@babylonjs/viewer 7.40.2-alpha → 7.40.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 (615) hide show
  1. package/configuration/configuration.d.ts +107 -0
  2. package/configuration/configuration.js +16 -0
  3. package/configuration/configuration.js.map +1 -0
  4. package/configuration/configurationCompatibility.d.ts +8 -0
  5. package/configuration/configurationCompatibility.js +66 -0
  6. package/configuration/configurationCompatibility.js.map +1 -0
  7. package/configuration/configurationContainer.d.ts +10 -0
  8. package/configuration/configurationContainer.js +10 -0
  9. package/configuration/configurationContainer.js.map +1 -0
  10. package/configuration/globals.d.ts +6 -0
  11. package/configuration/globals.js +18 -0
  12. package/configuration/globals.js.map +1 -0
  13. package/configuration/index.d.ts +2 -0
  14. package/configuration/index.js +4 -0
  15. package/configuration/index.js.map +1 -0
  16. package/configuration/interfaces/cameraConfiguration.d.ts +31 -0
  17. package/configuration/interfaces/cameraConfiguration.js +2 -0
  18. package/configuration/interfaces/cameraConfiguration.js.map +1 -0
  19. package/configuration/interfaces/colorGradingConfiguration.d.ts +81 -0
  20. package/configuration/interfaces/colorGradingConfiguration.js +2 -0
  21. package/configuration/interfaces/colorGradingConfiguration.js.map +1 -0
  22. package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +20 -0
  23. package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +2 -0
  24. package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +1 -0
  25. package/configuration/interfaces/environmentMapConfiguration.d.ts +22 -0
  26. package/configuration/interfaces/environmentMapConfiguration.js +2 -0
  27. package/configuration/interfaces/environmentMapConfiguration.js.map +1 -0
  28. package/configuration/interfaces/groundConfiguration.d.ts +24 -0
  29. package/configuration/interfaces/groundConfiguration.js +2 -0
  30. package/configuration/interfaces/groundConfiguration.js.map +1 -0
  31. package/configuration/interfaces/imageProcessingConfiguration.d.ts +45 -0
  32. package/configuration/interfaces/imageProcessingConfiguration.js +2 -0
  33. package/configuration/interfaces/imageProcessingConfiguration.js.map +1 -0
  34. package/configuration/interfaces/index.d.ts +15 -0
  35. package/configuration/interfaces/index.js +16 -0
  36. package/configuration/interfaces/index.js.map +1 -0
  37. package/configuration/interfaces/lightConfiguration.d.ts +60 -0
  38. package/configuration/interfaces/lightConfiguration.js +2 -0
  39. package/configuration/interfaces/lightConfiguration.js.map +1 -0
  40. package/configuration/interfaces/modelAnimationConfiguration.d.ts +26 -0
  41. package/configuration/interfaces/modelAnimationConfiguration.js +2 -0
  42. package/configuration/interfaces/modelAnimationConfiguration.js.map +1 -0
  43. package/configuration/interfaces/modelConfiguration.d.ts +65 -0
  44. package/configuration/interfaces/modelConfiguration.js +2 -0
  45. package/configuration/interfaces/modelConfiguration.js.map +1 -0
  46. package/configuration/interfaces/observersConfiguration.d.ts +5 -0
  47. package/configuration/interfaces/observersConfiguration.js +2 -0
  48. package/configuration/interfaces/observersConfiguration.js.map +1 -0
  49. package/configuration/interfaces/sceneConfiguration.d.ts +48 -0
  50. package/configuration/interfaces/sceneConfiguration.js +2 -0
  51. package/configuration/interfaces/sceneConfiguration.js.map +1 -0
  52. package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +23 -0
  53. package/configuration/interfaces/sceneOptimizerConfiguration.js +2 -0
  54. package/configuration/interfaces/sceneOptimizerConfiguration.js.map +1 -0
  55. package/configuration/interfaces/skyboxConfiguration.d.ts +21 -0
  56. package/configuration/interfaces/skyboxConfiguration.js +2 -0
  57. package/configuration/interfaces/skyboxConfiguration.js.map +1 -0
  58. package/configuration/interfaces/templateConfiguration.d.ts +67 -0
  59. package/configuration/interfaces/templateConfiguration.js +2 -0
  60. package/configuration/interfaces/templateConfiguration.js.map +1 -0
  61. package/configuration/interfaces/vrConfiguration.d.ts +16 -0
  62. package/configuration/interfaces/vrConfiguration.js +2 -0
  63. package/configuration/interfaces/vrConfiguration.js.map +1 -0
  64. package/configuration/loader.d.ts +4 -0
  65. package/configuration/loader.js +17 -0
  66. package/configuration/loader.js.map +1 -0
  67. package/configuration/mappers.d.ts +43 -0
  68. package/configuration/mappers.js +193 -0
  69. package/configuration/mappers.js.map +1 -0
  70. package/configuration/renderOnlyLoader.d.ts +33 -0
  71. package/configuration/renderOnlyLoader.js +162 -0
  72. package/configuration/renderOnlyLoader.js.map +1 -0
  73. package/configuration/types/default.d.ts +6 -0
  74. package/configuration/types/default.js +121 -0
  75. package/configuration/types/default.js.map +1 -0
  76. package/configuration/types/environmentMap.d.ts +5 -0
  77. package/configuration/types/environmentMap.js +14 -0
  78. package/configuration/types/environmentMap.js.map +1 -0
  79. package/configuration/types/extended.d.ts +6 -0
  80. package/configuration/types/extended.js +317 -0
  81. package/configuration/types/extended.js.map +1 -0
  82. package/configuration/types/index.d.ts +14 -0
  83. package/configuration/types/index.js +51 -0
  84. package/configuration/types/index.js.map +1 -0
  85. package/configuration/types/minimal.d.ts +6 -0
  86. package/configuration/types/minimal.js +43 -0
  87. package/configuration/types/minimal.js.map +1 -0
  88. package/configuration/types/renderOnlyDefault.d.ts +30 -0
  89. package/configuration/types/renderOnlyDefault.js +31 -0
  90. package/configuration/types/renderOnlyDefault.js.map +1 -0
  91. package/configuration/types/shadowLight.d.ts +9 -0
  92. package/configuration/types/shadowLight.js +64 -0
  93. package/configuration/types/shadowLight.js.map +1 -0
  94. package/helper/index.d.ts +29 -0
  95. package/helper/index.js +66 -0
  96. package/helper/index.js.map +1 -0
  97. package/index.d.ts +30 -0
  98. package/index.js +46 -0
  99. package/index.js.map +1 -0
  100. package/initializer.d.ts +11 -0
  101. package/initializer.js +35 -0
  102. package/initializer.js.map +1 -0
  103. package/interfaces.d.ts +5 -0
  104. package/interfaces.js +7 -0
  105. package/interfaces.js.map +1 -0
  106. package/labs/environmentSerializer.d.ts +126 -0
  107. package/labs/environmentSerializer.js +191 -0
  108. package/labs/environmentSerializer.js.map +1 -0
  109. package/labs/texture.d.ts +183 -0
  110. package/labs/texture.js +351 -0
  111. package/labs/texture.js.map +1 -0
  112. package/labs/viewerLabs.d.ts +51 -0
  113. package/labs/viewerLabs.js +134 -0
  114. package/labs/viewerLabs.js.map +1 -0
  115. package/loader/modelLoader.d.ts +56 -0
  116. package/loader/modelLoader.js +202 -0
  117. package/loader/modelLoader.js.map +1 -0
  118. package/loader/plugins/applyMaterialConfig.d.ts +12 -0
  119. package/loader/plugins/applyMaterialConfig.js +16 -0
  120. package/loader/plugins/applyMaterialConfig.js.map +1 -0
  121. package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +9 -0
  122. package/loader/plugins/extendedMaterialLoaderPlugin.js +16 -0
  123. package/loader/plugins/extendedMaterialLoaderPlugin.js.map +1 -0
  124. package/loader/plugins/index.d.ts +19 -0
  125. package/loader/plugins/index.js +44 -0
  126. package/loader/plugins/index.js.map +1 -0
  127. package/loader/plugins/loaderPlugin.d.ts +24 -0
  128. package/loader/plugins/loaderPlugin.js +2 -0
  129. package/loader/plugins/loaderPlugin.js.map +1 -0
  130. package/loader/plugins/msftLodLoaderPlugin.d.ts +12 -0
  131. package/loader/plugins/msftLodLoaderPlugin.js +21 -0
  132. package/loader/plugins/msftLodLoaderPlugin.js.map +1 -0
  133. package/loader/plugins/telemetryLoaderPlugin.d.ts +12 -0
  134. package/loader/plugins/telemetryLoaderPlugin.js +36 -0
  135. package/loader/plugins/telemetryLoaderPlugin.js.map +1 -0
  136. package/managers/observablesManager.d.ts +66 -0
  137. package/managers/observablesManager.js +35 -0
  138. package/managers/observablesManager.js.map +1 -0
  139. package/managers/sceneManager.d.ts +245 -0
  140. package/managers/sceneManager.js +1375 -0
  141. package/managers/sceneManager.js.map +1 -0
  142. package/managers/telemetryManager.d.ts +78 -0
  143. package/managers/telemetryManager.js +117 -0
  144. package/managers/telemetryManager.js.map +1 -0
  145. package/model/modelAnimation.d.ts +215 -0
  146. package/model/modelAnimation.js +237 -0
  147. package/model/modelAnimation.js.map +1 -0
  148. package/model/viewerModel.d.ts +233 -0
  149. package/model/viewerModel.js +673 -0
  150. package/model/viewerModel.js.map +1 -0
  151. package/optimizer/custom/extended.d.ts +13 -0
  152. package/optimizer/custom/extended.js +101 -0
  153. package/optimizer/custom/extended.js.map +1 -0
  154. package/optimizer/custom/index.d.ts +9 -0
  155. package/optimizer/custom/index.js +26 -0
  156. package/optimizer/custom/index.js.map +1 -0
  157. package/package.json +28 -19
  158. package/readme.md +28 -28
  159. package/renderOnlyIndex.d.ts +11 -0
  160. package/renderOnlyIndex.js +18 -0
  161. package/renderOnlyIndex.js.map +1 -0
  162. package/templating/eventManager.d.ts +35 -0
  163. package/templating/eventManager.js +66 -0
  164. package/templating/eventManager.js.map +1 -0
  165. package/templating/plugins/hdButtonPlugin.d.ts +9 -0
  166. package/templating/plugins/hdButtonPlugin.js +22 -0
  167. package/templating/plugins/hdButtonPlugin.js.map +1 -0
  168. package/templating/plugins/printButton.d.ts +9 -0
  169. package/templating/plugins/printButton.js +41 -0
  170. package/templating/plugins/printButton.js.map +1 -0
  171. package/templating/templateManager.d.ts +197 -0
  172. package/templating/templateManager.js +561 -0
  173. package/templating/templateManager.js.map +1 -0
  174. package/templating/viewerTemplatePlugin.d.ts +21 -0
  175. package/templating/viewerTemplatePlugin.js +69 -0
  176. package/templating/viewerTemplatePlugin.js.map +1 -0
  177. package/viewer/defaultViewer.d.ts +130 -0
  178. package/viewer/defaultViewer.js +672 -0
  179. package/viewer/defaultViewer.js.map +1 -0
  180. package/viewer/renderOnlyViewer.d.ts +9 -0
  181. package/viewer/renderOnlyViewer.js +46 -0
  182. package/viewer/renderOnlyViewer.js.map +1 -0
  183. package/viewer/viewer.d.ts +258 -0
  184. package/viewer/viewer.js +783 -0
  185. package/viewer/viewer.js.map +1 -0
  186. package/viewer/viewerManager.d.ts +58 -0
  187. package/viewer/viewerManager.js +91 -0
  188. package/viewer/viewerManager.js.map +1 -0
  189. package/viewer/viewerWithTemplate.d.ts +9 -0
  190. package/viewer/viewerWithTemplate.js +20 -0
  191. package/viewer/viewerWithTemplate.js.map +1 -0
  192. package/assets/photoStudio.env +0 -0
  193. package/dist/babylon-viewer.esm.js +0 -2
  194. package/dist/babylon-viewer.esm.js.map +0 -1
  195. package/dist/babylon-viewer.esm.min.js +0 -2
  196. package/dist/babylon-viewer.esm.min.js.map +0 -1
  197. package/dist/chunks/EXT_lights_ies-BrhvRw2-.esm.js +0 -84
  198. package/dist/chunks/EXT_lights_ies-BrhvRw2-.esm.js.map +0 -1
  199. package/dist/chunks/EXT_lights_ies-Ddw_Gk8Q.esm.min.js +0 -2
  200. package/dist/chunks/EXT_lights_ies-Ddw_Gk8Q.esm.min.js.map +0 -1
  201. package/dist/chunks/EXT_lights_image_based-BjoWM5tf.esm.min.js +0 -2
  202. package/dist/chunks/EXT_lights_image_based-BjoWM5tf.esm.min.js.map +0 -1
  203. package/dist/chunks/EXT_lights_image_based-Bt2TW49Q.esm.js +0 -171
  204. package/dist/chunks/EXT_lights_image_based-Bt2TW49Q.esm.js.map +0 -1
  205. package/dist/chunks/EXT_mesh_gpu_instancing-Cy595I0S.esm.js +0 -86
  206. package/dist/chunks/EXT_mesh_gpu_instancing-Cy595I0S.esm.js.map +0 -1
  207. package/dist/chunks/EXT_mesh_gpu_instancing-DbVyjoq7.esm.min.js +0 -2
  208. package/dist/chunks/EXT_mesh_gpu_instancing-DbVyjoq7.esm.min.js.map +0 -1
  209. package/dist/chunks/EXT_meshopt_compression-PLPAdJXy.esm.min.js +0 -2
  210. package/dist/chunks/EXT_meshopt_compression-PLPAdJXy.esm.min.js.map +0 -1
  211. package/dist/chunks/EXT_meshopt_compression-ynnPogtK.esm.js +0 -134
  212. package/dist/chunks/EXT_meshopt_compression-ynnPogtK.esm.js.map +0 -1
  213. package/dist/chunks/EXT_texture_avif-D2N-IXnv.esm.min.js +0 -2
  214. package/dist/chunks/EXT_texture_avif-D2N-IXnv.esm.min.js.map +0 -1
  215. package/dist/chunks/EXT_texture_avif-Vt2hSGI5.esm.js +0 -44
  216. package/dist/chunks/EXT_texture_avif-Vt2hSGI5.esm.js.map +0 -1
  217. package/dist/chunks/EXT_texture_webp-CWz2PiP_.esm.min.js +0 -2
  218. package/dist/chunks/EXT_texture_webp-CWz2PiP_.esm.min.js.map +0 -1
  219. package/dist/chunks/EXT_texture_webp-i_LM5STR.esm.js +0 -43
  220. package/dist/chunks/EXT_texture_webp-i_LM5STR.esm.js.map +0 -1
  221. package/dist/chunks/ExtrasAsMetadata-BPRuILS3.esm.js +0 -64
  222. package/dist/chunks/ExtrasAsMetadata-BPRuILS3.esm.js.map +0 -1
  223. package/dist/chunks/ExtrasAsMetadata-BpKCYcU-.esm.min.js +0 -2
  224. package/dist/chunks/ExtrasAsMetadata-BpKCYcU-.esm.min.js.map +0 -1
  225. package/dist/chunks/KHR_animation_pointer-D25vJZ-D.esm.js +0 -352
  226. package/dist/chunks/KHR_animation_pointer-D25vJZ-D.esm.js.map +0 -1
  227. package/dist/chunks/KHR_animation_pointer-WM3ggesH.esm.min.js +0 -2
  228. package/dist/chunks/KHR_animation_pointer-WM3ggesH.esm.min.js.map +0 -1
  229. package/dist/chunks/KHR_draco_mesh_compression-6AbT2wN8.esm.min.js +0 -2
  230. package/dist/chunks/KHR_draco_mesh_compression-6AbT2wN8.esm.min.js.map +0 -1
  231. package/dist/chunks/KHR_draco_mesh_compression-Bn3cig1r.esm.js +0 -617
  232. package/dist/chunks/KHR_draco_mesh_compression-Bn3cig1r.esm.js.map +0 -1
  233. package/dist/chunks/KHR_interactivity-BN92hPs7.esm.js +0 -4033
  234. package/dist/chunks/KHR_interactivity-BN92hPs7.esm.js.map +0 -1
  235. package/dist/chunks/KHR_interactivity-B_CAm57j.esm.min.js +0 -2
  236. package/dist/chunks/KHR_interactivity-B_CAm57j.esm.min.js.map +0 -1
  237. package/dist/chunks/KHR_lights_punctual-BGKxFRu8.esm.js +0 -581
  238. package/dist/chunks/KHR_lights_punctual-BGKxFRu8.esm.js.map +0 -1
  239. package/dist/chunks/KHR_lights_punctual-DCOXnpRP.esm.min.js +0 -2
  240. package/dist/chunks/KHR_lights_punctual-DCOXnpRP.esm.min.js.map +0 -1
  241. package/dist/chunks/KHR_materials_anisotropy-Dav3eIQr.esm.js +0 -65
  242. package/dist/chunks/KHR_materials_anisotropy-Dav3eIQr.esm.js.map +0 -1
  243. package/dist/chunks/KHR_materials_anisotropy-I_WlXBtU.esm.min.js +0 -2
  244. package/dist/chunks/KHR_materials_anisotropy-I_WlXBtU.esm.min.js.map +0 -1
  245. package/dist/chunks/KHR_materials_clearcoat-D_Vx4NDv.esm.js +0 -96
  246. package/dist/chunks/KHR_materials_clearcoat-D_Vx4NDv.esm.js.map +0 -1
  247. package/dist/chunks/KHR_materials_clearcoat-DrU2oJzb.esm.min.js +0 -2
  248. package/dist/chunks/KHR_materials_clearcoat-DrU2oJzb.esm.min.js.map +0 -1
  249. package/dist/chunks/KHR_materials_diffuse_transmission-C8j8KtbL.esm.js +0 -97
  250. package/dist/chunks/KHR_materials_diffuse_transmission-C8j8KtbL.esm.js.map +0 -1
  251. package/dist/chunks/KHR_materials_diffuse_transmission-YyXsJa9T.esm.min.js +0 -2
  252. package/dist/chunks/KHR_materials_diffuse_transmission-YyXsJa9T.esm.min.js.map +0 -1
  253. package/dist/chunks/KHR_materials_dispersion-3Dk8ELun.esm.min.js +0 -2
  254. package/dist/chunks/KHR_materials_dispersion-3Dk8ELun.esm.min.js.map +0 -1
  255. package/dist/chunks/KHR_materials_dispersion-8_vd0eka.esm.js +0 -62
  256. package/dist/chunks/KHR_materials_dispersion-8_vd0eka.esm.js.map +0 -1
  257. package/dist/chunks/KHR_materials_emissive_strength-6VqWp9kS.esm.js +0 -55
  258. package/dist/chunks/KHR_materials_emissive_strength-6VqWp9kS.esm.js.map +0 -1
  259. package/dist/chunks/KHR_materials_emissive_strength-Bpd-wcN6.esm.min.js +0 -2
  260. package/dist/chunks/KHR_materials_emissive_strength-Bpd-wcN6.esm.min.js.map +0 -1
  261. package/dist/chunks/KHR_materials_ior-BGPYY59r.esm.min.js +0 -2
  262. package/dist/chunks/KHR_materials_ior-BGPYY59r.esm.min.js.map +0 -1
  263. package/dist/chunks/KHR_materials_ior-Cs0X7UR6.esm.js +0 -64
  264. package/dist/chunks/KHR_materials_ior-Cs0X7UR6.esm.js.map +0 -1
  265. package/dist/chunks/KHR_materials_iridescence-BI7_Q9V2.esm.js +0 -72
  266. package/dist/chunks/KHR_materials_iridescence-BI7_Q9V2.esm.js.map +0 -1
  267. package/dist/chunks/KHR_materials_iridescence-CvIyjrbg.esm.min.js +0 -2
  268. package/dist/chunks/KHR_materials_iridescence-CvIyjrbg.esm.min.js.map +0 -1
  269. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-BFUvgZ3P.esm.min.js +0 -2
  270. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-BFUvgZ3P.esm.min.js.map +0 -1
  271. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-C3famAnb.esm.js +0 -81
  272. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-C3famAnb.esm.js.map +0 -1
  273. package/dist/chunks/KHR_materials_sheen-B4V2NlWD.esm.js +0 -85
  274. package/dist/chunks/KHR_materials_sheen-B4V2NlWD.esm.js.map +0 -1
  275. package/dist/chunks/KHR_materials_sheen-CegUHCDa.esm.min.js +0 -2
  276. package/dist/chunks/KHR_materials_sheen-CegUHCDa.esm.min.js.map +0 -1
  277. package/dist/chunks/KHR_materials_specular-CC5wN1RR.esm.min.js +0 -2
  278. package/dist/chunks/KHR_materials_specular-CC5wN1RR.esm.min.js.map +0 -1
  279. package/dist/chunks/KHR_materials_specular-TypCUJDx.esm.js +0 -75
  280. package/dist/chunks/KHR_materials_specular-TypCUJDx.esm.js.map +0 -1
  281. package/dist/chunks/KHR_materials_transmission-BY9yIcAF.esm.js +0 -307
  282. package/dist/chunks/KHR_materials_transmission-BY9yIcAF.esm.js.map +0 -1
  283. package/dist/chunks/KHR_materials_transmission-SU6SJMhP.esm.min.js +0 -2
  284. package/dist/chunks/KHR_materials_transmission-SU6SJMhP.esm.min.js.map +0 -1
  285. package/dist/chunks/KHR_materials_unlit-DOjLjYi4.esm.js +0 -74
  286. package/dist/chunks/KHR_materials_unlit-DOjLjYi4.esm.js.map +0 -1
  287. package/dist/chunks/KHR_materials_unlit-DwCYujyL.esm.min.js +0 -2
  288. package/dist/chunks/KHR_materials_unlit-DwCYujyL.esm.min.js.map +0 -1
  289. package/dist/chunks/KHR_materials_variants-BJUrgDp4.esm.js +0 -262
  290. package/dist/chunks/KHR_materials_variants-BJUrgDp4.esm.js.map +0 -1
  291. package/dist/chunks/KHR_materials_variants-BXHHmDq_.esm.min.js +0 -2
  292. package/dist/chunks/KHR_materials_variants-BXHHmDq_.esm.min.js.map +0 -1
  293. package/dist/chunks/KHR_materials_volume-D8a4cCjx.esm.min.js +0 -2
  294. package/dist/chunks/KHR_materials_volume-D8a4cCjx.esm.min.js.map +0 -1
  295. package/dist/chunks/KHR_materials_volume-cyXWRVXR.esm.js +0 -87
  296. package/dist/chunks/KHR_materials_volume-cyXWRVXR.esm.js.map +0 -1
  297. package/dist/chunks/KHR_mesh_quantization-BJCC5tJC.esm.min.js +0 -2
  298. package/dist/chunks/KHR_mesh_quantization-BJCC5tJC.esm.min.js.map +0 -1
  299. package/dist/chunks/KHR_mesh_quantization-BhTbEUzk.esm.js +0 -26
  300. package/dist/chunks/KHR_mesh_quantization-BhTbEUzk.esm.js.map +0 -1
  301. package/dist/chunks/KHR_node_hoverability-C2Bud6ES.esm.min.js +0 -2
  302. package/dist/chunks/KHR_node_hoverability-C2Bud6ES.esm.min.js.map +0 -1
  303. package/dist/chunks/KHR_node_hoverability-DlRIeNZh.esm.js +0 -39
  304. package/dist/chunks/KHR_node_hoverability-DlRIeNZh.esm.js.map +0 -1
  305. package/dist/chunks/KHR_node_visibility-CB2d0WsR.esm.js +0 -46
  306. package/dist/chunks/KHR_node_visibility-CB2d0WsR.esm.js.map +0 -1
  307. package/dist/chunks/KHR_node_visibility-CFk6SMES.esm.min.js +0 -2
  308. package/dist/chunks/KHR_node_visibility-CFk6SMES.esm.min.js.map +0 -1
  309. package/dist/chunks/KHR_texture_basisu-B68Sil5v.esm.js +0 -43
  310. package/dist/chunks/KHR_texture_basisu-B68Sil5v.esm.js.map +0 -1
  311. package/dist/chunks/KHR_texture_basisu-C2OGAWY7.esm.min.js +0 -2
  312. package/dist/chunks/KHR_texture_basisu-C2OGAWY7.esm.min.js.map +0 -1
  313. package/dist/chunks/KHR_texture_transform-Bk2KMc5C.esm.js +0 -63
  314. package/dist/chunks/KHR_texture_transform-Bk2KMc5C.esm.js.map +0 -1
  315. package/dist/chunks/KHR_texture_transform-D9MJQRee.esm.min.js +0 -2
  316. package/dist/chunks/KHR_texture_transform-D9MJQRee.esm.min.js.map +0 -1
  317. package/dist/chunks/KHR_xmp_json_ld-BkiGlm_U.esm.min.js +0 -2
  318. package/dist/chunks/KHR_xmp_json_ld-BkiGlm_U.esm.min.js.map +0 -1
  319. package/dist/chunks/KHR_xmp_json_ld-a9-wGW9D.esm.js +0 -51
  320. package/dist/chunks/KHR_xmp_json_ld-a9-wGW9D.esm.js.map +0 -1
  321. package/dist/chunks/MSFT_audio_emitter-B7aM8Qaz.esm.min.js +0 -2
  322. package/dist/chunks/MSFT_audio_emitter-B7aM8Qaz.esm.min.js.map +0 -1
  323. package/dist/chunks/MSFT_audio_emitter-D0Z8eJZb.esm.js +0 -2207
  324. package/dist/chunks/MSFT_audio_emitter-D0Z8eJZb.esm.js.map +0 -1
  325. package/dist/chunks/MSFT_lod-BjIiS7t9.esm.js +0 -337
  326. package/dist/chunks/MSFT_lod-BjIiS7t9.esm.js.map +0 -1
  327. package/dist/chunks/MSFT_lod-DIOF_rM4.esm.min.js +0 -2
  328. package/dist/chunks/MSFT_lod-DIOF_rM4.esm.min.js.map +0 -1
  329. package/dist/chunks/MSFT_minecraftMesh-Bx5s-9FS.esm.js +0 -46
  330. package/dist/chunks/MSFT_minecraftMesh-Bx5s-9FS.esm.js.map +0 -1
  331. package/dist/chunks/MSFT_minecraftMesh-EqwVrdf4.esm.min.js +0 -2
  332. package/dist/chunks/MSFT_minecraftMesh-EqwVrdf4.esm.min.js.map +0 -1
  333. package/dist/chunks/MSFT_sRGBFactors-BJH-moQl.esm.min.js +0 -2
  334. package/dist/chunks/MSFT_sRGBFactors-BJH-moQl.esm.min.js.map +0 -1
  335. package/dist/chunks/MSFT_sRGBFactors-Db1zWU4o.esm.js +0 -47
  336. package/dist/chunks/MSFT_sRGBFactors-Db1zWU4o.esm.js.map +0 -1
  337. package/dist/chunks/animationGroup-DjpN6ul8.esm.js +0 -2482
  338. package/dist/chunks/animationGroup-DjpN6ul8.esm.js.map +0 -1
  339. package/dist/chunks/animationGroup-Duijaphk.esm.min.js +0 -2
  340. package/dist/chunks/animationGroup-Duijaphk.esm.min.js.map +0 -1
  341. package/dist/chunks/assetContainer-2ZDjmTJ7.esm.min.js +0 -2
  342. package/dist/chunks/assetContainer-2ZDjmTJ7.esm.min.js.map +0 -1
  343. package/dist/chunks/assetContainer-nATkXNwM.esm.js +0 -1720
  344. package/dist/chunks/assetContainer-nATkXNwM.esm.js.map +0 -1
  345. package/dist/chunks/audioEngine-C2kMlYrt.esm.js +0 -305
  346. package/dist/chunks/audioEngine-C2kMlYrt.esm.js.map +0 -1
  347. package/dist/chunks/audioEngine-iEjhOdSs.esm.min.js +0 -2
  348. package/dist/chunks/audioEngine-iEjhOdSs.esm.min.js.map +0 -1
  349. package/dist/chunks/bakedVertexAnimation-CX_LYhI-.esm.js +0 -114
  350. package/dist/chunks/bakedVertexAnimation-CX_LYhI-.esm.js.map +0 -1
  351. package/dist/chunks/bakedVertexAnimation-Duhv1yIp.esm.min.js +0 -2
  352. package/dist/chunks/bakedVertexAnimation-Duhv1yIp.esm.min.js.map +0 -1
  353. package/dist/chunks/basisTextureLoader-BJrbh335.esm.min.js +0 -2
  354. package/dist/chunks/basisTextureLoader-BJrbh335.esm.min.js.map +0 -1
  355. package/dist/chunks/basisTextureLoader-KDTm6Vl6.esm.js +0 -600
  356. package/dist/chunks/basisTextureLoader-KDTm6Vl6.esm.js.map +0 -1
  357. package/dist/chunks/dds-BiituSHb.esm.min.js +0 -2
  358. package/dist/chunks/dds-BiituSHb.esm.min.js.map +0 -1
  359. package/dist/chunks/dds-CeXwQQLK.esm.js +0 -540
  360. package/dist/chunks/dds-CeXwQQLK.esm.js.map +0 -1
  361. package/dist/chunks/ddsTextureLoader-D38C-6i9.esm.min.js +0 -2
  362. package/dist/chunks/ddsTextureLoader-D38C-6i9.esm.min.js.map +0 -1
  363. package/dist/chunks/ddsTextureLoader-DZgDhz39.esm.js +0 -88
  364. package/dist/chunks/ddsTextureLoader-DZgDhz39.esm.js.map +0 -1
  365. package/dist/chunks/decalFragment-B0hAgbHQ.esm.js +0 -18
  366. package/dist/chunks/decalFragment-B0hAgbHQ.esm.js.map +0 -1
  367. package/dist/chunks/decalFragment-BisNb1SA.esm.min.js +0 -2
  368. package/dist/chunks/decalFragment-BisNb1SA.esm.min.js.map +0 -1
  369. package/dist/chunks/default.fragment-BKDPVw0f.esm.min.js +0 -2
  370. package/dist/chunks/default.fragment-BKDPVw0f.esm.min.js.map +0 -1
  371. package/dist/chunks/default.fragment-CKRvFrOX.esm.min.js +0 -2
  372. package/dist/chunks/default.fragment-CKRvFrOX.esm.min.js.map +0 -1
  373. package/dist/chunks/default.fragment-DBNZgft_.esm.js +0 -515
  374. package/dist/chunks/default.fragment-DBNZgft_.esm.js.map +0 -1
  375. package/dist/chunks/default.fragment-mEUMwg3j.esm.js +0 -446
  376. package/dist/chunks/default.fragment-mEUMwg3j.esm.js.map +0 -1
  377. package/dist/chunks/default.vertex-BIMZfH9h.esm.min.js +0 -2
  378. package/dist/chunks/default.vertex-BIMZfH9h.esm.min.js.map +0 -1
  379. package/dist/chunks/default.vertex-BYGJcupS.esm.js +0 -181
  380. package/dist/chunks/default.vertex-BYGJcupS.esm.js.map +0 -1
  381. package/dist/chunks/default.vertex-D-mtahDc.esm.min.js +0 -2
  382. package/dist/chunks/default.vertex-D-mtahDc.esm.min.js.map +0 -1
  383. package/dist/chunks/default.vertex-uhPv4tjg.esm.js +0 -202
  384. package/dist/chunks/default.vertex-uhPv4tjg.esm.js.map +0 -1
  385. package/dist/chunks/defaultUboDeclaration-CRSLp0Ab.esm.js +0 -13
  386. package/dist/chunks/defaultUboDeclaration-CRSLp0Ab.esm.js.map +0 -1
  387. package/dist/chunks/defaultUboDeclaration-CWb_GB6I.esm.min.js +0 -2
  388. package/dist/chunks/defaultUboDeclaration-CWb_GB6I.esm.min.js.map +0 -1
  389. package/dist/chunks/defaultUboDeclaration-Coy2X5Tb.esm.min.js +0 -2
  390. package/dist/chunks/defaultUboDeclaration-Coy2X5Tb.esm.min.js.map +0 -1
  391. package/dist/chunks/defaultUboDeclaration-vQgTvkEe.esm.js +0 -15
  392. package/dist/chunks/defaultUboDeclaration-vQgTvkEe.esm.js.map +0 -1
  393. package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js +0 -11
  394. package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js.map +0 -1
  395. package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js +0 -2
  396. package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js.map +0 -1
  397. package/dist/chunks/dumpTools-DO-b-FSI.esm.js +0 -200
  398. package/dist/chunks/dumpTools-DO-b-FSI.esm.js.map +0 -1
  399. package/dist/chunks/dumpTools-a-Jxv0UI.esm.min.js +0 -2
  400. package/dist/chunks/dumpTools-a-Jxv0UI.esm.min.js.map +0 -1
  401. package/dist/chunks/engine-BcUVpC0R.esm.js +0 -2216
  402. package/dist/chunks/engine-BcUVpC0R.esm.js.map +0 -1
  403. package/dist/chunks/engine-CBJrzwFS.esm.min.js +0 -2
  404. package/dist/chunks/engine-CBJrzwFS.esm.min.js.map +0 -1
  405. package/dist/chunks/engine.common-CSbFYR6g.esm.min.js +0 -2
  406. package/dist/chunks/engine.common-CSbFYR6g.esm.min.js.map +0 -1
  407. package/dist/chunks/engine.common-MyFhbP5R.esm.js +0 -1162
  408. package/dist/chunks/engine.common-MyFhbP5R.esm.js.map +0 -1
  409. package/dist/chunks/envTextureLoader-DFF091wY.esm.min.js +0 -2
  410. package/dist/chunks/envTextureLoader-DFF091wY.esm.min.js.map +0 -1
  411. package/dist/chunks/envTextureLoader-Mp-YE5HT.esm.js +0 -64
  412. package/dist/chunks/envTextureLoader-Mp-YE5HT.esm.js.map +0 -1
  413. package/dist/chunks/environmentTextureTools-B2Hu-wcq.esm.min.js +0 -2
  414. package/dist/chunks/environmentTextureTools-B2Hu-wcq.esm.min.js.map +0 -1
  415. package/dist/chunks/environmentTextureTools-Dd-a4rbC.esm.js +0 -382
  416. package/dist/chunks/environmentTextureTools-Dd-a4rbC.esm.js.map +0 -1
  417. package/dist/chunks/exrTextureLoader-DqVtC6Vz.esm.min.js +0 -2
  418. package/dist/chunks/exrTextureLoader-DqVtC6Vz.esm.min.js.map +0 -1
  419. package/dist/chunks/exrTextureLoader-yzAS6vzg.esm.js +0 -1683
  420. package/dist/chunks/exrTextureLoader-yzAS6vzg.esm.js.map +0 -1
  421. package/dist/chunks/fogFragment-B6w-VW0A.esm.js +0 -102
  422. package/dist/chunks/fogFragment-B6w-VW0A.esm.js.map +0 -1
  423. package/dist/chunks/fogFragment-BdwYc4_S.esm.js +0 -101
  424. package/dist/chunks/fogFragment-BdwYc4_S.esm.js.map +0 -1
  425. package/dist/chunks/fogFragment-CKVFmHTL.esm.min.js +0 -2
  426. package/dist/chunks/fogFragment-CKVFmHTL.esm.min.js.map +0 -1
  427. package/dist/chunks/fogFragment-CrTUuKN1.esm.min.js +0 -2
  428. package/dist/chunks/fogFragment-CrTUuKN1.esm.min.js.map +0 -1
  429. package/dist/chunks/fresnelFunction-BeTviBu9.esm.js +0 -12
  430. package/dist/chunks/fresnelFunction-BeTviBu9.esm.js.map +0 -1
  431. package/dist/chunks/fresnelFunction-BsRBgxHr.esm.min.js +0 -2
  432. package/dist/chunks/fresnelFunction-BsRBgxHr.esm.min.js.map +0 -1
  433. package/dist/chunks/glTFLoader-BNxQLfRc.esm.min.js +0 -2
  434. package/dist/chunks/glTFLoader-BNxQLfRc.esm.min.js.map +0 -1
  435. package/dist/chunks/glTFLoader-C3ib4SHM.esm.js +0 -7586
  436. package/dist/chunks/glTFLoader-C3ib4SHM.esm.js.map +0 -1
  437. package/dist/chunks/glTFLoaderAnimation-BNIOeHW6.esm.min.js +0 -2
  438. package/dist/chunks/glTFLoaderAnimation-BNIOeHW6.esm.min.js.map +0 -1
  439. package/dist/chunks/glTFLoaderAnimation-CIZW3HpB.esm.js +0 -77
  440. package/dist/chunks/glTFLoaderAnimation-CIZW3HpB.esm.js.map +0 -1
  441. package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js +0 -2
  442. package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js.map +0 -1
  443. package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js +0 -67
  444. package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js.map +0 -1
  445. package/dist/chunks/harmonicsFunctions-BEk7hjTV.esm.js +0 -35
  446. package/dist/chunks/harmonicsFunctions-BEk7hjTV.esm.js.map +0 -1
  447. package/dist/chunks/harmonicsFunctions-DNd3DvtK.esm.js +0 -34
  448. package/dist/chunks/harmonicsFunctions-DNd3DvtK.esm.js.map +0 -1
  449. package/dist/chunks/harmonicsFunctions-Dcle49vi.esm.min.js +0 -2
  450. package/dist/chunks/harmonicsFunctions-Dcle49vi.esm.min.js.map +0 -1
  451. package/dist/chunks/harmonicsFunctions-yt7loS1y.esm.min.js +0 -2
  452. package/dist/chunks/harmonicsFunctions-yt7loS1y.esm.min.js.map +0 -1
  453. package/dist/chunks/hdrTextureLoader-CVa1eQ0k.esm.min.js +0 -2
  454. package/dist/chunks/hdrTextureLoader-CVa1eQ0k.esm.min.js.map +0 -1
  455. package/dist/chunks/hdrTextureLoader-vBST57Sm.esm.js +0 -253
  456. package/dist/chunks/hdrTextureLoader-vBST57Sm.esm.js.map +0 -1
  457. package/dist/chunks/helperFunctions-CZ3iJ2Zw.esm.js +0 -108
  458. package/dist/chunks/helperFunctions-CZ3iJ2Zw.esm.js.map +0 -1
  459. package/dist/chunks/helperFunctions-D0BgwVW1.esm.min.js +0 -2
  460. package/dist/chunks/helperFunctions-D0BgwVW1.esm.min.js.map +0 -1
  461. package/dist/chunks/helperFunctions-DjXuKfJE.esm.min.js +0 -2
  462. package/dist/chunks/helperFunctions-DjXuKfJE.esm.min.js.map +0 -1
  463. package/dist/chunks/helperFunctions-utyx3wAA.esm.js +0 -80
  464. package/dist/chunks/helperFunctions-utyx3wAA.esm.js.map +0 -1
  465. package/dist/chunks/iesTextureLoader-CROHHiJh.esm.js +0 -189
  466. package/dist/chunks/iesTextureLoader-CROHHiJh.esm.js.map +0 -1
  467. package/dist/chunks/iesTextureLoader-WrbecGoP.esm.min.js +0 -2
  468. package/dist/chunks/iesTextureLoader-WrbecGoP.esm.min.js.map +0 -1
  469. package/dist/chunks/index-DnSap2FI.esm.js +0 -74799
  470. package/dist/chunks/index-DnSap2FI.esm.js.map +0 -1
  471. package/dist/chunks/index-j2tloO6T.esm.min.js +0 -57
  472. package/dist/chunks/index-j2tloO6T.esm.min.js.map +0 -1
  473. package/dist/chunks/ktxTextureLoader-BiAsvhuB.esm.js +0 -814
  474. package/dist/chunks/ktxTextureLoader-BiAsvhuB.esm.js.map +0 -1
  475. package/dist/chunks/ktxTextureLoader-DdTyaRVu.esm.min.js +0 -2
  476. package/dist/chunks/ktxTextureLoader-DdTyaRVu.esm.min.js.map +0 -1
  477. package/dist/chunks/logDepthDeclaration-B3OVyLof.esm.min.js +0 -2
  478. package/dist/chunks/logDepthDeclaration-B3OVyLof.esm.min.js.map +0 -1
  479. package/dist/chunks/logDepthDeclaration-B7WZlAEH.esm.min.js +0 -2
  480. package/dist/chunks/logDepthDeclaration-B7WZlAEH.esm.min.js.map +0 -1
  481. package/dist/chunks/logDepthDeclaration-C4zeVBON.esm.js +0 -11
  482. package/dist/chunks/logDepthDeclaration-C4zeVBON.esm.js.map +0 -1
  483. package/dist/chunks/logDepthDeclaration-CWmx6aVd.esm.js +0 -35
  484. package/dist/chunks/logDepthDeclaration-CWmx6aVd.esm.js.map +0 -1
  485. package/dist/chunks/logDepthVertex-7PIzO8Uh.esm.js +0 -81
  486. package/dist/chunks/logDepthVertex-7PIzO8Uh.esm.js.map +0 -1
  487. package/dist/chunks/logDepthVertex-CplbMCm2.esm.min.js +0 -2
  488. package/dist/chunks/logDepthVertex-CplbMCm2.esm.min.js.map +0 -1
  489. package/dist/chunks/logDepthVertex-bHa3hoU5.esm.min.js +0 -2
  490. package/dist/chunks/logDepthVertex-bHa3hoU5.esm.min.js.map +0 -1
  491. package/dist/chunks/logDepthVertex-vHSzwfZ-.esm.js +0 -77
  492. package/dist/chunks/logDepthVertex-vHSzwfZ-.esm.js.map +0 -1
  493. package/dist/chunks/mainUVVaryingDeclaration-CNqYA-gB.esm.min.js +0 -2
  494. package/dist/chunks/mainUVVaryingDeclaration-CNqYA-gB.esm.min.js.map +0 -1
  495. package/dist/chunks/mainUVVaryingDeclaration-CeQvcMfP.esm.js +0 -11
  496. package/dist/chunks/mainUVVaryingDeclaration-CeQvcMfP.esm.js.map +0 -1
  497. package/dist/chunks/mainUVVaryingDeclaration-CvsL0qYU.esm.min.js +0 -2
  498. package/dist/chunks/mainUVVaryingDeclaration-CvsL0qYU.esm.min.js.map +0 -1
  499. package/dist/chunks/mainUVVaryingDeclaration-utHd2T0O.esm.js +0 -11
  500. package/dist/chunks/mainUVVaryingDeclaration-utHd2T0O.esm.js.map +0 -1
  501. package/dist/chunks/meshUboDeclaration-BJPUJrXy.esm.min.js +0 -2
  502. package/dist/chunks/meshUboDeclaration-BJPUJrXy.esm.min.js.map +0 -1
  503. package/dist/chunks/meshUboDeclaration-VYoDYbYC.esm.js +0 -26
  504. package/dist/chunks/meshUboDeclaration-VYoDYbYC.esm.js.map +0 -1
  505. package/dist/chunks/objFileLoader-8afS-_hY.esm.js +0 -1338
  506. package/dist/chunks/objFileLoader-8afS-_hY.esm.js.map +0 -1
  507. package/dist/chunks/objFileLoader-BzLe6gaH.esm.min.js +0 -2
  508. package/dist/chunks/objFileLoader-BzLe6gaH.esm.min.js.map +0 -1
  509. package/dist/chunks/oitFragment-CHqqW65b.esm.js +0 -1240
  510. package/dist/chunks/oitFragment-CHqqW65b.esm.js.map +0 -1
  511. package/dist/chunks/oitFragment-CeyJ_Jg6.esm.min.js +0 -2
  512. package/dist/chunks/oitFragment-CeyJ_Jg6.esm.min.js.map +0 -1
  513. package/dist/chunks/oitFragment-D_sf5Zw1.esm.min.js +0 -2
  514. package/dist/chunks/oitFragment-D_sf5Zw1.esm.min.js.map +0 -1
  515. package/dist/chunks/oitFragment-alnyZbc9.esm.js +0 -1078
  516. package/dist/chunks/oitFragment-alnyZbc9.esm.js.map +0 -1
  517. package/dist/chunks/pass.fragment-CwG7GshA.esm.js +0 -15
  518. package/dist/chunks/pass.fragment-CwG7GshA.esm.js.map +0 -1
  519. package/dist/chunks/pass.fragment-DfyFrxFg.esm.min.js +0 -2
  520. package/dist/chunks/pass.fragment-DfyFrxFg.esm.min.js.map +0 -1
  521. package/dist/chunks/pass.fragment-DvFaAVdg.esm.min.js +0 -2
  522. package/dist/chunks/pass.fragment-DvFaAVdg.esm.min.js.map +0 -1
  523. package/dist/chunks/pass.fragment-ZOmfFzXO.esm.js +0 -15
  524. package/dist/chunks/pass.fragment-ZOmfFzXO.esm.js.map +0 -1
  525. package/dist/chunks/pbr.fragment-C3zMQTsB.esm.min.js +0 -2
  526. package/dist/chunks/pbr.fragment-C3zMQTsB.esm.min.js.map +0 -1
  527. package/dist/chunks/pbr.fragment-CwRrGfA1.esm.js +0 -3232
  528. package/dist/chunks/pbr.fragment-CwRrGfA1.esm.js.map +0 -1
  529. package/dist/chunks/pbr.fragment-nFI8xyI0.esm.min.js +0 -2
  530. package/dist/chunks/pbr.fragment-nFI8xyI0.esm.min.js.map +0 -1
  531. package/dist/chunks/pbr.fragment-q5uFa6s9.esm.js +0 -3273
  532. package/dist/chunks/pbr.fragment-q5uFa6s9.esm.js.map +0 -1
  533. package/dist/chunks/pbr.vertex-CTHhPDZF.esm.js +0 -214
  534. package/dist/chunks/pbr.vertex-CTHhPDZF.esm.js.map +0 -1
  535. package/dist/chunks/pbr.vertex-CzNCwEDt.esm.min.js +0 -2
  536. package/dist/chunks/pbr.vertex-CzNCwEDt.esm.min.js.map +0 -1
  537. package/dist/chunks/pbr.vertex-CzdtHEkI.esm.min.js +0 -2
  538. package/dist/chunks/pbr.vertex-CzdtHEkI.esm.min.js.map +0 -1
  539. package/dist/chunks/pbr.vertex-xNnroO_M.esm.js +0 -339
  540. package/dist/chunks/pbr.vertex-xNnroO_M.esm.js.map +0 -1
  541. package/dist/chunks/postprocess.vertex-BYAf7HA1.esm.min.js +0 -2
  542. package/dist/chunks/postprocess.vertex-BYAf7HA1.esm.min.js.map +0 -1
  543. package/dist/chunks/postprocess.vertex-CbyPpEkq.esm.js +0 -20
  544. package/dist/chunks/postprocess.vertex-CbyPpEkq.esm.js.map +0 -1
  545. package/dist/chunks/rawTexture-CBbxz3pc.esm.js +0 -191
  546. package/dist/chunks/rawTexture-CBbxz3pc.esm.js.map +0 -1
  547. package/dist/chunks/rawTexture-DPGXBgNz.esm.min.js +0 -2
  548. package/dist/chunks/rawTexture-DPGXBgNz.esm.min.js.map +0 -1
  549. package/dist/chunks/ray-C_Cg5Enj.esm.js +0 -946
  550. package/dist/chunks/ray-C_Cg5Enj.esm.js.map +0 -1
  551. package/dist/chunks/ray-VbeIB6un.esm.min.js +0 -2
  552. package/dist/chunks/ray-VbeIB6un.esm.min.js.map +0 -1
  553. package/dist/chunks/rgbdDecode.fragment-C8j9F7Bp.esm.js +0 -13
  554. package/dist/chunks/rgbdDecode.fragment-C8j9F7Bp.esm.js.map +0 -1
  555. package/dist/chunks/rgbdDecode.fragment-CcXKr577.esm.js +0 -13
  556. package/dist/chunks/rgbdDecode.fragment-CcXKr577.esm.js.map +0 -1
  557. package/dist/chunks/rgbdDecode.fragment-Cwx1U7TE.esm.min.js +0 -2
  558. package/dist/chunks/rgbdDecode.fragment-Cwx1U7TE.esm.min.js.map +0 -1
  559. package/dist/chunks/rgbdDecode.fragment-DAz-9d4q.esm.min.js +0 -2
  560. package/dist/chunks/rgbdDecode.fragment-DAz-9d4q.esm.min.js.map +0 -1
  561. package/dist/chunks/rgbdEncode.fragment-B-B_-l4T.esm.min.js +0 -2
  562. package/dist/chunks/rgbdEncode.fragment-B-B_-l4T.esm.min.js.map +0 -1
  563. package/dist/chunks/rgbdEncode.fragment-C-IhOuE7.esm.js +0 -13
  564. package/dist/chunks/rgbdEncode.fragment-C-IhOuE7.esm.js.map +0 -1
  565. package/dist/chunks/rgbdEncode.fragment-D2kStupC.esm.min.js +0 -2
  566. package/dist/chunks/rgbdEncode.fragment-D2kStupC.esm.min.js.map +0 -1
  567. package/dist/chunks/rgbdEncode.fragment-DqeaHLSx.esm.js +0 -13
  568. package/dist/chunks/rgbdEncode.fragment-DqeaHLSx.esm.js.map +0 -1
  569. package/dist/chunks/splatFileLoader-CM4z7s6S.esm.min.js +0 -2
  570. package/dist/chunks/splatFileLoader-CM4z7s6S.esm.min.js.map +0 -1
  571. package/dist/chunks/splatFileLoader-DE83jdwc.esm.js +0 -3379
  572. package/dist/chunks/splatFileLoader-DE83jdwc.esm.js.map +0 -1
  573. package/dist/chunks/spotLight-98FksSI3.esm.min.js +0 -2
  574. package/dist/chunks/spotLight-98FksSI3.esm.min.js.map +0 -1
  575. package/dist/chunks/spotLight-DuWkoiV8.esm.js +0 -701
  576. package/dist/chunks/spotLight-DuWkoiV8.esm.js.map +0 -1
  577. package/dist/chunks/standardMaterial-Bp1mTX1d.esm.js +0 -1805
  578. package/dist/chunks/standardMaterial-Bp1mTX1d.esm.js.map +0 -1
  579. package/dist/chunks/standardMaterial-D8kKjcZn.esm.min.js +0 -2
  580. package/dist/chunks/standardMaterial-D8kKjcZn.esm.min.js.map +0 -1
  581. package/dist/chunks/stlFileLoader-BFPumqQB.esm.js +0 -238
  582. package/dist/chunks/stlFileLoader-BFPumqQB.esm.js.map +0 -1
  583. package/dist/chunks/stlFileLoader-BosbmaNZ.esm.min.js +0 -2
  584. package/dist/chunks/stlFileLoader-BosbmaNZ.esm.min.js.map +0 -1
  585. package/dist/chunks/tgaTextureLoader-CKRrtbo-.esm.min.js +0 -2
  586. package/dist/chunks/tgaTextureLoader-CKRrtbo-.esm.min.js.map +0 -1
  587. package/dist/chunks/tgaTextureLoader-PEVGE0SY.esm.js +0 -349
  588. package/dist/chunks/tgaTextureLoader-PEVGE0SY.esm.js.map +0 -1
  589. package/dist/chunks/thinEngine-kKYV_9vd.esm.js +0 -3848
  590. package/dist/chunks/thinEngine-kKYV_9vd.esm.js.map +0 -1
  591. package/dist/chunks/thinEngine-x_AyHrxY.esm.min.js +0 -2
  592. package/dist/chunks/thinEngine-x_AyHrxY.esm.min.js.map +0 -1
  593. package/dist/chunks/thinInstanceMesh-BlVs6kyh.esm.js +0 -314
  594. package/dist/chunks/thinInstanceMesh-BlVs6kyh.esm.js.map +0 -1
  595. package/dist/chunks/thinInstanceMesh-CNDaksPN.esm.min.js +0 -2
  596. package/dist/chunks/thinInstanceMesh-CNDaksPN.esm.min.js.map +0 -1
  597. package/dist/chunks/vertexColorMixing-2eNeJSgA.esm.min.js +0 -2
  598. package/dist/chunks/vertexColorMixing-2eNeJSgA.esm.min.js.map +0 -1
  599. package/dist/chunks/vertexColorMixing-BjOdZrk-.esm.js +0 -412
  600. package/dist/chunks/vertexColorMixing-BjOdZrk-.esm.js.map +0 -1
  601. package/dist/chunks/vertexColorMixing-BpqdwwOR.esm.min.js +0 -2
  602. package/dist/chunks/vertexColorMixing-BpqdwwOR.esm.min.js.map +0 -1
  603. package/dist/chunks/vertexColorMixing-CuP50ad9.esm.js +0 -522
  604. package/dist/chunks/vertexColorMixing-CuP50ad9.esm.js.map +0 -1
  605. package/dist/chunks/webgpuEngine-BW5Z2CFp.esm.min.js +0 -2
  606. package/dist/chunks/webgpuEngine-BW5Z2CFp.esm.min.js.map +0 -1
  607. package/dist/chunks/webgpuEngine-Cwdi0UKo.esm.js +0 -11533
  608. package/dist/chunks/webgpuEngine-Cwdi0UKo.esm.js.map +0 -1
  609. package/dist/chunks/workerPool-BUOov2K1.esm.js +0 -122
  610. package/dist/chunks/workerPool-BUOov2K1.esm.js.map +0 -1
  611. package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js +0 -2
  612. package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js.map +0 -1
  613. package/lib/index.d.ts +0 -591
  614. package/lib/index.js +0 -2165
  615. package/lib/index.js.map +0 -1
@@ -1,57 +0,0 @@
1
- function e(e,t,i,s){var r,n=arguments.length,a=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(n<3?r(a):n>3?r(t,i,a):r(t,i))||a);return n>3&&a&&Object.defineProperty(t,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const t={},i={};function s(e){const s=e.getClassName();if(t[s])return t[s];t[s]={};const r=t[s];let n=e,a=s;for(;a;){const e=i[a];for(const t in e)r[t]=e[t];let t,s=!1;do{if(t=Object.getPrototypeOf(n),!t.getClassName){s=!0;break}if(t.getClassName()!==a)break;n=t}while(t);if(s)break;a=t.getClassName(),n=t}return r}function r(e,t){return(s,r)=>{const n=function(e){const t=e.getClassName();return i[t]||(i[t]={}),i[t]}(s);n[r]||(n[r]={type:e,sourceName:t})}}function n(e,t=null){return function(e,t=null){return(i,s)=>{const r=t||"_"+s;Object.defineProperty(i,s,{get:function(){return this[r]},set:function(t){"function"==typeof this.equals&&this.equals(t)||this[r]!==t&&(this[r]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}(e,t)}function a(e){return r(0,e)}function o(e){return r(1,e)}function h(e){return r(2,e)}function l(e){return r(3,e)}function c(e){return r(4,e)}function u(e){return r(5,e)}function d(e){return r(6,e)}function _(e){return r(8,e)}function f(e){return r(12,e)}function p(e,t,i,s){const r=i.value;i.value=(...i)=>{let n=r;if("undefined"!=typeof _native&&_native[t]){const e=_native[t];n=s?(...t)=>s(...t)?e(...t):r(...t):e}return e[t]=n,n(...i)}}p.filter=function(e){return(t,i,s)=>p(t,i,s,e)};const g="undefined"!=typeof WeakRef;class m{constructor(e,t=!1,i,s){this.initialize(e,t,i,s)}initialize(e,t=!1,i,s){return this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=s,this}}class T{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(){this._remove&&this._remove()}}class A{static FromPromise(e,t){const i=new A;return e.then((e=>{i.notifyObservers(e)})).catch((e=>{if(!t)throw e;t.notifyObservers(e)})),i}get observers(){return this._observers}constructor(e,t=!1){this.notifyIfTriggered=t,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new m(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const n=new T(e,t,s);n.unregisterOnNextCall=r,i?this._observers.unshift(n):this._observers.push(n),this._onObserverAdded&&this._onObserverAdded(n),this._hasNotified&&this.notifyIfTriggered&&void 0!==this._lastNotifiedValue&&this.notifyObserver(n,this._lastNotifiedValue);const a=g?new WeakRef(this):{deref:()=>this};return n._remove=()=>{const e=a.deref();e&&e._remove(n)},n}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){if(!e)return!1;e._remove=null;return-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0)}removeCallback(e,t){for(let i=0;i<this._observers.length;i++){const s=this._observers[i];if(!s._willBeUnregistered&&(s.callback===e&&(!t||t===s.scope)))return this._deferUnregister(s),!0}return!1}_deferUnregister(e){e._willBeUnregistered||(this._numObserversMarkedAsDeleted++,e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout((()=>{this._remove(e)}),0))}_remove(e,t=!0){if(!e)return!1;const i=this._observers.indexOf(e);return-1!==i&&(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0)}makeObserverTopPriority(e){this._remove(e,!1),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e,!1),this._observers.push(e)}notifyObservers(e,t=-1,i,s,r){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;const n=this._eventState;n.mask=t,n.target=i,n.currentTarget=s,n.skipNextObservers=!1,n.lastReturnValue=e,n.userInfo=r;for(const i of this._observers)if(!i._willBeUnregistered&&(i.mask&t&&(i.unregisterOnNextCall&&this._deferUnregister(i),i.scope?n.lastReturnValue=i.callback.apply(i.scope,[e,n]):n.lastReturnValue=i.callback(e,n)),n.skipNextObservers))return!1;return!0}notifyObserver(e,t,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;const s=this._eventState;s.mask=i,s.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,s)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){const e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()}cleanLastNotifiedState(){this._hasNotified=!1,this._lastNotifiedValue=void 0}clone(){const e=new A;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(const t of this._observers)if(t.mask&e||t.mask===e)return!0;return!1}}const E=1/2.2,b=2.2,R=.001;function y(e,t){const i=[];for(let s=0;s<e;++s)i.push(t());return i}function I(e,t){return y(e,t)}const M=["push","splice","pop","shift","unshift"];function v(e,t){const i=M.map((i=>function(e,t,i){const s=e[t];if("function"!=typeof s)return null;const r=function(){const s=e.length,n=r.previous.apply(e,arguments);return i(t,s),n};return s.next=r,r.previous=s,e[t]=r,()=>{const i=r.previous;if(!i)return;const s=r.next;s?(i.next=s,s.previous=i):(i.next=void 0,e[t]=i),r.next=void 0,r.previous=void 0}}(e,i,t)));return()=>{i.forEach((e=>{e?.()}))}}const x={};function S(e,t){x[e]=t}function C(e){return x[e]}class P{static SetMatrixPrecision(e){if(P.MatrixTrackPrecisionChange=!1,e&&!P.MatrixUse64Bits&&P.MatrixTrackedMatrices)for(let e=0;e<P.MatrixTrackedMatrices.length;++e){const t=P.MatrixTrackedMatrices[e],i=t._m;t._m=new Array(16);for(let e=0;e<16;++e)t._m[e]=i[e]}P.MatrixUse64Bits=e,P.MatrixCurrentType=P.MatrixUse64Bits?Array:Float32Array,P.MatrixTrackedMatrices=null}}P.MatrixUse64Bits=!1,P.MatrixTrackPrecisionChange=!0,P.MatrixCurrentType=Float32Array,P.MatrixTrackedMatrices=[];class O{static get LastCreatedEngine(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}function D(e,t,i=1401298e-51){return Math.abs(e-t)<=i}function L(e,t){return e===t?e:Math.random()*(t-e)+e}function F(e,t,i){return e+(t-e)*i}function w(e,t,i,s,r){const n=r*r,a=r*n;return e*(2*a-3*n+1)+i*(-2*a+3*n)+t*(a-2*n+r)+s*(a-n)}function N(e,t=0,i=1){return Math.min(i,Math.max(t,e))}function B(e){return e-=2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function U(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}function k(e){if(Math.log2)return Math.floor(Math.log2(e));if(e<0)return NaN;if(0===e)return-1/0;let t=0;if(e<1){for(;e<1;)t++,e*=2;t=-t}else if(e>1)for(;e>1;)t++,e=Math.floor(e/2);return t}function V(e,t){return e-Math.floor(e/t)*t}function z(e,t){let i=V(t-e,360);return i>180&&(i-=360),i}function G(e,t,i){let s=0;return s=Math.abs(t-e)<=i?t:e+Math.sign(t-e)*i,s}function H(e,t){const i=e%t;return 0===i?t:H(t,i)}O.Instances=[],O.OnEnginesDisposedObservable=new A,O._LastCreatedScene=null,O.UseFallbackTexture=!0,O.FallbackTexture="";var W=Object.freeze({__proto__:null,Clamp:N,DeltaAngle:z,Denormalize:function(e,t,i){return e*(i-t)+t},ExtractAsInt:function(e){return parseInt(e.toString().replace(/\W/g,""))},Hermite:w,Hermite1stDerivative:function(e,t,i,s,r){const n=r*r;return 6*(n-r)*e+(3*n-4*r+1)*t+6*(-n+r)*i+(3*n-2*r)*s},HighestCommonFactor:H,ILog2:k,InverseLerp:function(e,t,i){let s=0;return s=e!=t?N((i-e)/(t-e)):0,s},Lerp:F,LerpAngle:function(e,t,i){let s=V(t-e,360);return s>180&&(s-=360),e+s*N(i)},MoveTowards:G,MoveTowardsAngle:function(e,t,i){const s=z(e,t);let r=0;return r=-i<s&&s<i?t:G(e,t=e+s,i),r},Normalize:function(e,t,i){return(e-t)/(i-t)},NormalizeRadians:B,PercentToRange:function(e,t,i){return(i-t)*e+t},PingPong:function(e,t){const i=V(e,2*t);return t-Math.abs(i-t)},RandomRange:L,RangeToPercent:function(e,t,i){return(e-t)/(i-t)},Repeat:V,SmoothStep:function(e,t,i){let s=N(i);return s=-2*s*s*s+3*s*s,t*s+e*(1-s)},ToHex:U,WithinEpsilon:D});const K=e=>parseInt(e.toString().replace(/\W/g,""));class Y{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){let e=K(this.x);return e=397*e^K(this.y),e}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return Y.FromArrayToRef(e,t,this),this}asArray(){return[this.x,this.y]}copyFrom(e){return this.x=e.x,this.y=e.y,this}copyFromFloats(e,t){return this.x=e,this.y=t,this}set(e,t){return this.copyFromFloats(e,t)}setAll(e){return this.copyFromFloats(e,e)}add(e){return new Y(this.x+e.x,this.y+e.y)}addToRef(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t}addInPlace(e){return this.x+=e.x,this.y+=e.y,this}addInPlaceFromFloats(e,t){return this.x+=e,this.y+=t,this}addVector3(e){return new Y(this.x+e.x,this.y+e.y)}subtract(e){return new Y(this.x-e.x,this.y-e.y)}subtractToRef(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this}multiply(e){return new Y(this.x*e.x,this.y*e.y)}multiplyToRef(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t}multiplyByFloats(e,t){return new Y(this.x*e,this.y*t)}divide(e){return new Y(this.x/e.x,this.y/e.y)}divideToRef(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t}divideInPlace(e){return this.x=this.x/e.x,this.y=this.y/e.y,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.x,e.y)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.x,e.y)}minimizeInPlaceFromFloats(e,t){return this.x=Math.min(e,this.x),this.y=Math.min(t,this.y),this}maximizeInPlaceFromFloats(e,t){return this.x=Math.max(e,this.x),this.y=Math.max(t,this.y),this}subtractFromFloats(e,t){return new Y(this.x-e,this.y-t)}subtractFromFloatsToRef(e,t,i){return i.x=this.x-e,i.y=this.y-t,i}negate(){return new Y(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){return new Y(this.x*e,this.y*e)}scaleToRef(e,t){return t.x=this.x*e,t.y=this.y*e,t}scaleAndAddToRef(e,t){return t.x+=this.x*e,t.y+=this.y*e,t}equals(e){return e&&this.x===e.x&&this.y===e.y}equalsWithEpsilon(e,t=.001){return e&&D(this.x,e.x,t)&&D(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new Y(Math.floor(this.x),Math.floor(this.y))}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e}fract(){return new Y(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotateToRef(e,t){const i=Math.cos(e),s=Math.sin(e),r=i*this.x-s*this.y,n=s*this.x+i*this.y;return t.x=r,t.y=n,t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new Y;return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return 0===t&&(e.x=this.x,e.y=this.y),this.scaleToRef(1/t,e)}clone(){return new Y(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new Y(0,0)}static One(){return new Y(1,1)}static Random(e=0,t=1){return new Y(L(e,t),L(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(L(e,t),L(e,t))}static get ZeroReadOnly(){return Y._ZeroReadOnly}static FromArray(e,t=0){return new Y(e[t],e[t+1])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i}static FromFloatsToRef(e,t,i){return i.copyFromFloats(e,t),i}static CatmullRom(e,t,i,s,r){const n=r*r,a=r*n,o=.5*(2*t.x+(-e.x+i.x)*r+(2*e.x-5*t.x+4*i.x-s.x)*n+(-e.x+3*t.x-3*i.x+s.x)*a),h=.5*(2*t.y+(-e.y+i.y)*r+(2*e.y-5*t.y+4*i.y-s.y)*n+(-e.y+3*t.y-3*i.y+s.y)*a);return new Y(o,h)}static ClampToRef(e,t,i,s){return s.x=N(e.x,t.x,i.x),s.y=N(e.y,t.y,i.y),s}static Clamp(e,t,i){const s=N(e.x,t.x,i.x),r=N(e.y,t.y,i.y);return new Y(s,r)}static Hermite(e,t,i,s,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e.x*o+i.x*h+t.x*l+s.x*c,d=e.y*o+i.y*h+t.y*l+s.y*c;return new Y(u,d)}static Hermite1stDerivative(e,t,i,s,r){return this.Hermite1stDerivativeToRef(e,t,i,s,r,new Y)}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;return n.x=6*(a-r)*e.x+(3*a-4*r+1)*t.x+6*(-a+r)*i.x+(3*a-2*r)*s.x,n.y=6*(a-r)*e.y+(3*a-4*r+1)*t.y+6*(-a+r)*i.y+(3*a-2*r)*s.y,n}static Lerp(e,t,i){return Y.LerpToRef(e,t,i,new Y)}static LerpToRef(e,t,i,s){return s.x=e.x+(t.x-e.x)*i,s.y=e.y+(t.y-e.y)*i,s}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return Y.NormalizeToRef(e,new Y)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=e.x<t.x?e.x:t.x,s=e.y<t.y?e.y:t.y;return new Y(i,s)}static Maximize(e,t){const i=e.x>t.x?e.x:t.x,s=e.y>t.y?e.y:t.y;return new Y(i,s)}static Transform(e,t){return Y.TransformToRef(e,t,new Y)}static TransformToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+s[12],n=e.x*s[1]+e.y*s[5]+s[13];return i.x=r,i.y=n,i}static PointInTriangle(e,t,i,s){const r=.5*(-i.y*s.x+t.y*(-i.x+s.x)+t.x*(i.y-s.y)+i.x*s.y),n=r<0?-1:1,a=(t.y*s.x-t.x*s.y+(s.y-t.y)*e.x+(t.x-s.x)*e.y)*n,o=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*n;return a>0&&o>0&&a+o<2*r*n}static Distance(e,t){return Math.sqrt(Y.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y;return i*i+s*s}static Center(e,t){return Y.CenterToRef(e,t,new Y)}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,i){const s=Y.DistanceSquared(t,i);if(0===s)return Y.Distance(e,t);const r=i.subtract(t),n=Math.max(0,Math.min(1,Y.Dot(e.subtract(t),r)/s)),a=t.add(r.multiplyByFloats(n,n));return Y.Distance(e,a)}}Y._V8PerformanceHack=new Y(.5,.5),Y._ZeroReadOnly=Y.Zero(),Object.defineProperties(Y.prototype,{dimension:{value:[2]},rank:{value:1}});class X{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,t=0,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=K(this._x);return e=397*e^K(this._y),e=397*e^K(this._z),e}asArray(){return[this._x,this._y,this._z]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this}fromArray(e,t=0){return X.FromArrayToRef(e,t,this),this}toQuaternion(){return q.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this}addInPlaceFromFloats(e,t,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this}add(e){return new X(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._isDirty=!0,t}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new X(this._x-e._x,this._y-e._y,this._z-e._z)}subtractToRef(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)}subtractFromFloats(e,t,i){return new X(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,s){return s._x=this._x-e,s._y=this._y-t,s._z=this._z-i,s._isDirty=!0,s}negate(){return new X(-this._x,-this._y,-this._z)}negateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}negateToRef(e){return e._x=-1*this._x,e._y=-1*this._y,e._z=-1*this._z,e._isDirty=!0,e}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new X(this._x*e,this._y*e,this._z*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._isDirty=!0,t}getNormalToRef(e){const t=this.length();let i=Math.acos(this.y/t);const s=Math.atan2(this.z,this.x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;const r=t*Math.sin(i)*Math.cos(s),n=t*Math.cos(i),a=t*Math.sin(i)*Math.sin(s);return e.set(r,n,a),e}applyRotationQuaternionToRef(e,t){const i=this._x,s=this._y,r=this._z,n=e._x,a=e._y,o=e._z,h=e._w,l=2*(a*r-o*s),c=2*(o*i-n*r),u=2*(n*s-a*i);return t._x=i+h*l+a*u-o*c,t._y=s+h*c+o*l-n*u,t._z=r+h*u+n*c-a*l,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new X)}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._isDirty=!0,t}projectOnPlane(e,t){return this.projectOnPlaneToRef(e,t,new X)}projectOnPlaneToRef(e,t,i){const s=e.normal,r=e.d,n=Z.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=X.Dot(n,s);if(Math.abs(a)<1e-10)i.setAll(1/0);else{const e=-(X.Dot(t,s)+r)/a,o=n.scaleInPlace(e);t.addToRef(o,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=.001){return e&&D(this._x,e._x,t)&&D(this._y,e._y,t)&&D(this._z,e._z,t)}equalsToFloats(e,t,i){return this._x===e&&this._y===t&&this._z===i}multiplyInPlace(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this}multiply(e){return this.multiplyByFloats(e._x,e._y,e._z)}multiplyToRef(e,t){return t._x=this._x*e._x,t._y=this._y*e._y,t._z=this._z*e._z,t._isDirty=!0,t}multiplyByFloats(e,t,i){return new X(this._x*e,this._y*t,this._z*i)}divide(e){return new X(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,t){return t._x=this._x/e._x,t._y=this._y/e._y,t._z=this._z/e._z,t._isDirty=!0,t}divideInPlace(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)}minimizeInPlaceFromFloats(e,t,i){return e<this._x&&(this.x=e),t<this._y&&(this.y=t),i<this._z&&(this.z=i),this}maximizeInPlaceFromFloats(e,t,i){return e>this._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){const t=Math.abs(this._x),i=Math.abs(this._y);if(!D(t,i,e))return!0;const s=Math.abs(this._z);return!D(t,s,e)||!D(i,s,e)}get isNonUniform(){const e=Math.abs(this._x);if(e!==Math.abs(this._y))return!0;return e!==Math.abs(this._z)}floorToRef(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e}floor(){return new X(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))}fractToRef(e){return e._x=this.x-Math.floor(this._x),e._y=this.y-Math.floor(this._y),e._z=this.z-Math.floor(this._z),e._isDirty=!0,e}fract(){return new X(this.x-Math.floor(this._x),this.y-Math.floor(this._y),this.z-Math.floor(this._z))}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z}get hasAZeroComponent(){return this._x*this._y*this._z==0}normalize(){return this.normalizeFromLength(this.length())}reorderInPlace(e){if("xyz"===(e=e.toLowerCase()))return this;const t=Z.Vector3[0].copyFrom(this);return this.x=t[e[0]],this.y=t[e[1]],this.z=t[e[2]],this}rotateByQuaternionToRef(e,t){return e.toRotationMatrix(Z.Matrix[0]),X.TransformCoordinatesToRef(this,Z.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,Z.Vector3[0]),Z.Vector3[0].rotateByQuaternionToRef(e,Z.Vector3[0]),t.addToRef(Z.Vector3[0],i),i}cross(e){return X.CrossToRef(this,e,new X)}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new X)}normalizeToRef(e){const t=this.length();return 0===t||1===t?(e._x=this._x,e._y=this._y,e._z=this._z,e._isDirty=!0,e):this.scaleToRef(1/t,e)}clone(){return new X(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,t,i){return this._x=e,this._y=t,this._z=i,this._isDirty=!0,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,t,i,s){const r=X.Dot(e,i);return(r-s)/(r-X.Dot(t,i))}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef(Z.Vector3[1]),r=t.normalizeToRef(Z.Vector3[2]);let n=X.Dot(s,r);n=N(n,-1,1);const a=Math.acos(n),o=Z.Vector3[3];return X.CrossToRef(s,r,o),X.Dot(o,i)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,i){Z.Vector3[0].copyFrom(e);const s=Z.Vector3[0];Z.Vector3[1].copyFrom(t);const r=Z.Vector3[1];Z.Vector3[2].copyFrom(i);const n=Z.Vector3[2],a=Z.Vector3[3],o=Z.Vector3[4];s.normalize(),r.normalize(),n.normalize(),X.CrossToRef(n,s,a),X.CrossToRef(a,n,o);return B(Math.atan2(X.Dot(r,a),X.Dot(r,o)))}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=J.Vector3[0];return t.subtractToRef(e,s),i._y=Math.atan2(s.x,s.z)||0,i._x=Math.atan2(Math.sqrt(s.x**2+s.z**2),s.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,t){const i=X.Zero();return X.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=N(i,0,1);const r=Z.Vector3[0],n=Z.Vector3[1];r.copyFrom(e);const a=r.length();r.normalizeFromLength(a),n.copyFrom(t);const o=n.length();n.normalizeFromLength(o);const h=X.Dot(r,n);let l,c;if(h<.999){const e=Math.acos(h),t=1/Math.sin(e);l=Math.sin((1-i)*e)*t,c=Math.sin(i*e)*t}else l=1-i,c=i;return r.scaleInPlace(l),n.scaleInPlace(c),s.copyFrom(r).addInPlace(n),s.scaleInPlace(F(a,o,i)),s}static SmoothToRef(e,t,i,s,r){return X.SlerpToRef(e,t,0===s?1:i/s,r),r}static FromArray(e,t=0){return new X(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return X.FromArray(e,t)}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._isDirty=!0,i}static FromFloatArrayToRef(e,t,i){return X.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new X(0,0,0)}static One(){return new X(1,1,1)}static Up(){return new X(0,1,0)}static get UpReadOnly(){return X._UpReadOnly}static get DownReadOnly(){return X._DownReadOnly}static get RightReadOnly(){return X._RightReadOnly}static get LeftReadOnly(){return X._LeftReadOnly}static get LeftHandedForwardReadOnly(){return X._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return X._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return X._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return X._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return X._ZeroReadOnly}static get OneReadOnly(){return X._OneReadOnly}static Down(){return new X(0,-1,0)}static Forward(e=!1){return new X(0,0,e?-1:1)}static Backward(e=!1){return new X(0,0,e?1:-1)}static Right(){return new X(1,0,0)}static Left(){return new X(-1,0,0)}static Random(e=0,t=1){return new X(L(e,t),L(e,t),L(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(L(e,t),L(e,t),L(e,t))}static TransformCoordinates(e,t){const i=X.Zero();return X.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return X.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const n=s.m,a=e*n[0]+t*n[4]+i*n[8]+n[12],o=e*n[1]+t*n[5]+i*n[9]+n[13],h=e*n[2]+t*n[6]+i*n[10]+n[14],l=1/(e*n[3]+t*n[7]+i*n[11]+n[15]);return r._x=a*l,r._y=o*l,r._z=h*l,r._isDirty=!0,r}static TransformNormal(e,t){const i=X.Zero();return X.TransformNormalToRef(e,t,i),i}static TransformNormalToRef(e,t,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformNormalFromFloatsToRef(e,t,i,s,r){const n=s.m;return r._x=e*n[0]+t*n[4]+i*n[8],r._y=e*n[1]+t*n[5]+i*n[9],r._z=e*n[2]+t*n[6]+i*n[10],r._isDirty=!0,r}static CatmullRom(e,t,i,s,r){const n=r*r,a=r*n,o=.5*(2*t._x+(-e._x+i._x)*r+(2*e._x-5*t._x+4*i._x-s._x)*n+(-e._x+3*t._x-3*i._x+s._x)*a),h=.5*(2*t._y+(-e._y+i._y)*r+(2*e._y-5*t._y+4*i._y-s._y)*n+(-e._y+3*t._y-3*i._y+s._y)*a),l=.5*(2*t._z+(-e._z+i._z)*r+(2*e._z-5*t._z+4*i._z-s._z)*n+(-e._z+3*t._z-3*i._z+s._z)*a);return new X(o,h,l)}static Clamp(e,t,i){const s=new X;return X.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){let r=e._x;r=r>i._x?i._x:r,r=r<t._x?t._x:r;let n=e._y;n=n>i._y?i._y:n,n=n<t._y?t._y:n;let a=e._z;return a=a>i._z?i._z:a,a=a<t._z?t._z:a,s.copyFromFloats(r,n,a),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,t,i,s,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e._x*o+i._x*h+t._x*l+s._x*c,d=e._y*o+i._y*h+t._y*l+s._y*c,_=e._z*o+i._z*h+t._z*l+s._z*c;return new X(u,d,_)}static Hermite1stDerivative(e,t,i,s,r){const n=new X;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;return n._x=6*(a-r)*e._x+(3*a-4*r+1)*t._x+6*(-a+r)*i._x+(3*a-2*r)*s._x,n._y=6*(a-r)*e._y+(3*a-4*r+1)*t._y+6*(-a+r)*i._y+(3*a-2*r)*s._y,n._z=6*(a-r)*e._z+(3*a-4*r+1)*t._z+6*(-a+r)*i._z+(3*a-2*r)*s._z,n._isDirty=!0,n}static Lerp(e,t,i){const s=new X(0,0,0);return X.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){return s._x=e._x+(t._x-e._x)*i,s._y=e._y+(t._y-e._y)*i,s._z=e._z+(t._z-e._z)*i,s._isDirty=!0,s}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z}static Cross(e,t){const i=new X;return X.CrossToRef(e,t,i),i}static CrossToRef(e,t,i){const s=e._y*t._z-e._z*t._y,r=e._z*t._x-e._x*t._z,n=e._x*t._y-e._y*t._x;return i.copyFromFloats(s,r,n),i}static Normalize(e){const t=X.Zero();return X.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const r=new X;return X.ProjectToRef(e,t,i,s,r),r}static ProjectToRef(e,t,i,s,r){const n=s.width,a=s.height,o=s.x,h=s.y,l=Z.Matrix[1],c=O.LastCreatedEngine?.isNDCHalfZRange,u=c?1:.5,d=c?0:.5;j.FromValuesToRef(n/2,0,0,0,0,-a/2,0,0,0,0,u,0,o+n/2,a/2+h,d,1,l);const _=Z.Matrix[0];return t.multiplyToRef(i,_),_.multiplyToRef(l,_),X.TransformCoordinatesToRef(e,_,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new X)}static ReflectToRef(e,t,i){const s=J.Vector3[0];return s.copyFrom(t).scaleInPlace(2*X.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static _UnprojectFromInvertedMatrixToRef(e,t,i){X.TransformCoordinatesToRef(e,t,i);const s=t.m,r=e._x*s[3]+e._y*s[7]+e._z*s[11]+s[15];return D(r,1)&&i.scaleInPlace(1/r),i}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,j.IdentityReadOnly)}static Unproject(e,t,i,s,r,n){const a=new X;return X.UnprojectToRef(e,t,i,s,r,n,a),a}static UnprojectToRef(e,t,i,s,r,n,a){return X.UnprojectFloatsToRef(e._x,e._y,e._z,t,i,s,r,n,a),a}static UnprojectFloatsToRef(e,t,i,s,r,n,a,o,h){const l=Z.Matrix[0];n.multiplyToRef(a,l),l.multiplyToRef(o,l),l.invert();const c=Z.Vector3[0];return c.x=e/s*2-1,c.y=-(t/r*2-1),O.LastCreatedEngine?.isNDCHalfZRange?c.z=i:c.z=2*i-1,X._UnprojectFromInvertedMatrixToRef(c,l,h),h}static Minimize(e,t){const i=new X;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new X;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(X.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e._x-t._x,s=e._y-t._y,r=e._z-t._z;return i*i+s*s+r*r}static ProjectOnTriangleToRef(e,t,i,s,r){const n=Z.Vector3[0],a=Z.Vector3[1],o=Z.Vector3[2],h=Z.Vector3[3],l=Z.Vector3[4];i.subtractToRef(t,n),s.subtractToRef(t,a),s.subtractToRef(i,o);const c=n.length(),u=a.length(),d=o.length();if(c<R||u<R||d<R)return r.copyFrom(t),X.Distance(e,t);e.subtractToRef(t,l),X.CrossToRef(n,a,h);const _=h.length();if(_<R)return r.copyFrom(t),X.Distance(e,t);h.normalizeFromLength(_);let f=l.length();if(f<R)return r.copyFrom(t),0;l.normalizeFromLength(f);const p=X.Dot(h,l),g=Z.Vector3[5],m=Z.Vector3[6];g.copyFrom(h).scaleInPlace(-f*p),m.copyFrom(e).addInPlace(g);const T=Z.Vector3[4],A=Z.Vector3[5],E=Z.Vector3[7],b=Z.Vector3[8];T.copyFrom(n).scaleInPlace(1/c),b.copyFrom(a).scaleInPlace(1/u),T.addInPlace(b).scaleInPlace(-1),A.copyFrom(n).scaleInPlace(-1/c),b.copyFrom(o).scaleInPlace(1/d),A.addInPlace(b).scaleInPlace(-1),E.copyFrom(o).scaleInPlace(-1/d),b.copyFrom(a).scaleInPlace(-1/u),E.addInPlace(b).scaleInPlace(-1);const y=Z.Vector3[9];let I;y.copyFrom(m).subtractInPlace(t),X.CrossToRef(T,y,b),I=X.Dot(b,h);const M=I;y.copyFrom(m).subtractInPlace(i),X.CrossToRef(A,y,b),I=X.Dot(b,h);const v=I;y.copyFrom(m).subtractInPlace(s),X.CrossToRef(E,y,b),I=X.Dot(b,h);const x=I,S=Z.Vector3[10];let C,P;M>0&&v<0?(S.copyFrom(n),C=t,P=i):v>0&&x<0?(S.copyFrom(o),C=i,P=s):(S.copyFrom(a).scaleInPlace(-1),C=s,P=t);const O=Z.Vector3[9],D=Z.Vector3[4];C.subtractToRef(m,b),P.subtractToRef(m,O),X.CrossToRef(b,O,D);if(!(X.Dot(D,h)<0))return r.copyFrom(m),Math.abs(f*p);const L=Z.Vector3[5];X.CrossToRef(S,D,L),L.normalize();const F=Z.Vector3[9];F.copyFrom(C).subtractInPlace(m);const w=F.length();if(w<R)return r.copyFrom(C),X.Distance(e,C);F.normalizeFromLength(w);const B=X.Dot(L,F),U=Z.Vector3[7];U.copyFrom(m).addInPlace(L.scaleInPlace(w*B)),b.copyFrom(U).subtractInPlace(C),f=S.length(),S.normalizeFromLength(f);let k=X.Dot(b,S)/Math.max(f,R);return k=N(k,0,1),U.copyFrom(C).addInPlace(S.scaleInPlace(k*f)),r.copyFrom(U),X.Distance(e,U)}static Center(e,t){return X.CenterToRef(e,t,X.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e._x+t._x)/2,(e._y+t._y)/2,(e._z+t._z)/2)}static RotationFromAxis(e,t,i){const s=new X;return X.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const r=Z.Quaternion[0];return q.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(s),s}}X._V8PerformanceHack=new X(.5,.5,.5),X._UpReadOnly=X.Up(),X._DownReadOnly=X.Down(),X._LeftHandedForwardReadOnly=X.Forward(!1),X._RightHandedForwardReadOnly=X.Forward(!0),X._LeftHandedBackwardReadOnly=X.Backward(!1),X._RightHandedBackwardReadOnly=X.Backward(!0),X._RightReadOnly=X.Right(),X._LeftReadOnly=X.Left(),X._ZeroReadOnly=X.Zero(),X._OneReadOnly=X.One(),Object.defineProperties(X.prototype,{dimension:{value:[3]},rank:{value:1}});class Q{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}toString(){return`{X: ${this.x} Y: ${this.y} Z: ${this.z} W: ${this.w}}`}getClassName(){return"Vector4"}getHashCode(){let e=K(this.x);return e=397*e^K(this.y),e=397*e^K(this.z),e=397*e^K(this.w),e}asArray(){return[this.x,this.y,this.z,this.w]}toArray(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this}fromArray(e,t=0){return Q.FromArrayToRef(e,t,this),this}addInPlace(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addInPlaceFromFloats(e,t,i,s){return this.x+=e,this.y+=t,this.z+=i,this.w+=s,this}add(e){return new Q(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)}addToRef(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subtract(e){return new Q(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)}subtractToRef(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,t}subtractFromFloats(e,t,i,s){return new Q(this.x-e,this.y-t,this.z-i,this.w-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,r.w=this.w-s,r}negate(){return new Q(-this.x,-this.y,-this.z,-this.w)}negateInPlace(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e.z=-this.z,e.w=-this.w,e}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new Q(this.x*e,this.y*e,this.z*e,this.w*e)}scaleToRef(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,t}scaleAndAddToRef(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,t.w+=this.w*e,t}equals(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsWithEpsilon(e,t=.001){return e&&D(this.x,e.x,t)&&D(this.y,e.y,t)&&D(this.z,e.z,t)&&D(this.w,e.w,t)}equalsToFloats(e,t,i,s){return this.x===e&&this.y===t&&this.z===i&&this.w===s}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new Q(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)}multiplyToRef(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,t}multiplyByFloats(e,t,i,s){return new Q(this.x*e,this.y*t,this.z*i,this.w*s)}divide(e){return new Q(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)}divideToRef(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,t}divideInPlace(e){return this.divideToRef(e,this)}minimizeInPlace(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this}maximizeInPlace(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this}minimizeInPlaceFromFloats(e,t,i,s){return this.x=Math.min(e,this.x),this.y=Math.min(t,this.y),this.z=Math.min(i,this.z),this.w=Math.min(s,this.w),this}maximizeInPlaceFromFloats(e,t,i,s){return this.x=Math.max(e,this.x),this.y=Math.max(t,this.y),this.z=Math.max(i,this.z),this.w=Math.max(s,this.w),this}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e.z=Math.floor(this.z),e.w=Math.floor(this.w),e}floor(){return new Q(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e.z=this.z-Math.floor(this.z),e.w=this.w-Math.floor(this.w),e}fract(){return new Q(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new Q)}normalizeToRef(e){const t=this.length();return 0===t||1===t?(e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w,e):this.scaleToRef(1/t,e)}toVector3(){return new X(this.x,this.y,this.z)}clone(){return new Q(this.x,this.y,this.z,this.w)}copyFrom(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}copyFromFloats(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.x=this.y=this.z=this.w=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}static FromArray(e,t){return t||(t=0),new Q(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3],i}static FromFloatArrayToRef(e,t,i){return Q.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,s,r){return r.x=e,r.y=t,r.z=i,r.w=s,r}static Zero(){return new Q(0,0,0,0)}static One(){return new Q(1,1,1,1)}static Random(e=0,t=1){return new Q(L(e,t),L(e,t),L(e,t),L(e,t))}static RandomToRef(e=0,t=1,i){return i.x=L(e,t),i.y=L(e,t),i.z=L(e,t),i.w=L(e,t),i}static Clamp(e,t,i){return Q.ClampToRef(e,t,i,new Q)}static ClampToRef(e,t,i,s){return s.x=N(e.x,t.x,i.x),s.y=N(e.y,t.y,i.y),s.z=N(e.z,t.z,i.z),s.w=N(e.w,t.w,i.w),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return Q._ZeroReadOnly}static Normalize(e){return Q.NormalizeToRef(e,new Q)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=new Q;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new Q;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(Q.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return i*i+s*s+r*r+n*n}static Center(e,t){return Q.CenterToRef(e,t,new Q)}static CenterToRef(e,t,i){return i.x=(e.x+t.x)/2,i.y=(e.y+t.y)/2,i.z=(e.z+t.z)/2,i.w=(e.w+t.w)/2,i}static TransformCoordinates(e,t){return Q.TransformCoordinatesToRef(e,t,new Q)}static TransformCoordinatesToRef(e,t,i){return Q.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const n=s.m,a=e*n[0]+t*n[4]+i*n[8]+n[12],o=e*n[1]+t*n[5]+i*n[9]+n[13],h=e*n[2]+t*n[6]+i*n[10]+n[14],l=e*n[3]+t*n[7]+i*n[11]+n[15];return r.x=a,r.y=o,r.z=h,r.w=l,r}static TransformNormal(e,t){return Q.TransformNormalToRef(e,t,new Q)}static TransformNormalToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+e.z*s[8],n=e.x*s[1]+e.y*s[5]+e.z*s[9],a=e.x*s[2]+e.y*s[6]+e.z*s[10];return i.x=r,i.y=n,i.z=a,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,s,r,n){const a=r.m;return n.x=e*a[0]+t*a[4]+i*a[8],n.y=e*a[1]+t*a[5]+i*a[9],n.z=e*a[2]+t*a[6]+i*a[10],n.w=s,n}static FromVector3(e,t=0){return new Q(e._x,e._y,e._z,t)}static Dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}}Q._V8PerformanceHack=new Q(.5,.5,.5,.5),Q._ZeroReadOnly=Q.Zero(),Object.defineProperties(Q.prototype,{dimension:{value:[4]},rank:{value:1}});class q{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,t=0,i=0,s=1){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){let e=K(this._x);return e=397*e^K(this._y),e=397*e^K(this._z),e=397*e^K(this._w),e}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return q.FromArrayToRef(e,t,this)}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,t=.001){return e&&D(this._x,e._x,t)&&D(this._y,e._y,t)&&D(this._z,e._z,t)&&D(this._w,e._w,t)}clone(){return new q(this._x,this._y,this._z,this._w)}copyFrom(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this}copyFromFloats(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._isDirty=!0,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new q(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._w)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._w=this._w+e._w,t._isDirty=!0,t}addInPlaceFromFloats(e,t,i,s){return this._x+=e,this._y+=t,this._z+=i,this._w+=s,this._isDirty=!0,this}subtractToRef(e,t){return t._x=this._x-e._x,t._y=this._y-e._y,t._z=this._z-e._z,t._w=this._w-e._w,t._isDirty=!0,t}subtractFromFloats(e,t,i,s){return this.subtractFromFloatsToRef(e,t,i,s,new q)}subtractFromFloatsToRef(e,t,i,s,r){return r._x=this._x-e,r._y=this._y-t,r._z=this._z-i,r._w=this._w-s,r._isDirty=!0,r}subtract(e){return new q(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._w)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this}scale(e){return new q(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._w=this._w*e,t._isDirty=!0,t}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._w+=this._w*e,t._isDirty=!0,t}multiply(e){const t=new q(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){const i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,s=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,n=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,s,r,n),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,i,s){return this._x*=e,this._y*=t,this._z*=i,this._w*=s,this._isDirty=!0,this}divide(e){throw new ReferenceError("Can not divide a quaternion")}divideToRef(e,t){throw new ReferenceError("Can not divide a quaternion")}divideInPlace(e){throw new ReferenceError("Can not divide a quaternion")}minimizeInPlace(){throw new ReferenceError("Can not minimize a quaternion")}minimizeInPlaceFromFloats(){throw new ReferenceError("Can not minimize a quaternion")}maximizeInPlace(){throw new ReferenceError("Can not maximize a quaternion")}maximizeInPlaceFromFloats(){throw new ReferenceError("Can not maximize a quaternion")}negate(){return this.negateToRef(new q)}negateInPlace(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this}negateToRef(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}floorToRef(e){throw new ReferenceError("Can not floor a quaternion")}floor(){throw new ReferenceError("Can not floor a quaternion")}fractToRef(e){throw new ReferenceError("Can not fract a quaternion")}fract(){throw new ReferenceError("Can not fract a quaternion")}conjugateToRef(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e}conjugateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}conjugate(){return new q(-this._x,-this._y,-this._z,this._w)}invert(){const e=this.conjugate(),t=this.lengthSquared();return 0==t||1==t||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();const e=this.lengthSquared();return 0==e||1==e||this.scaleInPlace(1/e),this}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this.lengthSquared())}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new q(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return 0===t||1===t?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)}toEulerAngles(){const e=X.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,n=s*t-i*r,a=.4999999;if(n<-a)e._y=2*Math.atan2(s,r),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(n>a)e._y=2*Math.atan2(s,r),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const a=r*r,o=t*t,h=i*i,l=s*s;e._z=Math.atan2(2*(i*s+t*r),-o-h+l+a),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*i+s*r),o-h-l+a),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,n=Math.sqrt(i*i+s*s),a=Math.sqrt(t*t+r*r),o=2*Math.atan2(n,a),h=2*Math.atan2(t,r),l=2*Math.atan2(s,i),c=(h+l)/2,u=(h-l)/2;return e.set(u,o,c),e}toRotationMatrix(e){return j.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return q.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}static FromRotationMatrix(e){const t=new q;return q.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const i=e.m,s=i[0],r=i[4],n=i[8],a=i[1],o=i[5],h=i[9],l=i[2],c=i[6],u=i[10],d=s+o+u;let _;return d>0?(_=.5/Math.sqrt(d+1),t._w=.25/_,t._x=(c-h)*_,t._y=(n-l)*_,t._z=(a-r)*_,t._isDirty=!0):s>o&&s>u?(_=2*Math.sqrt(1+s-o-u),t._w=(c-h)/_,t._x=.25*_,t._y=(r+a)/_,t._z=(n+l)/_,t._isDirty=!0):o>u?(_=2*Math.sqrt(1+o-s-u),t._w=(n-l)/_,t._x=(r+a)/_,t._y=.25*_,t._z=(h+c)/_,t._isDirty=!0):(_=2*Math.sqrt(1+u-s-o),t._w=(a-r)/_,t._x=(n+l)/_,t._y=(h+c)/_,t._z=.25*_,t._isDirty=!0),t}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w}static AreClose(e,t,i=.1){const s=q.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let n=0===s?1:i/s;return n=N(n,0,1),q.SlerpToRef(e,t,n,r),r}static Zero(){return new q(0,0,0,0)}static Inverse(e){return new q(-e._x,-e._y,-e._z,e._w)}static InverseToRef(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t}static Identity(){return new q(0,0,0,1)}static IsIdentity(e){return e&&0===e._x&&0===e._y&&0===e._z&&1===e._w}static RotationAxis(e,t){return q.RotationAxisToRef(e,t,new q)}static RotationAxisToRef(e,t,i){i._w=Math.cos(t/2);const s=Math.sin(t/2)/e.length();return i._x=e._x*s,i._y=e._y*s,i._z=e._z*s,i._isDirty=!0,i}static FromArray(e,t){return t||(t=0),new q(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._w=e[t+3],i._isDirty=!0,i}static FromFloatsToRef(e,t,i,s,r){return r.copyFromFloats(e,t,i,s),r}static FromEulerAngles(e,t,i){const s=new q;return q.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return q.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new q;return q.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return q.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=.001){const r=X.Dot(e,t)+1;return r<s?Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(X.CrossToRef(e,t,J.Vector3[0]),i.set(J.Vector3[0].x,J.Vector3[0].y,J.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new q;return q.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const r=.5*i,n=.5*t,a=.5*e,o=Math.sin(r),h=Math.cos(r),l=Math.sin(n),c=Math.cos(n),u=Math.sin(a),d=Math.cos(a);return s._x=d*l*h+u*c*o,s._y=u*c*h-d*l*o,s._z=d*c*o-u*l*h,s._w=d*c*h+u*l*o,s._isDirty=!0,s}static RotationAlphaBetaGamma(e,t,i){const s=new q;return q.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const r=.5*(i+e),n=.5*(i-e),a=.5*t;return s._x=Math.cos(n)*Math.sin(a),s._y=Math.sin(n)*Math.sin(a),s._z=Math.sin(r)*Math.cos(a),s._w=Math.cos(r)*Math.cos(a),s._isDirty=!0,s}static RotationQuaternionFromAxis(e,t,i){const s=new q(0,0,0,0);return q.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=Z.Matrix[0];return e=e.normalizeToRef(Z.Vector3[0]),t=t.normalizeToRef(Z.Vector3[1]),i=i.normalizeToRef(Z.Vector3[2]),j.FromXYZAxesToRef(e,t,i,r),q.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new q;return q.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=Z.Matrix[0];return j.LookDirectionLHToRef(e,t,s),q.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new q;return q.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=Z.Matrix[0];return j.LookDirectionRHToRef(e,t,s),q.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=q.Identity();return q.SlerpToRef(e,t,i,s),s}static SlerpToRef(e,t,i,s){let r,n,a=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,o=!1;if(a<0&&(o=!0,a=-a),a>.999999)n=1-i,r=o?-i:i;else{const e=Math.acos(a),t=1/Math.sin(e);n=Math.sin((1-i)*e)*t,r=o?-Math.sin(i*e)*t:Math.sin(i*e)*t}return s._x=n*e._x+r*t._x,s._y=n*e._y+r*t._y,s._z=n*e._z+r*t._z,s._w=n*e._w+r*t._w,s._isDirty=!0,s}static Hermite(e,t,i,s,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e._x*o+i._x*h+t._x*l+s._x*c,d=e._y*o+i._y*h+t._y*l+s._y*c,_=e._z*o+i._z*h+t._z*l+s._z*c,f=e._w*o+i._w*h+t._w*l+s._w*c;return new q(u,d,_,f)}static Hermite1stDerivative(e,t,i,s,r){const n=new q;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;return n._x=6*(a-r)*e._x+(3*a-4*r+1)*t._x+6*(-a+r)*i._x+(3*a-2*r)*s._x,n._y=6*(a-r)*e._y+(3*a-4*r+1)*t._y+6*(-a+r)*i._y+(3*a-2*r)*s._y,n._z=6*(a-r)*e._z+(3*a-4*r+1)*t._z+6*(-a+r)*i._z+(3*a-2*r)*s._z,n._w=6*(a-r)*e._w+(3*a-4*r+1)*t._w+6*(-a+r)*i._w+(3*a-2*r)*s._w,n._isDirty=!0,n}static Normalize(e){const t=q.Zero();return q.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){const s=new q;return q.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){return s.copyFromFloats(N(e.x,t.x,i.x),N(e.y,t.y,i.y),N(e.z,t.z,i.z),N(e.w,t.w,i.w))}static Random(e=0,t=1){return new q(L(e,t),L(e,t),L(e,t),L(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(L(e,t),L(e,t),L(e,t),L(e,t))}static Minimize(){throw new ReferenceError("Quaternion.Minimize does not make sense")}static Maximize(){throw new ReferenceError("Quaternion.Maximize does not make sense")}static Distance(e,t){return Math.sqrt(q.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return i*i+s*s+r*r+n*n}static Center(e,t){return q.CenterToRef(e,t,q.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)}}q._V8PerformanceHack=new q(.5,.5,.5,.5),Object.defineProperties(q.prototype,{dimension:{value:[4]},rank:{value:1}});class j{static get Use64Bits(){return P.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=j._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,i=!1,s=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=!this._isIdentity&&t,this._isIdentity3x2Dirty=!this._isIdentity3x2&&s}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,P.MatrixTrackPrecisionChange&&P.MatrixTrackedMatrices.push(this),this._m=new P.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;const e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(!0===this._isIdentity)return 1;const e=this._m,t=e[0],i=e[1],s=e[2],r=e[3],n=e[4],a=e[5],o=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],f=e[13],p=e[14],g=e[15],m=u*g-p*d,T=c*g-f*d,A=c*p-f*u,E=l*g-_*d,b=l*p-u*_,R=l*f-_*c;return t*+(a*m-o*T+h*A)+i*-(n*m-o*E+h*b)+s*+(n*T-a*E+h*R)+r*-(n*A-a*b+o*R)}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}\n${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]}\n${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]}\n${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;const i=this._m;for(let s=0;s<16;s++)e[t+s]=i[s];return this}asArray(){return this._m}fromArray(e,t=0){return j.FromArrayToRef(e,t,this)}copyFromFloats(...e){return j.FromArrayToRef(e,0,this)}set(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=e[i];return this.markAsUpdated(),this}setAll(e){const t=this._m;for(let i=0;i<16;i++)t[i]=e;return this.markAsUpdated(),this}invert(){return this.invertToRef(this),this}reset(){return j.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){const t=new j;return this.addToRef(e,t),t}addToRef(e,t){const i=this._m,s=t._m,r=e.m;for(let e=0;e<16;e++)s[e]=i[e]+r[e];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,i=e.m;return t[0]+=i[0],t[1]+=i[1],t[2]+=i[2],t[3]+=i[3],t[4]+=i[4],t[5]+=i[5],t[6]+=i[6],t[7]+=i[7],t[8]+=i[8],t[9]+=i[9],t[10]+=i[10],t[11]+=i[11],t[12]+=i[12],t[13]+=i[13],t[14]+=i[14],t[15]+=i[15],this.markAsUpdated(),this}addInPlace(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]+=i[e];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]+=e[i];return this.markAsUpdated(),this}subtract(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]-=i[e];return this.markAsUpdated(),this}subtractToRef(e,t){const i=this._m,s=e.m,r=t._m;for(let e=0;e<16;e++)r[e]=i[e]-s[e];return t.markAsUpdated(),t}subtractInPlace(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]-=i[e];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new j)}subtractFromFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,r=e;for(let e=0;e<16;e++)s[e]=i[e]-r[e];return t.markAsUpdated(),t}invertToRef(e){if(!0===this._isIdentity)return j.IdentityToRef(e),e;const t=this._m,i=t[0],s=t[1],r=t[2],n=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],f=t[12],p=t[13],g=t[14],m=t[15],T=d*m-g*_,A=u*m-p*_,E=u*g-p*d,b=c*m-f*_,R=c*g-d*f,y=c*p-f*u,I=+(o*T-h*A+l*E),M=-(a*T-h*b+l*R),v=+(a*A-o*b+l*y),x=-(a*E-o*R+h*y),S=i*I+s*M+r*v+n*x;if(0===S)return e.copyFrom(this),e;const C=1/S,P=h*m-g*l,O=o*m-p*l,D=o*g-p*h,L=a*m-f*l,F=a*g-f*h,w=a*p-f*o,N=h*_-d*l,B=o*_-u*l,U=o*d-u*h,k=a*_-c*l,V=a*d-c*h,z=a*u-c*o,G=-(s*T-r*A+n*E),H=+(i*T-r*b+n*R),W=-(i*A-s*b+n*y),K=+(i*E-s*R+r*y),Y=+(s*P-r*O+n*D),X=-(i*P-r*L+n*F),Q=+(i*O-s*L+n*w),q=-(i*D-s*F+r*w),Z=-(s*N-r*B+n*U),J=+(i*N-r*k+n*V),$=-(i*B-s*k+n*z),ee=+(i*U-s*V+r*z);return j.FromValuesToRef(I*C,G*C,Y*C,Z*C,M*C,H*C,X*C,J*C,v*C,W*C,Q*C,$*C,x*C,K*C,q*C,ee*C,e),e}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this.markAsUpdated(),this}addTranslationFromFloats(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new X(this._m[12],this._m[13],this._m[14])}getTranslationToRef(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e}removeRotationAndScaling(){const e=this.m;return j.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]),this}copyFrom(e){e.copyToArray(this._m);const t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){const i=this._m;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],this}multiply(e){const t=new j;return this.multiplyToRef(e,t),t}multiplyInPlace(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]*=i[e];return this.markAsUpdated(),this}multiplyByFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]*=e[i];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,r=e;for(let e=0;e<16;e++)s[e]=i[e]*r[e];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,i){const s=this._m,r=e.m,n=s[0],a=s[1],o=s[2],h=s[3],l=s[4],c=s[5],u=s[6],d=s[7],_=s[8],f=s[9],p=s[10],g=s[11],m=s[12],T=s[13],A=s[14],E=s[15],b=r[0],R=r[1],y=r[2],I=r[3],M=r[4],v=r[5],x=r[6],S=r[7],C=r[8],P=r[9],O=r[10],D=r[11],L=r[12],F=r[13],w=r[14],N=r[15];return t[i]=n*b+a*M+o*C+h*L,t[i+1]=n*R+a*v+o*P+h*F,t[i+2]=n*y+a*x+o*O+h*w,t[i+3]=n*I+a*S+o*D+h*N,t[i+4]=l*b+c*M+u*C+d*L,t[i+5]=l*R+c*v+u*P+d*F,t[i+6]=l*y+c*x+u*O+d*w,t[i+7]=l*I+c*S+u*D+d*N,t[i+8]=_*b+f*M+p*C+g*L,t[i+9]=_*R+f*v+p*P+g*F,t[i+10]=_*y+f*x+p*O+g*w,t[i+11]=_*I+f*S+p*D+g*N,t[i+12]=m*b+T*M+A*C+E*L,t[i+13]=m*R+T*v+A*P+E*F,t[i+14]=m*y+T*x+A*O+E*w,t[i+15]=m*I+T*S+A*D+E*N,this}divide(e){return this.divideToRef(e,new j)}divideToRef(e,t){const i=this._m,s=e.m,r=t._m;for(let e=0;e<16;e++)r[e]=i[e]/s[e];return t.markAsUpdated(),t}divideInPlace(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]/=i[e];return this.markAsUpdated(),this}minimizeInPlace(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]=Math.min(t[e],i[e]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}maximizeInPlace(e){const t=this._m,i=e.m;for(let e=0;e<16;e++)t[e]=Math.min(t[e],i[e]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}negate(){return this.negateToRef(new j)}negateInPlace(){const e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){const t=this._m,i=e._m;for(let e=0;e<16;e++)i[e]=-t[e];return e.markAsUpdated(),e}equals(e){const t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;const i=this.m,s=t.m;return i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]&&i[3]===s[3]&&i[4]===s[4]&&i[5]===s[5]&&i[6]===s[6]&&i[7]===s[7]&&i[8]===s[8]&&i[9]===s[9]&&i[10]===s[10]&&i[11]===s[11]&&i[12]===s[12]&&i[13]===s[13]&&i[14]===s[14]&&i[15]===s[15]}equalsWithEpsilon(e,t=0){const i=this._m,s=e.m;for(let e=0;e<16;e++)if(!D(i[e],s[e],t))return!1;return!0}equalsToFloats(...e){const t=this._m;for(let i=0;i<16;i++)if(t[i]!=e[i])return!1;return!0}floor(){return this.floorToRef(new j)}floorToRef(e){const t=this._m,i=e._m;for(let e=0;e<16;e++)i[e]=Math.floor(t[e]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new j)}fractToRef(e){const t=this._m,i=e._m;for(let e=0;e<16;e++)i[e]=t[e]-Math.floor(t[e]);return e.markAsUpdated(),e}clone(){const e=new j;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=K(this._m[0]);for(let t=1;t<16;t++)e=397*e^K(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new q,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,s,r=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const n=this._m;if(i&&i.copyFromFloats(n[12],n[13],n[14]),(e=e||Z.Vector3[0]).x=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),e.y=Math.sqrt(n[4]*n[4]+n[5]*n[5]+n[6]*n[6]),e.z=Math.sqrt(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),s){const t=(r?s.absoluteScaling.x:s.scaling.x)<0?-1:1,i=(r?s.absoluteScaling.y:s.scaling.y)<0?-1:1,n=(r?s.absoluteScaling.z:s.scaling.z)<0?-1:1;e.x*=t,e.y*=i,e.z*=n}else this.determinant()<=0&&(e.y*=-1);if(0===e._x||0===e._y||0===e._z)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const i=1/e._x,s=1/e._y,r=1/e._z;j.FromValuesToRef(n[0]*i,n[1]*i,n[2]*i,0,n[4]*s,n[5]*s,n[6]*s,0,n[8]*r,n[9]*r,n[10]*r,0,0,0,0,1,Z.Matrix[0]),q.FromRotationMatrixToRef(Z.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=4*e;return new Q(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){const i=4*e;t.x=this._m[i+0],t.y=this._m[i+1],t.z=this._m[i+2],t.w=this._m[i+3]}return t}setRow(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)}transpose(){const e=new j;return j.TransposeToRef(this,e),e}transposeToRef(e){return j.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,s,r){if(e<0||e>3)return this;const n=4*e;return this._m[n+0]=t,this._m[n+1]=i,this._m[n+2]=s,this._m[n+3]=r,this.markAsUpdated(),this}scale(e){const t=new j;return this.scaleToRef(e,t),t}scaleToRef(e,t){for(let i=0;i<16;i++)t._m[i]=this._m[i]*e;return t.markAsUpdated(),t}scaleAndAddToRef(e,t){for(let i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t.markAsUpdated(),t}scaleInPlace(e){const t=this._m;for(let i=0;i<16;i++)t[i]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){const t=Z.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return j.FromValuesToRef(i[0],i[1],i[2],0,i[4],i[5],i[6],0,i[8],i[9],i[10],0,0,0,0,1,e),e}getRotationMatrix(){const e=new j;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=Z.Vector3[0];if(!this.decompose(t))return j.IdentityToRef(e),e;const i=this._m,s=1/t._x,r=1/t._y,n=1/t._z;return j.FromValuesToRef(i[0]*s,i[1]*s,i[2]*s,0,i[4]*r,i[5]*r,i[6]*r,0,i[8]*n,i[9]*n,i[10]*n,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){const e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){const e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){const i=new j;return j.FromArrayToRef(e,t,i),i}static FromArrayToRef(e,t,i){for(let s=0;s<16;s++)i._m[s]=e[s+t];return i.markAsUpdated(),i}static FromFloat32ArrayToRefScaled(e,t,i,s){return s._m[0]=e[0+t]*i,s._m[1]=e[1+t]*i,s._m[2]=e[2+t]*i,s._m[3]=e[3+t]*i,s._m[4]=e[4+t]*i,s._m[5]=e[5+t]*i,s._m[6]=e[6+t]*i,s._m[7]=e[7+t]*i,s._m[8]=e[8+t]*i,s._m[9]=e[9+t]*i,s._m[10]=e[10+t]*i,s._m[11]=e[11+t]*i,s._m[12]=e[12+t]*i,s._m[13]=e[13+t]*i,s._m[14]=e[14+t]*i,s._m[15]=e[15+t]*i,s.markAsUpdated(),s}static get IdentityReadOnly(){return j._IdentityReadOnly}static FromValuesToRef(e,t,i,s,r,n,a,o,h,l,c,u,d,_,f,p,g){const m=g._m;m[0]=e,m[1]=t,m[2]=i,m[3]=s,m[4]=r,m[5]=n,m[6]=a,m[7]=o,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=f,m[15]=p,g.markAsUpdated()}static FromValues(e,t,i,s,r,n,a,o,h,l,c,u,d,_,f,p){const g=new j,m=g._m;return m[0]=e,m[1]=t,m[2]=i,m[3]=s,m[4]=r,m[5]=n,m[6]=a,m[7]=o,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=f,m[15]=p,g.markAsUpdated(),g}static Compose(e,t,i){const s=new j;return j.ComposeToRef(e,t,i,s),s}static ComposeToRef(e,t,i,s){const r=s._m,n=t._x,a=t._y,o=t._z,h=t._w,l=n+n,c=a+a,u=o+o,d=n*l,_=n*c,f=n*u,p=a*c,g=a*u,m=o*u,T=h*l,A=h*c,E=h*u,b=e._x,R=e._y,y=e._z;return r[0]=(1-(p+m))*b,r[1]=(_+E)*b,r[2]=(f-A)*b,r[3]=0,r[4]=(_-E)*R,r[5]=(1-(d+m))*R,r[6]=(g+T)*R,r[7]=0,r[8]=(f+A)*y,r[9]=(g-T)*y,r[10]=(1-(d+p))*y,r[11]=0,r[12]=i._x,r[13]=i._y,r[14]=i._z,r[15]=1,s.markAsUpdated(),s}static Identity(){const e=j.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return e._updateIdentityStatus(!0),e}static IdentityToRef(e){return j.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){const e=j.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return e._updateIdentityStatus(!1),e}static RotationX(e){const t=new j;return j.RotationXToRef(e,t),t}static Invert(e){const t=new j;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return j.FromValuesToRef(1,0,0,0,0,s,i,0,0,-i,s,0,0,0,0,1,t),t._updateIdentityStatus(1===s&&0===i),t}static RotationY(e){const t=new j;return j.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return j.FromValuesToRef(s,0,-i,0,0,1,0,0,i,0,s,0,0,0,0,1,t),t._updateIdentityStatus(1===s&&0===i),t}static RotationZ(e){const t=new j;return j.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return j.FromValuesToRef(s,i,0,0,-i,s,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(1===s&&0===i),t}static RotationAxis(e,t){const i=new j;return j.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){const s=Math.sin(-t),r=Math.cos(-t),n=1-r;e=e.normalizeToRef(Z.Vector3[0]);const a=i._m;return a[0]=e._x*e._x*n+r,a[1]=e._x*e._y*n-e._z*s,a[2]=e._x*e._z*n+e._y*s,a[3]=0,a[4]=e._y*e._x*n+e._z*s,a[5]=e._y*e._y*n+r,a[6]=e._y*e._z*n-e._x*s,a[7]=0,a[8]=e._z*e._x*n-e._y*s,a[9]=e._z*e._y*n+e._x*s,a[10]=e._z*e._z*n+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i.markAsUpdated(),i}static RotationAlignToRef(e,t,i,s=!1){const r=X.Dot(t,e),n=i._m;if(r<-.999)n[0]=-1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s?1:-1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=s?-1:1,n[11]=0;else{const i=X.Cross(t,e),s=1/(1+r);n[0]=i._x*i._x*s+r,n[1]=i._y*i._x*s-i._z,n[2]=i._z*i._x*s+i._y,n[3]=0,n[4]=i._x*i._y*s+i._z,n[5]=i._y*i._y*s+r,n[6]=i._z*i._y*s-i._x,n[7]=0,n[8]=i._x*i._z*s-i._y,n[9]=i._y*i._z*s+i._x,n[10]=i._z*i._z*s+r,n[11]=0}return n[12]=0,n[13]=0,n[14]=0,n[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){const s=new j;return j.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return q.RotationYawPitchRollToRef(e,t,i,Z.Quaternion[0]),Z.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new j;return j.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return j.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,s),s._updateIdentityStatus(1===e&&1===t&&1===i),s}static Translation(e,t,i){const s=new j;return j.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return j.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,s),s._updateIdentityStatus(0===e&&0===t&&0===i),s}static Lerp(e,t,i){const s=new j;return j.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){const r=s._m,n=e.m,a=t.m;for(let e=0;e<16;e++)r[e]=n[e]*(1-i)+a[e]*i;return s.markAsUpdated(),s}static DecomposeLerp(e,t,i){const s=new j;return j.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const r=Z.Vector3[0],n=Z.Quaternion[0],a=Z.Vector3[1];e.decompose(r,n,a);const o=Z.Vector3[2],h=Z.Quaternion[1],l=Z.Vector3[3];t.decompose(o,h,l);const c=Z.Vector3[4];X.LerpToRef(r,o,i,c);const u=Z.Quaternion[2];q.SlerpToRef(n,h,i,u);const d=Z.Vector3[5];return X.LerpToRef(a,l,i,d),j.ComposeToRef(c,u,d,s),s}static LookAtLH(e,t,i){const s=new j;return j.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const r=Z.Vector3[0],n=Z.Vector3[1],a=Z.Vector3[2];t.subtractToRef(e,a),a.normalize(),X.CrossToRef(i,a,r);const o=r.lengthSquared();0===o?r.x=1:r.normalizeFromLength(Math.sqrt(o)),X.CrossToRef(a,r,n),n.normalize();const h=-X.Dot(r,e),l=-X.Dot(n,e),c=-X.Dot(a,e);return j.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,l,c,1,s),s}static LookAtRH(e,t,i){const s=new j;return j.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const r=Z.Vector3[0],n=Z.Vector3[1],a=Z.Vector3[2];e.subtractToRef(t,a),a.normalize(),X.CrossToRef(i,a,r);const o=r.lengthSquared();0===o?r.x=1:r.normalizeFromLength(Math.sqrt(o)),X.CrossToRef(a,r,n),n.normalize();const h=-X.Dot(r,e),l=-X.Dot(n,e),c=-X.Dot(a,e);return j.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,l,c,1,s),s}static LookDirectionLH(e,t){const i=new j;return j.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=Z.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const r=Z.Vector3[1];return X.CrossToRef(t,s,r),j.FromValuesToRef(r._x,r._y,r._z,0,t._x,t._y,t._z,0,s._x,s._y,s._z,0,0,0,0,1,i),i}static LookDirectionRH(e,t){const i=new j;return j.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=Z.Vector3[2];return X.CrossToRef(t,e,s),j.FromValuesToRef(s._x,s._y,s._z,0,t._x,t._y,t._z,0,e._x,e._y,e._z,0,0,0,0,1,i),i}static OrthoLH(e,t,i,s,r){const n=new j;return j.OrthoLHToRef(e,t,i,s,n,r),n}static OrthoLHToRef(e,t,i,s,r,n){const a=2/e,o=2/t,h=2/(s-i),l=-(s+i)/(s-i);return j.FromValuesToRef(a,0,0,0,0,o,0,0,0,0,h,0,0,0,l,1,r),n&&r.multiplyToRef($,r),r._updateIdentityStatus(1===a&&1===o&&1===h&&0===l),r}static OrthoOffCenterLH(e,t,i,s,r,n,a){const o=new j;return j.OrthoOffCenterLHToRef(e,t,i,s,r,n,o,a),o}static OrthoOffCenterLHToRef(e,t,i,s,r,n,a,o){const h=2/(t-e),l=2/(s-i),c=2/(n-r),u=-(n+r)/(n-r),d=(e+t)/(e-t),_=(s+i)/(i-s);return j.FromValuesToRef(h,0,0,0,0,l,0,0,0,0,c,0,d,_,u,1,a),o&&a.multiplyToRef($,a),a.markAsUpdated(),a}static ObliqueOffCenterLHToRef(e,t,i,s,r,n,a,o,h,l,c){const u=-a*Math.cos(o),d=-a*Math.sin(o);return j.TranslationToRef(0,0,-h,Z.Matrix[1]),j.FromValuesToRef(1,0,0,0,0,1,0,0,u,d,1,0,0,0,0,1,Z.Matrix[0]),Z.Matrix[1].multiplyToRef(Z.Matrix[0],Z.Matrix[0]),j.TranslationToRef(0,0,h,Z.Matrix[1]),Z.Matrix[0].multiplyToRef(Z.Matrix[1],Z.Matrix[0]),j.OrthoOffCenterLHToRef(e,t,i,s,r,n,l,c),Z.Matrix[0].multiplyToRef(l,l),l}static OrthoOffCenterRH(e,t,i,s,r,n,a){const o=new j;return j.OrthoOffCenterRHToRef(e,t,i,s,r,n,o,a),o}static OrthoOffCenterRHToRef(e,t,i,s,r,n,a,o){return j.OrthoOffCenterLHToRef(e,t,i,s,r,n,a,o),a._m[10]*=-1,a}static ObliqueOffCenterRHToRef(e,t,i,s,r,n,a,o,h,l,c){const u=a*Math.cos(o),d=a*Math.sin(o);return j.TranslationToRef(0,0,h,Z.Matrix[1]),j.FromValuesToRef(1,0,0,0,0,1,0,0,u,d,1,0,0,0,0,1,Z.Matrix[0]),Z.Matrix[1].multiplyToRef(Z.Matrix[0],Z.Matrix[0]),j.TranslationToRef(0,0,-h,Z.Matrix[1]),Z.Matrix[0].multiplyToRef(Z.Matrix[1],Z.Matrix[0]),j.OrthoOffCenterRHToRef(e,t,i,s,r,n,l,c),Z.Matrix[0].multiplyToRef(l,l),l}static PerspectiveLH(e,t,i,s,r,n=0){const a=new j,o=2*i/e,h=2*i/t,l=(s+i)/(s-i),c=-2*s*i/(s-i),u=Math.tan(n);return j.FromValuesToRef(o,0,0,0,0,h,0,u,0,0,l,1,0,0,c,0,a),r&&a.multiplyToRef($,a),a._updateIdentityStatus(!1),a}static PerspectiveFovLH(e,t,i,s,r,n=0,a=!1){const o=new j;return j.PerspectiveFovLHToRef(e,t,i,s,o,!0,r,n,a),o}static PerspectiveFovLHToRef(e,t,i,s,r,n=!0,a,o=0,h=!1){const l=i,c=s,u=1/Math.tan(.5*e),d=n?u/t:u,_=n?u:u*t,f=h&&0===l?-1:0!==c?(c+l)/(c-l):1,p=h&&0===l?2*c:0!==c?-2*c*l/(c-l):-2*l,g=Math.tan(o);return j.FromValuesToRef(d,0,0,0,0,_,0,g,0,0,f,1,0,0,p,0,r),a&&r.multiplyToRef($,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,i,s,r,n=!0,a,o=0){const h=1/Math.tan(.5*e),l=n?h/t:h,c=n?h:h*t,u=Math.tan(o);return j.FromValuesToRef(l,0,0,0,0,c,0,u,0,0,-i,1,0,0,1,0,r),a&&r.multiplyToRef($,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,i,s,r,n=0,a=!1){const o=new j;return j.PerspectiveFovRHToRef(e,t,i,s,o,!0,r,n,a),o}static PerspectiveFovRHToRef(e,t,i,s,r,n=!0,a,o=0,h=!1){const l=i,c=s,u=1/Math.tan(.5*e),d=n?u/t:u,_=n?u:u*t,f=h&&0===l?1:0!==c?-(c+l)/(c-l):-1,p=h&&0===l?2*c:0!==c?-2*c*l/(c-l):-2*l,g=Math.tan(o);return j.FromValuesToRef(d,0,0,0,0,_,0,g,0,0,f,-1,0,0,p,0,r),a&&r.multiplyToRef($,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,i,s,r,n=!0,a,o=0){const h=1/Math.tan(.5*e),l=n?h/t:h,c=n?h:h*t,u=Math.tan(o);return j.FromValuesToRef(l,0,0,0,0,c,0,u,0,0,-i,-1,0,0,-1,0,r),a&&r.multiplyToRef($,r),r._updateIdentityStatus(!1),r}static GetFinalMatrix(e,t,i,s,r,n){const a=e.width,o=e.height,h=e.x,l=e.y,c=j.FromValues(a/2,0,0,0,0,-o/2,0,0,0,0,n-r,0,h+a/2,o/2+l,r,1),u=new j;return t.multiplyToRef(i,u),u.multiplyToRef(s,u),u.multiplyToRef(c,u)}static GetAsMatrix2x2(e){const t=e.m,i=[t[0],t[1],t[4],t[5]];return P.MatrixUse64Bits?i:new Float32Array(i)}static GetAsMatrix3x3(e){const t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return P.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new j;return j.TransposeToRef(e,t),t}static TransposeToRef(e,t){const i=e.m,s=i[0],r=i[4],n=i[8],a=i[12],o=i[1],h=i[5],l=i[9],c=i[13],u=i[2],d=i[6],_=i[10],f=i[14],p=i[3],g=i[7],m=i[11],T=i[15],A=t._m;return A[0]=s,A[1]=r,A[2]=n,A[3]=a,A[4]=o,A[5]=h,A[6]=l,A[7]=c,A[8]=u,A[9]=d,A[10]=_,A[11]=f,A[12]=p,A[13]=g,A[14]=m,A[15]=T,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new j;return j.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();const i=e.normal.x,s=e.normal.y,r=e.normal.z,n=-2*i,a=-2*s,o=-2*r;return j.FromValuesToRef(n*i+1,a*i,o*i,0,n*s,a*s+1,o*s,0,n*r,a*r,o*r+1,0,n*e.d,a*e.d,o*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,s){return j.FromValuesToRef(e._x,e._y,e._z,0,t._x,t._y,t._z,0,i._x,i._y,i._z,0,0,0,0,1,s),s}static FromQuaternionToRef(e,t){const i=e._x*e._x,s=e._y*e._y,r=e._z*e._z,n=e._x*e._y,a=e._z*e._w,o=e._z*e._x,h=e._y*e._w,l=e._y*e._z,c=e._x*e._w;return t._m[0]=1-2*(s+r),t._m[1]=2*(n+a),t._m[2]=2*(o-h),t._m[3]=0,t._m[4]=2*(n-a),t._m[5]=1-2*(r+i),t._m[6]=2*(l+c),t._m[7]=0,t._m[8]=2*(o+h),t._m[9]=2*(l-c),t._m[10]=1-2*(s+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}}j._UpdateFlagSeed=0,j._IdentityReadOnly=j.Identity(),Object.defineProperties(j.prototype,{dimension:{value:[4,4]},rank:{value:2}});class Z{}Z.Vector3=I(11,X.Zero),Z.Matrix=I(2,j.Identity),Z.Quaternion=I(3,q.Zero);class J{}J.Vector2=I(3,Y.Zero),J.Vector3=I(13,X.Zero),J.Vector4=I(3,Q.Zero),J.Quaternion=I(3,q.Zero),J.Matrix=I(8,j.Identity),S("BABYLON.Vector2",Y),S("BABYLON.Vector3",X),S("BABYLON.Vector4",Q),S("BABYLON.Matrix",j);const $=j.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1),ee={};function te(e,t=!1){if(!t||!ee[e])return ee[e]=!0,`${e} needs to be imported before as it contains a side-effect required by your code.`}class ie{static Eval(e,t){return e=e.match(/\([^()]*\)/g)?e.replace(/\([^()]*\)/g,(e=>(e=e.slice(1,e.length-1),ie._HandleParenthesisContent(e,t)))):ie._HandleParenthesisContent(e,t),"true"===e||"false"!==e&&ie.Eval(e,t)}static _HandleParenthesisContent(e,t){let i;t=t||(e=>"true"===e);const s=e.split("||");for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)){let r=ie._SimplifyNegation(s[e].trim());const n=r.split("&&");if(n.length>1)for(let e=0;e<n.length;++e){const s=ie._SimplifyNegation(n[e].trim());if(i="true"!==s&&"false"!==s?"!"===s[0]?!t(s.substring(1)):t(s):"true"===s,!i){r="false";break}}if(i||"true"===r){i=!0;break}i="true"!==r&&"false"!==r?"!"===r[0]?!t(r.substring(1)):t(r):"true"===r}return i?"true":"false"}static _SimplifyNegation(e){return e=e.replace(/^[\s!]+/,(e=>(e=e.replace(/[\s]/g,(()=>""))).length%2?"!":"")),"!true"===(e=e.trim())?e="false":"!false"===e&&(e="true"),e}}class se{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>se.HasTags(e),e.addTags=t=>se.AddTagsTo(e,t),e.removeTags=t=>se.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>se.MatchesQuery(e,t)}static DisableFor(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery}static HasTags(e){if(!e._tags)return!1;const t=e._tags;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const t=[];for(const i in e._tags)Object.prototype.hasOwnProperty.call(e._tags,i)&&!0===e._tags[i]&&t.push(i);return t.join(" ")}return e._tags}static AddTagsTo(e,t){if(!t)return;if("string"!=typeof t)return;t.split(" ").forEach((function(t){se._AddTagTo(e,t)}))}static _AddTagTo(e,t){""!==(t=t.trim())&&"true"!==t&&"false"!==t&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(se.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!se.HasTags(e))return;const i=t.split(" ");for(const t in i)se._RemoveTagFrom(e,i[t])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return void 0===t||(""===t?se.HasTags(e):ie.Eval(t,(t=>se.HasTags(e)&&e._tags[t])))}}function re(e){return Math.pow(e,b)}function ne(e){return e<=.04045?.0773993808*e:Math.pow(.947867299*(e+.055),2.4)}function ae(e){return Math.pow(e,E)}function oe(e){return e<=.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class he{constructor(e=0,t=0,i=0){this.r=e,this.g=t,this.b=i}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"}getClassName(){return"Color3"}getHashCode(){let e=255*this.r|0;return e=397*e^255*this.g,e=397*e^255*this.b,e}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this}fromArray(e,t=0){return he.FromArrayToRef(e,t,this),this}toColor4(e=1){return new le(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return.3*this.r+.59*this.g+.11*this.b}multiply(e){return new he(this.r*e.r,this.g*e.g,this.b*e.b)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyByFloats(e,t,i){return new he(this.r*e,this.g*t,this.b*i)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.r,e.g,e.b)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.r,e.g,e.b)}minimizeInPlaceFromFloats(e,t,i){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this}maximizeInPlaceFromFloats(e,t,i){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,i){return this.equalsToFloats(e,t,i)}equalsToFloats(e,t,i){return this.r===e&&this.g===t&&this.b===i}equalsWithEpsilon(e,t=.001){return D(this.r,e.r,t)&&D(this.g,e.g,t)&&D(this.b,e.b,t)}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}scale(e){return new he(this.r*e,this.g*e,this.b*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t}clampToRef(e=0,t=1,i){return i.r=N(this.r,e,t),i.g=N(this.g,e,t),i.b=N(this.b,e,t),i}add(e){return new he(this.r+e.r,this.g+e.g,this.b+e.b)}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addInPlaceFromFloats(e,t,i){return this.r+=e,this.g+=t,this.b+=i,this}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t}subtract(e){return new he(this.r-e.r,this.g-e.g,this.b-e.b)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this}subtractFromFloats(e,t,i){return new he(this.r-e,this.g-t,this.b-i)}subtractFromFloatsToRef(e,t,i,s){return s.r=this.r-e,s.g=this.g-t,s.b=this.b-i,s}clone(){return new he(this.r,this.g,this.b)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyFromFloats(e,t,i){return this.r=e,this.g=t,this.b=i,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this.r=this.g=this.b=e,this}toHexString(){const e=Math.round(255*this.r),t=Math.round(255*this.g),i=Math.round(255*this.b);return"#"+U(e)+U(t)+U(i)}fromHexString(e){return"#"!==e.substring(0,1)||7!==e.length||(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255),this}toHSV(){return this.toHSVToRef(new he)}toHSVToRef(e){const t=this.r,i=this.g,s=this.b,r=Math.max(t,i,s),n=Math.min(t,i,s);let a=0,o=0;const h=r,l=r-n;return 0!==r&&(o=l/r),r!=n&&(r==t?(a=(i-s)/l,i<s&&(a+=6)):r==i?a=(s-t)/l+2:r==s&&(a=(t-i)/l+4),a*=60),e.r=a,e.g=o,e.b=h,e}toLinearSpace(e=!1){const t=new he;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=ne(this.r),e.g=ne(this.g),e.b=ne(this.b)):(e.r=re(this.r),e.g=re(this.g),e.b=re(this.b)),this}toGammaSpace(e=!1){const t=new he;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=oe(this.r),e.g=oe(this.g),e.b=oe(this.b)):(e.r=ae(this.r),e.g=ae(this.g),e.b=ae(this.b)),this}static HSVtoRGBToRef(e,t,i,s){const r=i*t,n=e/60,a=r*(1-Math.abs(n%2-1));let o=0,h=0,l=0;n>=0&&n<=1?(o=r,h=a):n>=1&&n<=2?(o=a,h=r):n>=2&&n<=3?(h=r,l=a):n>=3&&n<=4?(h=a,l=r):n>=4&&n<=5?(o=a,l=r):n>=5&&n<=6&&(o=r,l=a);const c=i-r;return s.r=o+c,s.g=h+c,s.b=l+c,s}static FromHSV(e,t,i){const s=new he(0,0,0);return he.HSVtoRGBToRef(e,t,i,s),s}static FromHexString(e){return new he(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new he(e[t],e[t+1],e[t+2])}static FromArrayToRef(e,t=0,i){i.r=e[t],i.g=e[t+1],i.b=e[t+2]}static FromInts(e,t,i){return new he(e/255,t/255,i/255)}static Lerp(e,t,i){const s=new he(0,0,0);return he.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){s.r=e.r+(t.r-e.r)*i,s.g=e.g+(t.g-e.g)*i,s.b=e.b+(t.b-e.b)*i}static Hermite(e,t,i,s,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e.r*o+i.r*h+t.r*l+s.r*c,d=e.g*o+i.g*h+t.g*l+s.g*c,_=e.b*o+i.b*h+t.b*l+s.b*c;return new he(u,d,_)}static Hermite1stDerivative(e,t,i,s,r){const n=he.Black();return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;n.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*i.r+(3*a-2*r)*s.r,n.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*i.g+(3*a-2*r)*s.g,n.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*i.b+(3*a-2*r)*s.b}static Red(){return new he(1,0,0)}static Green(){return new he(0,1,0)}static Blue(){return new he(0,0,1)}static Black(){return new he(0,0,0)}static get BlackReadOnly(){return he._BlackReadOnly}static White(){return new he(1,1,1)}static Purple(){return new he(.5,0,.5)}static Magenta(){return new he(1,0,1)}static Yellow(){return new he(1,1,0)}static Gray(){return new he(.5,.5,.5)}static Teal(){return new he(0,1,1)}static Random(){return new he(Math.random(),Math.random(),Math.random())}}he._V8PerformanceHack=new he(.5,.5,.5),he._BlackReadOnly=he.Black(),Object.defineProperties(he.prototype,{dimension:{value:[3]},rank:{value:1}});class le{constructor(e=0,t=0,i=0,s=1){this.r=e,this.g=t,this.b=i,this.a=s}asArray(){return[this.r,this.g,this.b,this.a]}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3],this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}add(e){return new le(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t.a=this.a+e.a,t}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}addInPlaceFromFloats(e,t,i,s){return this.r+=e,this.g+=t,this.b+=i,this.a+=s,this}subtract(e){return new le(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this.a-=e.a,this}subtractFromFloats(e,t,i,s){return new le(this.r-e,this.g-t,this.b-i,this.a-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-i,r.a=this.a-s,r}scale(e){return new le(this.r*e,this.g*e,this.b*e,this.a*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this.a*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,t}clampToRef(e=0,t=1,i){return i.r=N(this.r,e,t),i.g=N(this.g,e,t),i.b=N(this.b,e,t),i.a=N(this.a,e,t),i}multiply(e){return new le(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this.a*=e.a,this}multiplyByFloats(e,t,i,s){return new le(this.r*e,this.g*t,this.b*i,this.a*s)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.r=Math.min(this.r,e.r),this.g=Math.min(this.g,e.g),this.b=Math.min(this.b,e.b),this.a=Math.min(this.a,e.a),this}maximizeInPlace(e){return this.r=Math.max(this.r,e.r),this.g=Math.max(this.g,e.g),this.b=Math.max(this.b,e.b),this.a=Math.max(this.a,e.a),this}minimizeInPlaceFromFloats(e,t,i,s){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this.a=Math.min(s,this.a),this}maximizeInPlaceFromFloats(e,t,i,s){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this.a=Math.max(s,this.a),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}equalsWithEpsilon(e,t=.001){return D(this.r,e.r,t)&&D(this.g,e.g,t)&&D(this.b,e.b,t)&&D(this.a,e.a,t)}equalsToFloats(e,t,i,s){return this.r===e&&this.g===t&&this.b===i&&this.a===s}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=255*this.r|0;return e=397*e^255*this.g,e=397*e^255*this.b,e=397*e^255*this.a,e}clone(){return(new le).copyFrom(this)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}copyFromFloats(e,t,i,s){return this.r=e,this.g=t,this.b=i,this.a=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){const t=Math.round(255*this.r),i=Math.round(255*this.g),s=Math.round(255*this.b);if(e)return"#"+U(t)+U(i)+U(s);const r=Math.round(255*this.a);return"#"+U(t)+U(i)+U(s)+U(r)}fromHexString(e){return"#"!==e.substring(0,1)||9!==e.length&&7!==e.length||(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,9===e.length&&(this.a=parseInt(e.substring(7,9),16)/255)),this}toLinearSpace(e=!1){const t=new le;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=ne(this.r),e.g=ne(this.g),e.b=ne(this.b)):(e.r=re(this.r),e.g=re(this.g),e.b=re(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new le;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=oe(this.r),e.g=oe(this.g),e.b=oe(this.b)):(e.r=ae(this.r),e.g=ae(this.g),e.b=ae(this.b)),e.a=this.a,this}static FromHexString(e){return"#"!==e.substring(0,1)||9!==e.length&&7!==e.length?new le(0,0,0,0):new le(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return le.LerpToRef(e,t,i,new le)}static LerpToRef(e,t,i,s){return s.r=e.r+(t.r-e.r)*i,s.g=e.g+(t.g-e.g)*i,s.b=e.b+(t.b-e.b)*i,s.a=e.a+(t.a-e.a)*i,s}static Hermite(e,t,i,s,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e.r*o+i.r*h+t.r*l+s.r*c,d=e.g*o+i.g*h+t.g*l+s.g*c,_=e.b*o+i.b*h+t.b*l+s.b*c,f=e.a*o+i.a*h+t.a*l+s.a*c;return new le(u,d,_,f)}static Hermite1stDerivative(e,t,i,s,r){const n=new le;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;n.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*i.r+(3*a-2*r)*s.r,n.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*i.g+(3*a-2*r)*s.g,n.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*i.b+(3*a-2*r)*s.b,n.a=6*(a-r)*e.a+(3*a-4*r+1)*t.a+6*(-a+r)*i.a+(3*a-2*r)*s.a}static FromColor3(e,t=1){return new le(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new le(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t=0,i){i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]}static FromInts(e,t,i,s){return new le(e/255,t/255,i/255,s/255)}static CheckColors4(e,t){if(e.length===3*t){const t=[];for(let i=0;i<e.length;i+=3){const s=i/3*4;t[s]=e[i],t[s+1]=e[i+1],t[s+2]=e[i+2],t[s+3]=1}return t}return e}}le._V8PerformanceHack=new le(.5,.5,.5,.5),Object.defineProperties(le.prototype,{dimension:{value:[4]},rank:{value:1}});class ce{}ce.Color3=y(3,he.Black),ce.Color4=y(3,(()=>new le(0,0,0,0))),S("BABYLON.Color3",he),S("BABYLON.Color4",le);const ue=function(e,t,i,r={}){const n=e();se&&se.HasTags(t)&&se.AddTagsTo(n,se.GetTags(t,!0));const a=s(n),o={};for(const e in a){const s=a[e],h=t[e],l=s.type;if(null!=h&&("uniqueId"!==e||de.AllowLoadingUniqueId))switch(l){case 0:case 6:case 11:n[e]=h;break;case 1:r.cloneTexturesOnlyOnce&&o[h.uniqueId]?n[e]=o[h.uniqueId]:(n[e]=i||h.isRenderTarget?h:h.clone(),o[h.uniqueId]=n[e]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:n[e]=i?h:h.clone()}}return n};class de{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let i=0;i<e.animations.length;i++){const s=e.animations[i];t.animations.push(s.serialize())}}}static Serialize(e,t){t||(t={}),se&&(t.tags=se.GetTags(e));const i=s(e);for(const s in i){const r=i[s],n=r.sourceName||s,a=r.type,o=e[s];if(null!=o&&("uniqueId"!==s||de.AllowLoadingUniqueId))switch(a){case 0:t[n]=o;break;case 1:case 3:case 7:case 9:t[n]=o.serialize();break;case 2:case 4:case 5:case 8:case 10:case 12:t[n]=o.asArray();break;case 6:case 11:t[n]=o.id}}return t}static ParseProperties(e,t,i,r){r||(r="");const n=s(t);for(const s in n){const a=n[s],o=e[a.sourceName||s],h=a.type;if(null!=o&&("uniqueId"!==s||de.AllowLoadingUniqueId)){const e=t;switch(h){case 0:e[s]=o;break;case 1:i&&(e[s]=de._TextureParser(o,i,r));break;case 2:e[s]=he.FromArray(o);break;case 3:e[s]=de._FresnelParametersParser(o);break;case 4:e[s]=Y.FromArray(o);break;case 5:e[s]=X.FromArray(o);break;case 6:i&&(e[s]=i.getLastMeshById(o));break;case 7:e[s]=de._ColorCurvesParser(o);break;case 8:e[s]=le.FromArray(o);break;case 9:e[s]=de._ImageProcessingConfigurationParser(o);break;case 10:e[s]=q.FromArray(o);break;case 11:i&&(e[s]=i.getCameraById(o));break;case 12:e[s]=j.FromArray(o)}}}}static Parse(e,t,i,s=null){const r=e();return se&&se.AddTagsTo(r,t.tags),de.ParseProperties(t,r,i,s),r}static Clone(e,t,i={}){return ue(e,t,!1,i)}static Instanciate(e,t){return ue(e,t,!0)}}de.AllowLoadingUniqueId=!1,de._ImageProcessingConfigurationParser=e=>{throw te("ImageProcessingConfiguration")},de._FresnelParametersParser=e=>{throw te("FresnelParameters")},de._ColorCurvesParser=e=>{throw te("ColorCurves")},de._TextureParser=(e,t,i)=>{throw te("Texture")};class _e{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new A,this._onClonedObservable=new A}}class fe{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,s){const r=this._NodeConstructors[e];return r?r(t,i,s):null}set accessibilityTag(e){this._accessibilityTag=e,this.onAccessibilityTagChangedObservable.notifyObservers(e)}get accessibilityTag(){return this._accessibilityTag}get doNotSerialize(){return!!this._nodeDataStorage._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize}set doNotSerialize(e){this._nodeDataStorage._doNotSerialize=e}isDisposed(){return this._nodeDataStorage._isDisposed}set parent(e){if(this._parentNode===e)return;const t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){const t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1),e||this._nodeDataStorage._isDisposed||this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){-1===this._nodeDataStorage._sceneRootNodesIndex&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(-1!==this._nodeDataStorage._sceneRootNodesIndex){const e=this._scene.rootNodes,t=e.length-1;e[this._nodeDataStorage._sceneRootNodesIndex]=e[t],e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex=this._nodeDataStorage._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._nodeDataStorage._sceneRootNodesIndex=-1}}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}getClassName(){return"Node"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onEnabledStateChangedObservable(){return this._nodeDataStorage._onEnabledStateChangedObservable}get onClonedObservable(){return this._nodeDataStorage._onClonedObservable}constructor(e,t=null,i=!0){this._isDirty=!1,this._nodeDataStorage=new _e,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new A,this._parentContainer=null,this.animations=[],this._ranges={},this.onReady=null,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._waitingParentInstanceIndex=null,this._waitingParsedUniqueId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=j.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new A,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||O.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),i&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((()=>{e.attach(this)})):e.attach(this),this._behaviors.push(e)),this}removeBehavior(e){const t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this}get behaviors(){return this._behaviors}getBehaviorByName(e){for(const t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return!this._parentNode||!this._parentNode._isDirty&&this._parentUpdateId===this._parentNode._childUpdateId&&this._parentNode.isSynchronized()}isSynchronized(){return!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return!1===e?this._nodeDataStorage._isEnabled:!!this._nodeDataStorage._isEnabled&&this._nodeDataStorage._isParentEnabled}_syncParentEnabledState(){this._nodeDataStorage._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach((e=>{e._syncParentEnabledState()}))}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))}_getDescendants(e,t=!1,i){if(this._children)for(let s=0;s<this._children.length;s++){const r=this._children[s];i&&!i(r)||e.push(r),t||r._getDescendants(e,!1,i)}}getDescendants(e,t){const i=[];return this._getDescendants(i,e,t),i}getChildMeshes(e,t){const i=[];return this._getDescendants(i,e,(e=>(!t||t(e))&&void 0!==e.cullingStrategy)),i}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){e!==this._nodeDataStorage._isReady&&(e?(this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0):this._nodeDataStorage._isReady=!1)}getAnimationByName(e){for(let t=0;t<this.animations.length;t++){const i=this.animations[t];if(i.name===e)return i}return null}createAnimationRange(e,t,i){if(!this._ranges[e]){this._ranges[e]=fe._AnimationRangeFactory(e,t,i);for(let s=0,r=this.animations.length;s<r;s++)this.animations[s]&&this.animations[s].createRange(e,t,i)}}deleteAnimationRange(e,t=!0){for(let i=0,s=this.animations.length;i<s;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=null}getAnimationRange(e){return this._ranges[e]||null}clone(e,t,i){const s=de.Clone((()=>new fe(e,this.getScene())),this);if(t&&(s.parent=t),!i){const t=this.getDescendants(!0);for(let i=0;i<t.length;i++){const r=t[i];r.clone(e+"."+r.name,s)}}return s}getAnimationRanges(){const e=[];let t;for(t in this._ranges)e.push(this._ranges[t]);return e}beginAnimation(e,t,i,s){const r=this.getAnimationRange(e);return r?this._scene.beginAnimation(this,r.from,r.to,t,i,s):null}serializeAnimationRanges(){const e=[];for(const t in this._ranges){const i=this._ranges[t];if(!i)continue;const s={};s.name=t,s.from=i.from,s.to=i.to,e.push(s)}return e}computeWorldMatrix(e){return this._worldMatrix||(this._worldMatrix=j.Identity()),this._worldMatrix}dispose(e,t=!1){if(this._nodeDataStorage._isDisposed=!0,!e){const i=this.getDescendants(!0);for(const s of i)s.dispose(e,t)}this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onEnabledStateChangedObservable.clear(),this.onClonedObservable.clear();for(const e of this._behaviors)e.detach();this._behaviors.length=0,this.metadata=null}static ParseAnimationRanges(e,t,i){if(t.ranges)for(let i=0;i<t.ranges.length;i++){const s=t.ranges[i];e.createAnimationRange(s.name,s.from,s.to)}}getHierarchyBoundingVectors(e=!0,t=null){let i,s;this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);const r=this;if(r.getBoundingInfo&&r.subMeshes){const e=r.getBoundingInfo();i=e.boundingBox.minimumWorld.clone(),s=e.boundingBox.maximumWorld.clone()}else i=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new X(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e){const e=this.getDescendants(!1);for(const r of e){const e=r;if(e.computeWorldMatrix(!0),t&&!t(e))continue;if(!e.getBoundingInfo||0===e.getTotalVertices())continue;const n=e.getBoundingInfo().boundingBox,a=n.minimumWorld,o=n.maximumWorld;X.CheckExtends(a,i,s),X.CheckExtends(o,i,s)}}return{min:i,max:s}}}function pe(){return"undefined"!=typeof window}function ge(){return"undefined"!=typeof navigator}function me(){return"undefined"!=typeof document}function Te(e){let t="",i=e.firstChild;for(;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t}fe._AnimationRangeFactory=(e,t,i)=>{throw te("AnimationRange")},fe._NodeConstructors={},e([a()],fe.prototype,"name",void 0),e([a()],fe.prototype,"id",void 0),e([a()],fe.prototype,"uniqueId",void 0),e([a()],fe.prototype,"state",void 0),e([a()],fe.prototype,"metadata",void 0);class Ae{static _CheckLimit(e,t){let i=Ae._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},Ae._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){const i=Ae._LogLimitOutputs[e];if(!i||!Ae.MessageLimitReached)return;const s=this._Levels[t];i.current===i.limit&&Ae[s.name](Ae.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,s.name??""))}static _AddLogEntry(e){Ae._LogCache=e+Ae._LogCache,Ae.OnNewCacheEntry&&Ae.OnNewCacheEntry(e)}static _FormatMessage(e){const t=e=>e<10?"0"+e:""+e,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){const s=Array.isArray(t)?t[0]:t;if(void 0!==i&&!Ae._CheckLimit(s,i))return;const r=Ae._FormatMessage(s),n=this._Levels[e],a=Array.isArray(t)?t.slice(1):[];n.logFunc&&n.logFunc("BJS - "+r,...a);const o=`<div style='color:${n.color}'>${r}</div><br>`;Ae._AddLogEntry(o),Ae._GenerateLimitMessage(s,e)}static get LogCache(){return Ae._LogCache}static ClearLogCache(){Ae._LogCache="",Ae._LogLimitOutputs={},Ae.errorsCount=0}static set LogLevels(e){Ae.Log=Ae._LogDisabled,Ae.Warn=Ae._LogDisabled,Ae.Error=Ae._LogDisabled,[Ae.MessageLogLevel,Ae.WarningLogLevel,Ae.ErrorLogLevel].forEach((t=>{if((e&t)===t){const e=this._Levels[t];Ae[e.name]=Ae._LogEnabled.bind(Ae,t)}}))}}Ae.NoneLogLevel=0,Ae.MessageLogLevel=1,Ae.WarningLogLevel=2,Ae.ErrorLogLevel=4,Ae.AllLogLevel=7,Ae.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",Ae._LogCache="",Ae._LogLimitOutputs={},Ae._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],Ae.errorsCount=0,Ae.Log=Ae._LogEnabled.bind(Ae,Ae.MessageLogLevel),Ae.Warn=Ae._LogEnabled.bind(Ae,Ae.WarningLogLevel),Ae.Error=Ae._LogEnabled.bind(Ae,Ae.ErrorLogLevel);const Ee=(e,t,i)=>e?e.getClassName&&"Mesh"===e.getClassName()?null:!e.getClassName||"SubMesh"!==e.getClassName()&&"PhysicsBody"!==e.getClassName()?e.clone?e.clone():Array.isArray(e)?e.slice():i&&"object"==typeof e?{...e}:null:e.clone(t):null;class be{static DeepCopy(e,t,i,s,r=!1){const n=function(e){const t=[];do{Object.getOwnPropertyNames(e).forEach((function(e){-1===t.indexOf(e)&&t.push(e)}))}while(e=Object.getPrototypeOf(e));return t}(e);for(const a of n){if("_"===a[0]&&(!s||-1===s.indexOf(a)))continue;if(a.endsWith("Observable"))continue;if(i&&-1!==i.indexOf(a))continue;const n=e[a],o=typeof n;if("function"!==o)try{if("object"===o)if(n instanceof Uint8Array)t[a]=Uint8Array.from(n);else if(n instanceof Array){if(t[a]=[],n.length>0)if("object"==typeof n[0])for(let e=0;e<n.length;e++){const i=Ee(n[e],t,r);-1===t[a].indexOf(i)&&t[a].push(i)}else t[a]=n.slice(0)}else t[a]=Ee(n,t,r);else t[a]=n}catch(e){Ae.Warn(e.message)}}}}class Re{static get Now(){return pe()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}class ye{constructor(){this._xhr="undefined"!=typeof _native&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest,this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(ye.CustomRequestHeaders).length>0||ye.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in ye.CustomRequestHeaders){const t=ye.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return ye.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}get onprogress(){return this._xhr.onprogress}set onprogress(e){this._xhr.onprogress=e}get readyState(){return this._xhr.readyState}get status(){return this._xhr.status}get statusText(){return this._xhr.statusText}get response(){return this._xhr.response}get responseURL(){return this._xhr.responseURL}get responseText(){return this._xhr.responseText}get responseType(){return this._xhr.responseType}set responseType(e){this._xhr.responseType=e}get timeout(){return this._xhr.timeout}set timeout(e){this._xhr.timeout=e}addEventListener(e,t,i){this._xhr.addEventListener(e,t,i)}removeEventListener(e,t,i){this._xhr.removeEventListener(e,t,i)}abort(){this._xhr.abort()}send(e){ye.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const e of ye.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;e(this._xhr,t)}t=(t=t.replace("file:http:","http:")).replace("file:https:","https:"),this._requestURL=t,this._xhr.open(e,t,!0)}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}}ye.CustomRequestHeaders={},ye.CustomRequestModifiers=new Array,ye.SkipRequestModificationForBabylonCDN=!0;class Ie{}Ie.FilesToLoad={};class Me extends Error{}Me._setPrototypeOf=Object.setPrototypeOf||((e,t)=>(e.__proto__=t,e));const ve={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class xe extends Me{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",Me._setPrototypeOf(this,xe.prototype)}}const Se=e=>{if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0;i<e.byteLength;i++)t+=String.fromCharCode(e[i]);return t},Ce=e=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i,s,r,n,a,o,h,l="",c=0;const u=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(;c<u.length;)i=u[c++],s=c<u.length?u[c++]:Number.NaN,r=c<u.length?u[c++]:Number.NaN,n=i>>2,a=(3&i)<<4|s>>4,o=(15&s)<<2|r>>6,h=63&r,isNaN(s)?o=h=64:isNaN(r)&&(h=64),l+=t.charAt(n)+t.charAt(a)+t.charAt(o)+t.charAt(h);return l},Pe=e=>atob(e);class Oe{constructor(){this.children=[]}isValid(e){return!0}process(e,t){let i="";if(this.line){let s=this.line;const r=t.processor;if(r){r.lineProcessor&&(s=r.lineProcessor(s,t.isFragment,t.processingContext));const i=t.processor?.attributeKeywordName??"attribute",n=t.isFragment&&t.processor?.varyingFragmentKeywordName?t.processor?.varyingFragmentKeywordName:!t.isFragment&&t.processor?.varyingVertexKeywordName?t.processor?.varyingVertexKeywordName:"varying";if(!t.isFragment&&r.attributeProcessor&&this.line.startsWith(i))s=r.attributeProcessor(this.line,e,t.processingContext);else if(r.varyingProcessor&&(r.varyingCheck?.(this.line,t.isFragment)||!r.varyingCheck&&this.line.startsWith(n)))s=r.varyingProcessor(this.line,t.isFragment,e,t.processingContext);else if(r.uniformProcessor&&r.uniformRegexp&&r.uniformRegexp.test(this.line))t.lookForClosingBracketForUniformBuffer||(s=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext));else if(r.uniformBufferProcessor&&r.uniformBufferRegexp&&r.uniformBufferRegexp.test(this.line))t.lookForClosingBracketForUniformBuffer||(s=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0);else if(r.textureProcessor&&r.textureRegexp&&r.textureRegexp.test(this.line))s=r.textureProcessor(this.line,t.isFragment,e,t.processingContext);else if((r.uniformProcessor||r.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer){/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?r.uniformProcessor&&(s=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&(s=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)}t.lookForClosingBracketForUniformBuffer&&-1!==this.line.indexOf("}")&&(t.lookForClosingBracketForUniformBuffer=!1,r.endOfUniformBufferProcessor&&(s=r.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}i+=s+"\n"}return this.children.forEach((s=>{i+=s.process(e,t)})),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),i}}class De{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex<this._lines.length-1}set lines(e){this._lines.length=0;for(const t of e){if(!t||"\r"===t)continue;if("#"===t[0]){this._lines.push(t);continue}const e=t.trim();if(!e)continue;if(e.startsWith("//")){this._lines.push(t);continue}const i=e.indexOf(";");if(-1===i)this._lines.push(e);else if(i===e.length-1)e.length>1&&this._lines.push(e);else{const e=t.split(";");for(let t=0;t<e.length;t++){let i=e[t];i&&(i=i.trim(),i&&this._lines.push(i+(t!==e.length-1?";":"")))}}}}}class Le extends Oe{process(e,t){for(let i=0;i<this.children.length;i++){const s=this.children[i];if(s.isValid(e))return s.process(e,t)}return""}}class Fe extends Oe{isValid(e){return this.testExpression.isTrue(e)}}class we{isTrue(e){return!0}static postfixToInfix(e){const t=[];for(const i of e)if(void 0===we._OperatorPriority[i])t.push(i);else{const e=t[t.length-1],s=t[t.length-2];t.length-=2,t.push(`(${s}${i}${e})`)}return t[t.length-1]}static infixToPostfix(e){const t=we._InfixToPostfixCache.get(e);if(t)return t.accessTime=Date.now(),t.result;if(!(e.includes("&&")||e.includes("||")||e.includes(")")||e.includes("(")))return[e];const i=[];let s=-1;const r=()=>{l=l.trim(),""!==l&&(i.push(l),l="")},n=e=>{s<we._Stack.length-1&&(we._Stack[++s]=e)},a=()=>we._Stack[s],o=()=>-1===s?"!!INVALID EXPRESSION!!":we._Stack[s--];let h=0,l="";for(;h<e.length;){const t=e.charAt(h),c=h<e.length-1?e.substring(h,2+h):"";if("("===t)l="",n(t);else if(")"===t){for(r();-1!==s&&"("!==a();)i.push(o());o()}else if(we._OperatorPriority[c]>1){for(r();-1!==s&&we._OperatorPriority[a()]>=we._OperatorPriority[c];)i.push(o());n(c),h++}else l+=t;h++}for(r();-1!==s;)"("===a()?o():i.push(o());return we._InfixToPostfixCache.size>=we.InfixToPostfixCacheLimitSize&&we.ClearCache(),we._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){const e=Array.from(we._InfixToPostfixCache.entries()).sort(((e,t)=>e[1].accessTime-t[1].accessTime));for(let t=0;t<we.InfixToPostfixCacheCleanupSize;t++)we._InfixToPostfixCache.delete(e[t][0])}}we.InfixToPostfixCacheLimitSize=5e4,we.InfixToPostfixCacheCleanupSize=25e3,we._InfixToPostfixCache=new Map,we._OperatorPriority={")":0,"(":1,"||":2,"&&":3},we._Stack=["","","","","","","","","","","","","","","","","","","",""];class Ne extends we{constructor(e,t=!1){super(),this.define=e,this.not=t}isTrue(e){let t=void 0!==e[this.define];return this.not&&(t=!t),t}}class Be extends we{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}class Ue extends we{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}class ke extends we{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}isTrue(e){let t=e[this.define];void 0===t&&(t=this.define);let i=!1;const s=parseInt(t),r=parseInt(this.testValue);switch(this.operand){case">":i=s>r;break;case"<":i=s<r;break;case"<=":i=s<=r;break;case">=":i=s>=r;break;case"==":i=s===r;break;case"!=":i=s!==r}return i}}class Ve{}Ve.AUTOSAMPLERSUFFIX="Sampler",Ve.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS",Ve.ALPHA_DISABLE=0,Ve.ALPHA_ADD=1,Ve.ALPHA_COMBINE=2,Ve.ALPHA_SUBTRACT=3,Ve.ALPHA_MULTIPLY=4,Ve.ALPHA_MAXIMIZED=5,Ve.ALPHA_ONEONE=6,Ve.ALPHA_PREMULTIPLIED=7,Ve.ALPHA_PREMULTIPLIED_PORTERDUFF=8,Ve.ALPHA_INTERPOLATE=9,Ve.ALPHA_SCREENMODE=10,Ve.ALPHA_ONEONE_ONEONE=11,Ve.ALPHA_ALPHATOCOLOR=12,Ve.ALPHA_REVERSEONEMINUS=13,Ve.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,Ve.ALPHA_ONEONE_ONEZERO=15,Ve.ALPHA_EXCLUSION=16,Ve.ALPHA_LAYER_ACCUMULATE=17,Ve.ALPHA_EQUATION_ADD=0,Ve.ALPHA_EQUATION_SUBSTRACT=1,Ve.ALPHA_EQUATION_REVERSE_SUBTRACT=2,Ve.ALPHA_EQUATION_MAX=3,Ve.ALPHA_EQUATION_MIN=4,Ve.ALPHA_EQUATION_DARKEN=5,Ve.DELAYLOADSTATE_NONE=0,Ve.DELAYLOADSTATE_LOADED=1,Ve.DELAYLOADSTATE_LOADING=2,Ve.DELAYLOADSTATE_NOTLOADED=4,Ve.NEVER=512,Ve.ALWAYS=519,Ve.LESS=513,Ve.EQUAL=514,Ve.LEQUAL=515,Ve.GREATER=516,Ve.GEQUAL=518,Ve.NOTEQUAL=517,Ve.KEEP=7680,Ve.ZERO=0,Ve.REPLACE=7681,Ve.INCR=7682,Ve.DECR=7683,Ve.INVERT=5386,Ve.INCR_WRAP=34055,Ve.DECR_WRAP=34056,Ve.TEXTURE_CLAMP_ADDRESSMODE=0,Ve.TEXTURE_WRAP_ADDRESSMODE=1,Ve.TEXTURE_MIRROR_ADDRESSMODE=2,Ve.TEXTURE_CREATIONFLAG_STORAGE=1,Ve.TEXTUREFORMAT_ALPHA=0,Ve.TEXTUREFORMAT_LUMINANCE=1,Ve.TEXTUREFORMAT_LUMINANCE_ALPHA=2,Ve.TEXTUREFORMAT_RGB=4,Ve.TEXTUREFORMAT_RGBA=5,Ve.TEXTUREFORMAT_RED=6,Ve.TEXTUREFORMAT_R=6,Ve.TEXTUREFORMAT_R16_UNORM=33322,Ve.TEXTUREFORMAT_RG16_UNORM=33324,Ve.TEXTUREFORMAT_RGB16_UNORM=32852,Ve.TEXTUREFORMAT_RGBA16_UNORM=32859,Ve.TEXTUREFORMAT_R16_SNORM=36760,Ve.TEXTUREFORMAT_RG16_SNORM=36761,Ve.TEXTUREFORMAT_RGB16_SNORM=36762,Ve.TEXTUREFORMAT_RGBA16_SNORM=36763,Ve.TEXTUREFORMAT_RG=7,Ve.TEXTUREFORMAT_RED_INTEGER=8,Ve.TEXTUREFORMAT_R_INTEGER=8,Ve.TEXTUREFORMAT_RG_INTEGER=9,Ve.TEXTUREFORMAT_RGB_INTEGER=10,Ve.TEXTUREFORMAT_RGBA_INTEGER=11,Ve.TEXTUREFORMAT_BGRA=12,Ve.TEXTUREFORMAT_DEPTH24_STENCIL8=13,Ve.TEXTUREFORMAT_DEPTH32_FLOAT=14,Ve.TEXTUREFORMAT_DEPTH16=15,Ve.TEXTUREFORMAT_DEPTH24=16,Ve.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17,Ve.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18,Ve.TEXTUREFORMAT_STENCIL8=19,Ve.TEXTUREFORMAT_UNDEFINED=4294967295,Ve.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492,Ve.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493,Ve.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495,Ve.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494,Ve.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779,Ve.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919,Ve.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778,Ve.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918,Ve.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777,Ve.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776,Ve.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917,Ve.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916,Ve.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808,Ve.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840,Ve.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196,Ve.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492,Ve.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493,Ve.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494,Ve.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495,Ve.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496,Ve.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497,Ve.TEXTURETYPE_UNSIGNED_BYTE=0,Ve.TEXTURETYPE_UNSIGNED_INT=0,Ve.TEXTURETYPE_FLOAT=1,Ve.TEXTURETYPE_HALF_FLOAT=2,Ve.TEXTURETYPE_BYTE=3,Ve.TEXTURETYPE_SHORT=4,Ve.TEXTURETYPE_UNSIGNED_SHORT=5,Ve.TEXTURETYPE_INT=6,Ve.TEXTURETYPE_UNSIGNED_INTEGER=7,Ve.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,Ve.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,Ve.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,Ve.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,Ve.TEXTURETYPE_UNSIGNED_INT_24_8=12,Ve.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,Ve.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,Ve.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,Ve.TEXTURETYPE_UNDEFINED=16,Ve.TEXTURE_2D=3553,Ve.TEXTURE_2D_ARRAY=35866,Ve.TEXTURE_CUBE_MAP=34067,Ve.TEXTURE_CUBE_MAP_ARRAY=3735928559,Ve.TEXTURE_3D=32879,Ve.TEXTURE_NEAREST_SAMPLINGMODE=1,Ve.TEXTURE_NEAREST_NEAREST=1,Ve.TEXTURE_BILINEAR_SAMPLINGMODE=2,Ve.TEXTURE_LINEAR_LINEAR=2,Ve.TEXTURE_TRILINEAR_SAMPLINGMODE=3,Ve.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,Ve.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,Ve.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,Ve.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,Ve.TEXTURE_NEAREST_LINEAR=7,Ve.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,Ve.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,Ve.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,Ve.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,Ve.TEXTURE_LINEAR_NEAREST=12,Ve.TEXTURE_EXPLICIT_MODE=0,Ve.TEXTURE_SPHERICAL_MODE=1,Ve.TEXTURE_PLANAR_MODE=2,Ve.TEXTURE_CUBIC_MODE=3,Ve.TEXTURE_PROJECTION_MODE=4,Ve.TEXTURE_SKYBOX_MODE=5,Ve.TEXTURE_INVCUBIC_MODE=6,Ve.TEXTURE_EQUIRECTANGULAR_MODE=7,Ve.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,Ve.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,Ve.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,Ve.TEXTURE_FILTERING_QUALITY_HIGH=64,Ve.TEXTURE_FILTERING_QUALITY_MEDIUM=16,Ve.TEXTURE_FILTERING_QUALITY_LOW=8,Ve.SCALEMODE_FLOOR=1,Ve.SCALEMODE_NEAREST=2,Ve.SCALEMODE_CEILING=3,Ve.MATERIAL_TextureDirtyFlag=1,Ve.MATERIAL_LightDirtyFlag=2,Ve.MATERIAL_FresnelDirtyFlag=4,Ve.MATERIAL_AttributesDirtyFlag=8,Ve.MATERIAL_MiscDirtyFlag=16,Ve.MATERIAL_PrePassDirtyFlag=32,Ve.MATERIAL_AllDirtyFlag=63,Ve.MATERIAL_TriangleFillMode=0,Ve.MATERIAL_WireFrameFillMode=1,Ve.MATERIAL_PointFillMode=2,Ve.MATERIAL_PointListDrawMode=3,Ve.MATERIAL_LineListDrawMode=4,Ve.MATERIAL_LineLoopDrawMode=5,Ve.MATERIAL_LineStripDrawMode=6,Ve.MATERIAL_TriangleStripDrawMode=7,Ve.MATERIAL_TriangleFanDrawMode=8,Ve.MATERIAL_ClockWiseSideOrientation=0,Ve.MATERIAL_CounterClockWiseSideOrientation=1,Ve.ACTION_NothingTrigger=0,Ve.ACTION_OnPickTrigger=1,Ve.ACTION_OnLeftPickTrigger=2,Ve.ACTION_OnRightPickTrigger=3,Ve.ACTION_OnCenterPickTrigger=4,Ve.ACTION_OnPickDownTrigger=5,Ve.ACTION_OnDoublePickTrigger=6,Ve.ACTION_OnPickUpTrigger=7,Ve.ACTION_OnPickOutTrigger=16,Ve.ACTION_OnLongPressTrigger=8,Ve.ACTION_OnPointerOverTrigger=9,Ve.ACTION_OnPointerOutTrigger=10,Ve.ACTION_OnEveryFrameTrigger=11,Ve.ACTION_OnIntersectionEnterTrigger=12,Ve.ACTION_OnIntersectionExitTrigger=13,Ve.ACTION_OnKeyDownTrigger=14,Ve.ACTION_OnKeyUpTrigger=15,Ve.PARTICLES_BILLBOARDMODE_Y=2,Ve.PARTICLES_BILLBOARDMODE_ALL=7,Ve.PARTICLES_BILLBOARDMODE_STRETCHED=8,Ve.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9,Ve.MESHES_CULLINGSTRATEGY_STANDARD=0,Ve.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,Ve.SCENELOADER_NO_LOGGING=0,Ve.SCENELOADER_MINIMAL_LOGGING=1,Ve.SCENELOADER_SUMMARY_LOGGING=2,Ve.SCENELOADER_DETAILED_LOGGING=3,Ve.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,Ve.PREPASS_POSITION_TEXTURE_TYPE=1,Ve.PREPASS_VELOCITY_TEXTURE_TYPE=2,Ve.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,Ve.PREPASS_COLOR_TEXTURE_TYPE=4,Ve.PREPASS_DEPTH_TEXTURE_TYPE=5,Ve.PREPASS_NORMAL_TEXTURE_TYPE=6,Ve.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7,Ve.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8,Ve.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9,Ve.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10,Ve.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11,Ve.PREPASS_ALBEDO_TEXTURE_TYPE=12,Ve.BUFFER_CREATIONFLAG_READ=1,Ve.BUFFER_CREATIONFLAG_WRITE=2,Ve.BUFFER_CREATIONFLAG_READWRITE=3,Ve.BUFFER_CREATIONFLAG_UNIFORM=4,Ve.BUFFER_CREATIONFLAG_VERTEX=8,Ve.BUFFER_CREATIONFLAG_INDEX=16,Ve.BUFFER_CREATIONFLAG_STORAGE=32,Ve.BUFFER_CREATIONFLAG_INDIRECT=64,Ve.RENDERPASS_MAIN=0,Ve.INPUT_ALT_KEY=18,Ve.INPUT_CTRL_KEY=17,Ve.INPUT_META_KEY1=91,Ve.INPUT_META_KEY2=92,Ve.INPUT_META_KEY3=93,Ve.INPUT_SHIFT_KEY=16,Ve.SNAPSHOTRENDERING_STANDARD=0,Ve.SNAPSHOTRENDERING_FAST=1,Ve.PERSPECTIVE_CAMERA=0,Ve.ORTHOGRAPHIC_CAMERA=1,Ve.FOVMODE_VERTICAL_FIXED=0,Ve.FOVMODE_HORIZONTAL_FIXED=1,Ve.RIG_MODE_NONE=0,Ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,Ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,Ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,Ve.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,Ve.RIG_MODE_STEREOSCOPIC_INTERLACED=14,Ve.RIG_MODE_VR=20,Ve.RIG_MODE_CUSTOM=22,Ve.MAX_SUPPORTED_UV_SETS=6,Ve.GL_ALPHA_EQUATION_ADD=32774,Ve.GL_ALPHA_EQUATION_MIN=32775,Ve.GL_ALPHA_EQUATION_MAX=32776,Ve.GL_ALPHA_EQUATION_SUBTRACT=32778,Ve.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779,Ve.GL_ALPHA_FUNCTION_SRC=768,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769,Ve.GL_ALPHA_FUNCTION_SRC_ALPHA=770,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771,Ve.GL_ALPHA_FUNCTION_DST_ALPHA=772,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773,Ve.GL_ALPHA_FUNCTION_DST_COLOR=774,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775,Ve.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776,Ve.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770,Ve.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772,Ve.GL_ALPHA_FUNCTION_SRC1_COLOR=35065,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066,Ve.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185,Ve.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067,Ve.SnippetUrl="https://snippet.babylonjs.com",Ve.FOGMODE_NONE=0,Ve.FOGMODE_EXP=1,Ve.FOGMODE_EXP2=2,Ve.FOGMODE_LINEAR=3,Ve.BYTE=5120,Ve.UNSIGNED_BYTE=5121,Ve.SHORT=5122,Ve.UNSIGNED_SHORT=5123,Ve.INT=5124,Ve.UNSIGNED_INT=5125,Ve.FLOAT=5126,Ve.PositionKind="position",Ve.NormalKind="normal",Ve.TangentKind="tangent",Ve.UVKind="uv",Ve.UV2Kind="uv2",Ve.UV3Kind="uv3",Ve.UV4Kind="uv4",Ve.UV5Kind="uv5",Ve.UV6Kind="uv6",Ve.ColorKind="color",Ve.ColorInstanceKind="instanceColor",Ve.MatricesIndicesKind="matricesIndices",Ve.MatricesWeightsKind="matricesWeights",Ve.MatricesIndicesExtraKind="matricesIndicesExtra",Ve.MatricesWeightsExtraKind="matricesWeightsExtra",Ve.ShadowMinZ=0,Ve.ShadowMaxZ=1e4;const ze={};function Ge(e,t,i=""){return i+(t?t+"\n":"")+e}function He(e,t,i,s,r,n,a){const o=a||ze.loadFile;if(o){return o(e,t,i,s,r,n)}throw te("FileTools")}function We(e,t,i,s){if(e)return t?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,i?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(s?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);{let e="";return t&&(e+="#define IS_NDC_HALF_ZRANGE"),i&&(e&&(e+="\n"),e+="#define USE_REVERSE_DEPTHBUFFER"),s&&(e&&(e+="\n"),e+="#define USE_EXACT_SRGB_CONVERSIONS"),e}}function Ke(e,t,i=!1,s){switch(e){case Ve.TEXTURETYPE_BYTE:{const e=(ArrayBuffer,new Int8Array(t));return s&&e.set(new Int8Array(s)),e}case Ve.TEXTURETYPE_UNSIGNED_BYTE:{const e=(ArrayBuffer,new Uint8Array(t));return s&&e.set(new Uint8Array(s)),e}case Ve.TEXTURETYPE_SHORT:{const e=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(i?t/2:t);return s&&e.set(new Int16Array(s)),e}case Ve.TEXTURETYPE_UNSIGNED_SHORT:case Ve.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:case Ve.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:case Ve.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:case Ve.TEXTURETYPE_HALF_FLOAT:{const e=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(i?t/2:t);return s&&e.set(new Uint16Array(s)),e}case Ve.TEXTURETYPE_INT:{const e=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(i?t/4:t);return s&&e.set(new Int32Array(s)),e}case Ve.TEXTURETYPE_UNSIGNED_INTEGER:case Ve.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:case Ve.TEXTURETYPE_UNSIGNED_INT_24_8:case Ve.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:case Ve.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:case Ve.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:{const e=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(i?t/4:t);return s&&e.set(new Uint32Array(s)),e}case Ve.TEXTURETYPE_FLOAT:{const e=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(i?t/4:t);return s&&e.set(new Float32Array(s)),e}}const r=(ArrayBuffer,new Uint8Array(t));return s&&r.set(new Uint8Array(s)),r}const Ye=/defined\s*?\((.+?)\)/g,Xe=/defined\s*?\[(.+?)\]/g,Qe=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,qe=/__decl__/,je=/light\{X\}.(\w*)/g,Ze=/\{X\}/g,Je=[],$e=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function et(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)}function tt(e,t,i,s){t.processor?.preProcessShaderCode&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),ot(e,t,(e=>{t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e,t.defines));const r=function(e,t,i){let s=function(e,t){if(t.processor?.noPrecision)return e;const i=t.shouldUseHighPrecisionShader;-1===e.indexOf("precision highp float")?e=i?"precision highp float;\n"+e:"precision mediump float;\n"+e:i||(e=e.replace("precision highp float","precision mediump float"));return e}(e,t);if(!t.processor)return s;if(0===t.processor.shaderLanguage&&-1!==s.indexOf("#version 3")&&(s=s.replace("#version 300 es",""),!t.processor.parseGLES3))return s;const r=t.defines,n=function(e,t){const i=e.defines,s={};for(const e of i){const t=e.replace("#define","").replace(";","").trim().split(" ");s[t[0]]=t.length>1?t[1]:""}0===e.processor?.shaderLanguage&&(s.GL_ES="true");return s.__VERSION__=e.version,s[e.platformName]="true",We(s,t?.isNDCHalfZRange,t?.useReverseDepthBuffer,t?.useExactSrgbConversions),s}(t,i);t.processor.preProcessor&&(s=t.processor.preProcessor(s,r,n,t.isFragment,t.processingContext));s=function(e,t,i){const s=new Oe,r=new De;return r.lineIndex=-1,r.lines=e.split("\n"),at(r,s),s.process(t,i)}(s,n,t),t.processor.postProcessor&&(s=t.processor.postProcessor(s,r,t.isFragment,t.processingContext,i?{drawBuffersExtensionDisabled:!i.getCaps().drawBuffersExtension}:{}));i?._features.needShaderCodeInlining&&(s=i.inlineShaderCode(s));return s}(e,t,s);i(r,e)}))}function it(e,t,i){return i.processor&&i.processor.finalizeShaders?i.processor.finalizeShaders(e,t,i.processingContext):{vertexCode:e,fragmentCode:t}}function st(e){const t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new Ne(t[1].trim(),"!"===e[0]);const i=["==","!=",">=","<=","<",">"];let s="",r=0;for(s of i)if(r=e.indexOf(s),r>-1)break;if(-1===r)return new Ne(e);const n=e.substring(0,r).trim(),a=e.substring(r+s.length).trim();return new ke(n,s,a)}function rt(e,t){const i=new Fe,s=e.substring(0,t);let r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),i.testExpression="#ifdef"===s?new Ne(r):"#ifndef"===s?new Ne(r,!0):function(e){e=e.replace(Ye,"defined[$1]");const t=we.infixToPostfix(e),i=[];for(const e of t)if("||"!==e&&"&&"!==e)i.push(e);else if(i.length>=2){let t=i[i.length-1],s=i[i.length-2];i.length-=2;const r="&&"==e?new Ue:new Be;"string"==typeof t&&(t=t.replace(Xe,"defined($1)")),"string"==typeof s&&(s=s.replace(Xe,"defined($1)")),r.leftOperand="string"==typeof s?st(s):s,r.rightOperand="string"==typeof t?st(t):t,i.push(r)}let s=i[i.length-1];return"string"==typeof s&&(s=s.replace(Xe,"defined($1)")),"string"==typeof s?st(s):s}(r),i}function nt(e,t,i){let s=e.currentLine;for(;at(e,i);){s=e.currentLine;const r=s.substring(0,5).toLowerCase();if("#else"===r){const i=new Oe;return t.children.push(i),void at(e,i)}if("#elif"===r){const e=rt(s,5);t.children.push(e),i=e}}}function at(e,t){for(;e.canRead;){e.lineIndex++;const i=e.currentLine;if(i.indexOf("#")>=0){const s=$e.exec(i);if(s&&s.length){switch(s[0]){case"#ifdef":{const s=new Le;t.children.push(s);const r=rt(i,6);s.children.push(r),nt(e,s,r);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const s=new Le;t.children.push(s);const r=rt(i,7);s.children.push(r),nt(e,s,r);break}case"#if":{const s=new Le,r=rt(i,3);t.children.push(s),s.children.push(r),nt(e,s,r);break}}continue}}const s=new Oe;if(s.line=i,t.children.push(s),"#"===i[0]&&"d"===i[1]){const e=i.replace(";","").split(" ");s.additionalDefineKey=e[1],3===e.length&&(s.additionalDefineValue=e[2])}}return!1}function ot(e,t,i){let s;for(Je.length=0;null!==(s=Qe.exec(e));)Je.push(s);let r=String(e),n=[e],a=!1;for(const e of Je){let s=e[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(qe,""),t.supportsUniformBuffers&&(s=s.replace("Vertex","Ubo").replace("Fragment","Ubo")),s+="Declaration"),!t.includesShadersStore[s]){const e=t.shadersRepository+"ShadersInclude/"+s+".fx";return void ht.loadFile(e,(e=>{t.includesShadersStore[s]=e,ot(n.join(""),t,i)}))}{let i=t.includesShadersStore[s];if(e[2]){const t=e[3].split(",");for(let e=0;e<t.length;e+=2){const s=new RegExp(t[e],"g"),r=t[e+1];i=i.replace(s,r)}}if(e[4]){const s=e[5];if(-1!==s.indexOf("..")){const e=s.split(".."),r=parseInt(e[0]);let n=parseInt(e[1]),a=i.slice(0);i="",isNaN(n)&&(n=t.indexParameters[e[1]]);for(let e=r;e<n;e++)t.supportsUniformBuffers||(a=a.replace(je,((e,t)=>t+"{X}"))),i+=a.replace(Ze,e.toString())+"\n"}else t.supportsUniformBuffers||(i=i.replace(je,((e,t)=>t+"{X}"))),i=i.replace(Ze,s)}const r=[];for(const t of n){const s=t.split(e[0]);for(let e=0;e<s.length-1;e++)r.push(s[e]),r.push(i);r.push(s[s.length-1])}n=r,a=a||i.indexOf("#include<")>=0||i.indexOf("#include <")>=0}}Je.length=0,r=n.join(""),a?ot(r.toString(),t,i):i(r)}const ht={loadFile:(e,t,i,s,r,n)=>{throw te("FileTools")}};class lt{static SetImmediate(e){pe()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)}}class ct{static GetShadersRepository(e=0){return 0===e?ct.ShadersRepository:ct.ShadersRepositoryWGSL}static GetShadersStore(e=0){return 0===e?ct.ShadersStore:ct.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return 0===e?ct.IncludesShadersStore:ct.IncludesShadersStoreWGSL}}ct.ShadersRepository="src/Shaders/",ct.ShadersStore={},ct.IncludesShadersStore={},ct.ShadersRepositoryWGSL="src/ShadersWGSL/",ct.ShadersStoreWGSL={},ct.IncludesShadersStoreWGSL={};class ut{constructor(){this._valueCache={},this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null,this._isDisposed=!1}get isAsync(){return this.isParallelCompiled}get isReady(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))}_handlesSpectorRebuildCallback(e){e&&this.program&&e(this.program)}setEngine(e){this.engine=e}_fillEffectInformation(e,t,i,s,r,n,a,o){const h=this.engine;if(h.supportsUniformBuffers)for(const i in t)e.bindUniformBlock(i,t[i]);let l;for(this.engine.getUniforms(this,i).forEach(((e,t)=>{s[i[t]]=e})),this._uniforms=s,l=0;l<r.length;l++){null==e.getUniform(r[l])&&(r.splice(l,1),l--)}r.forEach(((e,t)=>{n[e]=t}));for(const e of h.getAttributes(this,a))o.push(e)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){const i=this._valueCache[e],s=t.updateFlag;return(void 0===i||i!==s)&&(this._valueCache[e]=s,!0)}_cacheFloat2(e,t,i){let s=this._valueCache[e];if(!s||2!==s.length)return s=[t,i],this._valueCache[e]=s,!0;let r=!1;return s[0]!==t&&(s[0]=t,r=!0),s[1]!==i&&(s[1]=i,r=!0),r}_cacheFloat3(e,t,i,s){let r=this._valueCache[e];if(!r||3!==r.length)return r=[t,i,s],this._valueCache[e]=r,!0;let n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),r[2]!==s&&(r[2]=s,n=!0),n}_cacheFloat4(e,t,i,s,r){let n=this._valueCache[e];if(!n||4!==n.length)return n=[t,i,s,r],this._valueCache[e]=n,!0;let a=!1;return n[0]!==t&&(n[0]=t,a=!0),n[1]!==i&&(n[1]=i,a=!0),n[2]!==s&&(n[2]=s,a=!0),n[3]!==r&&(n[3]=r,a=!0),a}setInt(e,t){const i=this._valueCache[e];void 0!==i&&i===t||this.engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setInt2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setInt2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setInt3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setInt3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setInt4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setInt4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setIntArray(e,t){this._valueCache[e]=null,this.engine.setIntArray(this._uniforms[e],t)}setIntArray2(e,t){this._valueCache[e]=null,this.engine.setIntArray2(this._uniforms[e],t)}setIntArray3(e,t){this._valueCache[e]=null,this.engine.setIntArray3(this._uniforms[e],t)}setIntArray4(e,t){this._valueCache[e]=null,this.engine.setIntArray4(this._uniforms[e],t)}setUInt(e,t){const i=this._valueCache[e];void 0!==i&&i===t||this.engine.setUInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setUInt2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setUInt2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setUInt3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setUInt3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setUInt4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setUInt4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setUIntArray(e,t){this._valueCache[e]=null,this.engine.setUIntArray(this._uniforms[e],t)}setUIntArray2(e,t){this._valueCache[e]=null,this.engine.setUIntArray2(this._uniforms[e],t)}setUIntArray3(e,t){this._valueCache[e]=null,this.engine.setUIntArray3(this._uniforms[e],t)}setUIntArray4(e,t){this._valueCache[e]=null,this.engine.setUIntArray4(this._uniforms[e],t)}setArray(e,t){this._valueCache[e]=null,this.engine.setArray(this._uniforms[e],t)}setArray2(e,t){this._valueCache[e]=null,this.engine.setArray2(this._uniforms[e],t)}setArray3(e,t){this._valueCache[e]=null,this.engine.setArray3(this._uniforms[e],t)}setArray4(e,t){this._valueCache[e]=null,this.engine.setArray4(this._uniforms[e],t)}setMatrices(e,t){t&&(this._valueCache[e]=null,this.engine.setMatrices(this._uniforms[e],t))}setMatrix(e,t){this._cacheMatrix(e,t)&&(this.engine.setMatrices(this._uniforms[e],t.asArray())||(this._valueCache[e]=null))}setMatrix3x3(e,t){this._valueCache[e]=null,this.engine.setMatrix3x3(this._uniforms[e],t)}setMatrix2x2(e,t){this._valueCache[e]=null,this.engine.setMatrix2x2(this._uniforms[e],t)}setFloat(e,t){const i=this._valueCache[e];void 0!==i&&i===t||this.engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t)}setVector2(e,t){this._cacheFloat2(e,t.x,t.y)&&(this.engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null))}setFloat2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setFloat2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setVector3(e,t){this._cacheFloat3(e,t.x,t.y,t.z)&&(this.engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null))}setFloat3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setFloat3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setVector4(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setQuaternion(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setFloat4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setFloat4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setColor3(e,t){this._cacheFloat3(e,t.r,t.g,t.b)&&(this.engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null))}setColor4(e,t,i){this._cacheFloat4(e,t.r,t.g,t.b,i)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,i)||(this._valueCache[e]=null))}setDirectColor4(e,t){this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null))}_getVertexShaderCode(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null}_getFragmentShaderCode(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null}}const dt=new WeakMap,_t={_webGLVersion:2,cachedPipelines:{}};function ft(e){let t=dt.get(e);if(!t){if(!e)return _t;t={_webGLVersion:e.TEXTURE_BINDING_3D?2:1,_context:e,parallelShaderCompile:e.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},dt.set(e,t)}return t}function pt(e){dt.delete(e)}function gt(e,t,i,s,r,n){const a=ft(s);n||(n=a._createShaderProgramInjection??At);return n(e,It(t,"vertex",s,a._contextWasLost),It(i,"fragment",s,a._contextWasLost),s,r,a.validateShaderPrograms)}function mt(e,t,i,s,r,n=null,a){const o=ft(r);a||(a=o._createShaderProgramInjection??At);const h=o._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"";return a(e,yt(t,"vertex",s,h,r,o._contextWasLost),yt(i,"fragment",s,h,r,o._contextWasLost),r,n,o.validateShaderPrograms)}function Tt(e,t){const i=new ut,s=ft(e);return s.parallelShaderCompile&&(i.isParallelCompiled=!0),i.context=s._context,i}function At(e,t,i,s,r=null,n){const a=s.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");return s.attachShader(a,t),s.attachShader(a,i),s.linkProgram(a),e.context=s,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||bt(e,s,n),a}function Et(e,t,i){const s=e;if(s._isDisposed)return!1;const r=ft(t);return!!t.getProgramParameter(s.program,r.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(bt(s,t,i),!0)}function bt(e,t,i){const s=e.context,r=e.vertexShader,n=e.fragmentShader,a=e.program;if(!s.getProgramParameter(a,s.LINK_STATUS)){if(!t.getShaderParameter(r,t.COMPILE_STATUS)){const i=t.getShaderInfoLog(r);if(i)throw e.vertexCompilationError=i,new Error("VERTEX SHADER "+i)}if(!t.getShaderParameter(n,t.COMPILE_STATUS)){const i=t.getShaderInfoLog(n);if(i)throw e.fragmentCompilationError=i,new Error("FRAGMENT SHADER "+i)}const i=s.getProgramInfoLog(a);if(i)throw e.programLinkError=i,new Error(i)}if(i){s.validateProgram(a);if(!s.getProgramParameter(a,s.VALIDATE_STATUS)){const t=s.getProgramInfoLog(a);if(t)throw e.programValidationError=t,new Error(t)}}s.deleteShader(r),s.deleteShader(n),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)}function Rt(e,t,i,s,r,n,a,o,h,l="",c,u,d){const _=ft(e.context);u||(u=_.createRawShaderProgramInjection??gt),d||(d=_.createShaderProgramInjection??mt);const f=e;f.program=s?u(f,t,i,f.context,h):d(f,t,i,o,f.context,h),f.program.__SPECTOR_rebuildProgram=a,c()}function yt(e,t,i,s,r,n){return It(Ge(e,i,s),t,r,n)}function It(e,t,i,s){const r=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!r){let e=i.NO_ERROR,r=i.NO_ERROR;for(;(r=i.getError())!==i.NO_ERROR;)e=r;throw new Error(`Something went wrong while creating a gl ${t} shader object. gl error=${e}, gl isContextLost=${i.isContextLost()}, _contextWasLost=${s}`)}return i.shaderSource(r,e),i.compileShader(r),r}function Mt(e,t){t.useProgram(e)}function vt(e,t){const i=e;if(!i.isParallelCompiled)return void t(e);const s=i.onCompiled;i.onCompiled=()=>{s?.(),t(e)}}function xt(e){const t=e._name,i=e.context;if(t&&i){const e=ft(i),s=e.cachedPipelines[t];s?.dispose(),delete e.cachedPipelines[t]}}function St(e,t,i,s,r,n){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){return void s(Te(e))}if("source:"===e.substring(0,7))return void s(e.substring(7));if("base64:"===e.substring(0,7)){return void s(window.atob(e.substring(7)))}const a=ct.GetShadersStore(r);if(a[e+t+"Shader"])return void s(a[e+t+"Shader"]);if(i&&a[e+i+"Shader"])return void s(a[e+i+"Shader"]);let o;if(o="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:ct.GetShadersRepository(r)+e,!(n=n||He))throw new Error("loadFileInjection is not defined");n(o+"."+t.toLowerCase()+".fx",s)}class Ct{static get ShadersRepository(){return ct.ShadersRepository}static set ShadersRepository(e){ct.ShadersRepository=e}get isDisposed(){return this._isDisposed}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new A),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,s=null,r,n=null,a=null,o=null,h=null,l,c="",u=0,d){this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new A,this.onErrorObservable=new A,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this.name=e,this._key=c;const _=this._key.replace(/\r/g,"").replace(/\n/g,"|");let f;if(t.attributes){const e=t;if(this._engine=i,this._attributesNames=e.attributes,this._uniformsNames=e.uniformsNames.concat(e.samplers),this._samplerList=e.samplers.slice(),this.defines=e.defines,this.onError=e.onError,this.onCompiled=e.onCompiled,this._fallbacks=e.fallbacks,this._indexParameters=e.indexParameters,this._transformFeedbackVaryings=e.transformFeedbackVaryings||null,this._multiTarget=!!e.multiTarget,this._shaderLanguage=e.shaderLanguage??0,e.uniformBuffersNames){this._uniformBuffersNamesList=e.uniformBuffersNames.slice();for(let t=0;t<e.uniformBuffersNames.length;t++)this._uniformBuffersNames[e.uniformBuffersNames[t]]=t}this._processFinalCode=e.processFinalCode??null,this._processCodeAfterIncludes=e.processCodeAfterIncludes??void 0,f=e.existingPipelineContext}else this._engine=r,this.defines=null==n?"":n,this._uniformsNames=i.concat(s),this._samplerList=s?s.slice():[],this._attributesNames=t,this._uniformBuffersNamesList=[],this._shaderLanguage=u,this.onError=h,this.onCompiled=o,this._indexParameters=l,this._fallbacks=a;"WEBGL2"===this._engine.shaderPlatformName&&(f=function(e,t){return ft(t).cachedPipelines[e]}(_,this._engine._gl)??f),this._attributeLocationByName={},this.uniqueId=Ct._UniqueIdSeed++,f?(this._pipelineContext=f,this._pipelineContext.setEngine(this._engine),this._onRenderingStateCompiled(this._pipelineContext),this._pipelineContext.program&&(this._pipelineContext.program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this))):this._processShaderCodeAsync(null,!1,null,d)}async _processShaderCodeAsync(e=null,t=!1,i=null,s){s&&await s(),this._processingContext=i||this._engine._getShaderProcessingContext(this._shaderLanguage,!1);!function(e,t,i,s,r,n,a){let o,h;const l=pe()?n?.getHostDocument():null;o="string"==typeof t?t:t.vertexSource?"source:"+t.vertexSource:t.vertexElement?l?.getElementById(t.vertexElement)||t.vertexElement:t.vertex||t,h="string"==typeof t?t:t.fragmentSource?"source:"+t.fragmentSource:t.fragmentElement?l?.getElementById(t.fragmentElement)||t.fragmentElement:t.fragment||t;const c=[void 0,void 0],u=()=>{if(c[0]&&c[1]){e.isFragment=!0;const[o,h]=c;tt(h,e,((n,h)=>{a&&(a._fragmentSourceCodeBeforeMigration=h),i&&(n=i("fragment",n));const l=it(o,n,e);e=null;const c=function(e,t,i,s){return i?{vertexSourceCode:(1===s?"//":"")+"#define SHADER_NAME vertex:"+(i.vertexElement||i.vertex||i.spectorName||i)+"\n"+e,fragmentSourceCode:(1===s?"//":"")+"#define SHADER_NAME fragment:"+(i.fragmentElement||i.fragment||i.spectorName||i)+"\n"+t}:{vertexSourceCode:e,fragmentSourceCode:t}}(l.vertexCode,l.fragmentCode,t,r);s?.(c.vertexSourceCode,c.fragmentSourceCode)}),n)}};St(o,"Vertex","",(t=>{et(e),tt(t,e,((e,s)=>{a&&(a._rawVertexSourceCode=t,a._vertexSourceCodeBeforeMigration=s),i&&(e=i("vertex",e)),c[0]=e,u()}),n)}),r),St(h,"Fragment","Pixel",(e=>{a&&(a._rawFragmentSourceCode=e),c[1]=e,u()}),r)}({defines:this.defines.split("\n"),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:e??this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:ct.GetShadersRepository(this._shaderLanguage),includesShadersStore:ct.GetIncludesShadersStore(this._shaderLanguage),version:(100*this._engine.version).toString(),platformName:this._engine.shaderPlatformName,processingContext:this._processingContext,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:this._processCodeAfterIncludes},this.name,this._processFinalCode,((e,i)=>{this._vertexSourceCode=e,this._fragmentSourceCode=i,this._prepareEffect(t)}),this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch{return!1}}_isReadyInternal(){return!!this._engine.isDisposed||(!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady)}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}executeWhenCompiled(e){this.isReady()?e(this):(this.onCompileObservable.add((t=>{e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||this._checkIsReady(null))}_checkIsReady(e){((e,t,i,s=16,r=1e3)=>{const n=setInterval((()=>{try{e()&&(clearInterval(n),t())}catch(e){clearInterval(n),i?.(e)}(r-=s)<0&&(clearInterval(n),i?.(new Error("Timeout")))}),s)})((()=>this._isReadyInternal()||this._isDisposed),(()=>{}),(t=>{this._processCompilationErrors(t,e)}))}get vertexSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._pipelineContext?._getVertexShaderCode()??this._vertexSourceCode}get fragmentSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._pipelineContext?._getFragmentShaderCode()??this._fragmentSourceCode}get vertexSourceCodeBeforeMigration(){return this._vertexSourceCodeBeforeMigration}get fragmentSourceCodeBeforeMigration(){return this._fragmentSourceCodeBeforeMigration}get rawVertexSourceCode(){return this._rawVertexSourceCode}get rawFragmentSourceCode(){return this._rawFragmentSourceCode}getPipelineGenerationOptions(){return{platformName:this._engine.shaderPlatformName,shaderLanguage:this._shaderLanguage,shaderNameOrContent:this.name,key:this._key,defines:this.defines.split("\n"),addGlobalDefines:!1,extendedProcessingOptions:{indexParameters:this._indexParameters,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,supportsUniformBuffers:this._engine.supportsUniformBuffers},extendedCreatePipelineOptions:{transformFeedbackVaryings:this._transformFeedbackVaryings,createAsRaw:!(!this._vertexSourceCodeOverride||!this._fragmentSourceCodeOverride)}}}_rebuildProgram(e,t,i,s){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(e,t)=>{s&&s(t)},this.onCompiled=()=>{const e=this.getEngine().scenes;if(e)for(let t=0;t<e.length;t++)e[t].markAllMaterialsAsDirty(Ve.MATERIAL_AllDirtyFlag);this._pipelineContext._handlesSpectorRebuildCallback?.(i)},this._fallbacks=null,this._prepareEffect()}_onRenderingStateCompiled(e){if(this._pipelineContext=e,this._pipelineContext.setEngine(this._engine),this._attributes=[],this._pipelineContext._fillEffectInformation(this,this._uniformBuffersNames,this._uniformsNames,this._uniforms,this._samplerList,this._samplers,this._attributesNames,this._attributes),this._attributesNames)for(let e=0;e<this._attributesNames.length;e++){const t=this._attributesNames[e];this._attributeLocationByName[t]=this._attributes[e]}this._engine.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh(),Ct.AutomaticallyClearCodeCache&&this.clearCodeCache()}_prepareEffect(e=!1){const t=this._pipelineContext;this._isReady=!1;try{const i=!(!this._vertexSourceCodeOverride||!this._fragmentSourceCodeOverride),s=i?null:this.defines,r=i?this._vertexSourceCodeOverride:this._vertexSourceCode,n=i?this._fragmentSourceCodeOverride:this._fragmentSourceCode,a=this._engine;this._pipelineContext=((e,t,i,s)=>{try{const r=e.existingPipelineContext||t(e.shaderProcessingContext);return r._name=e.name,e.name&&e.context&&(ft(e.context).cachedPipelines[e.name]=r),i(r,e.vertex,e.fragment,!!e.createAsRaw,"","",e.rebuildRebind,e.defines,e.transformFeedbackVaryings,"",(()=>{s(r,(()=>{e.onRenderingStateCompiled?.(r)}))})),r}catch(e){throw Ae.Error("Error compiling effect"),e}})({existingPipelineContext:e?t:null,vertex:r,fragment:n,context:"WEBGL2"===a.shaderPlatformName?a._gl:void 0,rebuildRebind:(e,t,i,s)=>this._rebuildProgram(e,t,i,s),defines:s,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:i,parallelShaderCompile:a._caps.parallelShaderCompile,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:i=>{t&&!e&&this._engine._deletePipelineContext(t),i&&this._onRenderingStateCompiled(i)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContext.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(e){this._processCompilationErrors(e,t)}}_getShaderCodeAndErrorLine(e,t,i){const s=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/;let r=null;if(t&&e){const n=t.match(s);if(n&&2===n.length){const t=parseInt(n[1]),s=e.split("\n",-1);s.length>=t&&(r=`Offending line [${t}] in ${i?"fragment":"vertex"} code: ${s[t-1]}`)}}return[e,r]}_processCompilationErrors(e,t=null){this._compilationError=e.message;const i=this._attributesNames,s=this._fallbacks;if(Ae.Error("Unable to compile effect:"),Ae.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),Ae.Error("Attributes: "+i.map((function(e){return" "+e}))),Ae.Error("Defines:\n"+this.defines),Ct.LogShaderCodeOnCompilationError){let e=null,t=null,i=null;this._pipelineContext?._getVertexShaderCode()&&([i,e]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),i&&(Ae.Error("Vertex code:"),Ae.Error(i))),this._pipelineContext?._getFragmentShaderCode()&&([i,t]=this._getShaderCodeAndErrorLine(this._pipelineContext?._getFragmentShaderCode(),this._compilationError,!0),i&&(Ae.Error("Fragment code:"),Ae.Error(i))),e&&Ae.Error(e),t&&Ae.Error(t)}Ae.Error("Error: "+this._compilationError);const r=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)};t&&(this._pipelineContext=t,this._isReady=!0,r()),s?(this._pipelineContext=null,s.hasMoreFallbacks?(this._allFallbacksProcessed=!1,Ae.Error("Trying next fallback."),this.defines=s.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,r(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||r())}get isSupported(){return""===this._compilationError}_bindTexture(e,t){this._engine._bindTexture(this._samplers[e],t,e)}setTexture(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)}setTextureArray(e,t){const i=e+"Ex";if(-1===this._samplerList.indexOf(i+"0")){const s=this._samplerList.indexOf(e);for(let e=1;e<t.length;e++){const t=i+(e-1).toString();this._samplerList.splice(s+e,0,t)}let r=0;for(const e of this._samplerList)this._samplers[e]=r,r+=1}this._engine.setTextureArray(this._samplers[e],this._uniforms[e],t,e)}bindUniformBuffer(e,t){const i=this._uniformBuffersNames[t];void 0===i||Ct._BaseCache[i]===e&&this._engine._features.useUBOBindingCache||(Ct._BaseCache[i]=e,this._engine.bindUniformBufferBase(e,i,t))}bindUniformBlock(e,t){this._engine.bindUniformBlock(this._pipelineContext,e,t)}setInt(e,t){return this._pipelineContext.setInt(e,t),this}setInt2(e,t,i){return this._pipelineContext.setInt2(e,t,i),this}setInt3(e,t,i,s){return this._pipelineContext.setInt3(e,t,i,s),this}setInt4(e,t,i,s,r){return this._pipelineContext.setInt4(e,t,i,s,r),this}setIntArray(e,t){return this._pipelineContext.setIntArray(e,t),this}setIntArray2(e,t){return this._pipelineContext.setIntArray2(e,t),this}setIntArray3(e,t){return this._pipelineContext.setIntArray3(e,t),this}setIntArray4(e,t){return this._pipelineContext.setIntArray4(e,t),this}setUInt(e,t){return this._pipelineContext.setUInt(e,t),this}setUInt2(e,t,i){return this._pipelineContext.setUInt2(e,t,i),this}setUInt3(e,t,i,s){return this._pipelineContext.setUInt3(e,t,i,s),this}setUInt4(e,t,i,s,r){return this._pipelineContext.setUInt4(e,t,i,s,r),this}setUIntArray(e,t){return this._pipelineContext.setUIntArray(e,t),this}setUIntArray2(e,t){return this._pipelineContext.setUIntArray2(e,t),this}setUIntArray3(e,t){return this._pipelineContext.setUIntArray3(e,t),this}setUIntArray4(e,t){return this._pipelineContext.setUIntArray4(e,t),this}setFloatArray(e,t){return this._pipelineContext.setArray(e,t),this}setFloatArray2(e,t){return this._pipelineContext.setArray2(e,t),this}setFloatArray3(e,t){return this._pipelineContext.setArray3(e,t),this}setFloatArray4(e,t){return this._pipelineContext.setArray4(e,t),this}setArray(e,t){return this._pipelineContext.setArray(e,t),this}setArray2(e,t){return this._pipelineContext.setArray2(e,t),this}setArray3(e,t){return this._pipelineContext.setArray3(e,t),this}setArray4(e,t){return this._pipelineContext.setArray4(e,t),this}setMatrices(e,t){return this._pipelineContext.setMatrices(e,t),this}setMatrix(e,t){return this._pipelineContext.setMatrix(e,t),this}setMatrix3x3(e,t){return this._pipelineContext.setMatrix3x3(e,t),this}setMatrix2x2(e,t){return this._pipelineContext.setMatrix2x2(e,t),this}setFloat(e,t){return this._pipelineContext.setFloat(e,t),this}setBool(e,t){return this._pipelineContext.setInt(e,t?1:0),this}setVector2(e,t){return this._pipelineContext.setVector2(e,t),this}setFloat2(e,t,i){return this._pipelineContext.setFloat2(e,t,i),this}setVector3(e,t){return this._pipelineContext.setVector3(e,t),this}setFloat3(e,t,i,s){return this._pipelineContext.setFloat3(e,t,i,s),this}setVector4(e,t){return this._pipelineContext.setVector4(e,t),this}setQuaternion(e,t){return this._pipelineContext.setQuaternion(e,t),this}setFloat4(e,t,i,s,r){return this._pipelineContext.setFloat4(e,t,i,s,r),this}setColor3(e,t){return this._pipelineContext.setColor3(e,t),this}setColor4(e,t,i){return this._pipelineContext.setColor4(e,t,i),this}setDirectColor4(e,t){return this._pipelineContext.setDirectColor4(e,t),this}clearCodeCache(){this._vertexSourceCode="",this._fragmentSourceCode="",this._fragmentSourceCodeBeforeMigration="",this._vertexSourceCodeBeforeMigration=""}dispose(e=!1){e?this._refCount=0:this._refCount--,this._refCount>0||this._isDisposed||(this._pipelineContext&&xt(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,s=0){t&&(ct.GetShadersStore(s)[`${e}PixelShader`]=t),i&&(ct.GetShadersStore(s)[`${e}VertexShader`]=i)}static ResetCache(){Ct._BaseCache={}}}Ct.LogShaderCodeOnCompilationError=!0,Ct.AutomaticallyClearCodeCache=!1,Ct._UniqueIdSeed=0,Ct._BaseCache={},Ct.ShadersStore=ct.ShadersStore,Ct.IncludesShadersStore=ct.IncludesShadersStore;class Pt{constructor(e=!0){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,e&&this.reset()}get isDirty(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty}get zOffset(){return this._zOffset}set zOffset(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)}get zOffsetUnits(){return this._zOffsetUnits}set zOffsetUnits(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0)}get cullFace(){return this._cullFace}set cullFace(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)}get cull(){return this._cull}set cull(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)}get depthFunc(){return this._depthFunc}set depthFunc(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)}get depthMask(){return this._depthMask}set depthMask(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)}get frontFace(){return this._frontFace}set frontFace(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)}reset(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,this._isFrontFaceDirty=!1}apply(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset||this.zOffsetUnits?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,this.zOffsetUnits)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))}}class Ot{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){this.stencilMaterial=void 0,this.stencilGlobal?.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0}apply(e){if(!e)return;const t=!this.useStencilGlobalOnly&&!!this.stencilMaterial?.enabled;this.enabled=t?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=t?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.func,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),this._isStencilOpDirty=!1))}}class Dt{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=Dt.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=Dt.KEEP,this.opDepthFail=Dt.KEEP,this.opStencilDepthPass=Dt.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}}Dt.ALWAYS=Ve.ALWAYS,Dt.KEEP=Ve.KEEP,Dt.REPLACE=Ve.REPLACE;class Lt{constructor(){this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._alphaBlend}set alphaBlend(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,i,s){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===s||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=s,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,i,s){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===s||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=s,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))}}class Ft{get wrapU(){return this._cachedWrapU}set wrapU(e){this._cachedWrapU=e}get wrapV(){return this._cachedWrapV}set wrapV(e){this._cachedWrapV=e}get wrapR(){return this._cachedWrapR}set wrapR(e){this._cachedWrapR=e}get anisotropicFilteringLevel(){return this._cachedAnisotropicFilteringLevel}set anisotropicFilteringLevel(e){this._cachedAnisotropicFilteringLevel=e}get comparisonFunction(){return this._comparisonFunction}set comparisonFunction(e){this._comparisonFunction=e}get useMipMaps(){return this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}constructor(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}setParameters(e=Ve.TEXTURE_WRAP_ADDRESSMODE,t=Ve.TEXTURE_WRAP_ADDRESSMODE,i=Ve.TEXTURE_WRAP_ADDRESSMODE,s=1,r=Ve.TEXTURE_BILINEAR_SAMPLINGMODE,n=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=s,this.samplingMode=r,this._comparisonFunction=n,this}compareSampler(e){return this._cachedWrapU===e._cachedWrapU&&this._cachedWrapV===e._cachedWrapV&&this._cachedWrapR===e._cachedWrapR&&this._cachedAnisotropicFilteringLevel===e._cachedAnisotropicFilteringLevel&&this.samplingMode===e.samplingMode&&this._comparisonFunction===e._comparisonFunction&&this._useMipMaps===e._useMipMaps}}var wt;function Nt(e){return e===Ve.TEXTUREFORMAT_DEPTH24_STENCIL8||e===Ve.TEXTUREFORMAT_DEPTH32_FLOAT||e===Ve.TEXTUREFORMAT_DEPTH16||e===Ve.TEXTUREFORMAT_DEPTH24||e===Ve.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||e===Ve.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8||e===Ve.TEXTUREFORMAT_STENCIL8}function Bt(e){switch(e){case Ve.TEXTUREFORMAT_DEPTH24_STENCIL8:case Ve.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8:case Ve.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8:case Ve.TEXTUREFORMAT_DEPTH32_FLOAT:case Ve.TEXTUREFORMAT_DEPTH24:return Ve.TEXTURETYPE_FLOAT;case Ve.TEXTUREFORMAT_DEPTH16:return Ve.TEXTURETYPE_UNSIGNED_SHORT;case Ve.TEXTUREFORMAT_STENCIL8:return Ve.TEXTURETYPE_UNSIGNED_BYTE}return Ve.TEXTURETYPE_UNSIGNED_BYTE}function Ut(e){return e===Ve.TEXTUREFORMAT_DEPTH24_STENCIL8||e===Ve.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||e===Ve.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8||e===Ve.TEXTUREFORMAT_STENCIL8}!function(e){e[e.Unknown=0]="Unknown",e[e.Url=1]="Url",e[e.Temp=2]="Temp",e[e.Raw=3]="Raw",e[e.Dynamic=4]="Dynamic",e[e.RenderTarget=5]="RenderTarget",e[e.MultiRenderTarget=6]="MultiRenderTarget",e[e.Cube=7]="Cube",e[e.CubeRaw=8]="CubeRaw",e[e.CubePrefiltered=9]="CubePrefiltered",e[e.Raw3D=10]="Raw3D",e[e.Raw2DArray=11]="Raw2DArray",e[e.DepthStencil=12]="DepthStencil",e[e.CubeRawRGBD=13]="CubeRawRGBD",e[e.Depth=14]="Depth"}(wt||(wt={}));class kt extends Ft{get useMipMaps(){return this.generateMipMaps}set useMipMaps(e){this.generateMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,i=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new A,this.onErrorObservable=new A,this.onRebuildCallback=null,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=0,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._cachedCoordinatesMode=null,this._isDisabled=!1,this._compression=null,this._sphericalPolynomial=null,this._sphericalPolynomialPromise=null,this._sphericalPolynomialComputed=!1,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._useSRGBBuffer=!1,this._creationFlags=0,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._hardwareTexture=null,this._maxLodLevel=null,this._references=1,this._gammaSpace=null,this._premulAlpha=!1,this._dynamicTextureSource=null,this._autoMSAAManagement=!1,this._engine=e,this._source=t,this._uniqueId=kt._Counter++,i||(this._hardwareTexture=e._createHardwareTexture())}incrementReferences(){this._references++}updateSize(e,t,i=1){this._engine.updateTextureDimensions(this,e,t,i),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i}_rebuild(){if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){const e=this.onRebuildCallback(this),t=t=>{t._swapAndDie(this,!1),this.isReady=e.isReady};return void(e.isAsync?e.proxy.then(t):t(e.proxy))}let e;switch(this.source){case 2:break;case 1:return void(e=this._engine.createTexture(this._originalUrl??this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(e=>{e._swapAndDie(this,!1),this.isReady=!0}),null,this._buffer,void 0,this.format,this._extension,void 0,void 0,void 0,this._useSRGBBuffer));case 3:e=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type,this._creationFlags,this._useSRGBBuffer),e._swapAndDie(this,!1),this.isReady=!0;break;case 10:e=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 11:e=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 4:e=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode),e._swapAndDie(this,!1),this._dynamicTextureSource&&this._engine.updateDynamicTexture(this,this._dynamicTextureSource,this.invertY,this._premulAlpha,this.format,!0);break;case 7:return void(e=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(()=>{e._swapAndDie(this,!1),this.isReady=!0}),null,this.format,this._extension,!1,0,0,null,void 0,this._useSRGBBuffer,ArrayBuffer.isView(this._buffer)?this._buffer:null));case 8:e=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this._originalFormat??this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),e._swapAndDie(this,!1),this.isReady=!0;break;case 13:return;case 9:return e=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(e=>{e&&e._swapAndDie(this,!1),this.isReady=!0}),null,this.format,this._extension),void(e._sphericalPolynomial=this._sphericalPolynomial)}}_swapAndDie(e,t=!0){this._hardwareTexture?.setUsage(e._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),e._hardwareTexture=this._hardwareTexture,t&&(e._isRGBD=this._isRGBD),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);const i=this._engine.getLoadedTexturesCache();let s=i.indexOf(this);-1!==s&&i.splice(s,1),s=i.indexOf(e),-1===s&&i.push(e)}dispose(){this._references--,this.onLoadedObservable.clear(),this.onErrorObservable.clear(),0===this._references&&(this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}}kt._Counter=0;const Vt=new Map;function zt(e,t){(function(e){return Vt.delete(e)})(e)&&Ae.Warn(`Extension with the name '${name}' already exists`),Vt.set(e,t)}function Gt(e,t){"image/ktx"!==t&&"image/ktx2"!==t||(e=".ktx"),Vt.has(e)||(e.endsWith(".ies")&&zt(".ies",(()=>import("./iesTextureLoader-WrbecGoP.esm.min.js").then((e=>new e._IESTextureLoader)))),e.endsWith(".dds")&&zt(".dds",(()=>import("./ddsTextureLoader-D38C-6i9.esm.min.js").then((e=>new e._DDSTextureLoader)))),e.endsWith(".basis")&&zt(".basis",(()=>import("./basisTextureLoader-BJrbh335.esm.min.js").then((e=>new e._BasisTextureLoader)))),e.endsWith(".env")&&zt(".env",(()=>import("./envTextureLoader-DFF091wY.esm.min.js").then((e=>new e._ENVTextureLoader)))),e.endsWith(".hdr")&&zt(".hdr",(()=>import("./hdrTextureLoader-CVa1eQ0k.esm.min.js").then((e=>new e._HDRTextureLoader)))),(e.endsWith(".ktx")||e.endsWith(".ktx2"))&&(zt(".ktx",(()=>import("./ktxTextureLoader-DdTyaRVu.esm.min.js").then((e=>new e._KTXTextureLoader)))),zt(".ktx2",(()=>import("./ktxTextureLoader-DdTyaRVu.esm.min.js").then((e=>new e._KTXTextureLoader))))),e.endsWith(".tga")&&zt(".tga",(()=>import("./tgaTextureLoader-CKRrtbo-.esm.min.js").then((e=>new e._TGATextureLoader)))),e.endsWith(".exr")&&zt(".exr",(()=>import("./exrTextureLoader-DqVtC6Vz.esm.min.js").then((e=>new e._ExrTextureLoader)))));const i=Vt.get(e);return i?Promise.resolve(i(t)):null}function Ht(e,t){if(pe()){const{requestAnimationFrame:i}=t||window;if("function"==typeof i)return i(e)}else if("function"==typeof requestAnimationFrame)return requestAnimationFrame(e);return setTimeout(e,16)}class Wt{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,this._depthCullingState.depthFunc=e?Ve.GEQUAL:Ve.LEQUAL)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}getColorWrite(){return this._colorWrite}get depthCullingState(){return this._depthCullingState}get alphaState(){return this._alphaState}get stencilState(){return this._stencilState}get stencilStateComposer(){return this._stencilStateComposer}_getGlobalDefines(e){if(e)return this.isNDCHalfZRange?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,this.useReverseDepthBuffer?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(this.useExactSrgbConversions?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);{let e="";return this.isNDCHalfZRange&&(e+="#define IS_NDC_HALF_ZRANGE"),this.useReverseDepthBuffer&&(e&&(e+="\n"),e+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(e&&(e+="\n"),e+="#define USE_EXACT_SRGB_CONVERSIONS"),e}}_rebuildInternalTextures(){const e=this._internalTexturesCache.slice();for(const t of e)t._rebuild()}_rebuildRenderTargetWrappers(){const e=this._renderTargetWrapperCache.slice();for(const t of e)t._rebuild()}_rebuildEffects(){for(const e in this._compiledEffects){const t=this._compiledEffects[e];t._pipelineContext=null,t._prepareEffect()}Ct.ResetCache()}_rebuildGraphicsResources(){this.wipeCaches(!0),this._rebuildEffects(),this._rebuildComputeEffects?.(),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){Ae.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout((async()=>{this._clearEmptyResources();const t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,s=this._depthCullingState.depthMask,r=this._stencilState.stencilTest;await e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=s,this._stencilState.stencilTest=r,this._flagContextRestored()}),0)}get isDisposed(){return this._isDisposed}get snapshotRendering(){return!1}set snapshotRendering(e){}get snapshotRenderingMode(){return Ve.SNAPSHOTRENDERING_STANDARD}set snapshotRenderingMode(e){}getClassName(){return"AbstractEngine"}get emptyTexture(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,Ve.TEXTUREFORMAT_RGBA,!1,!1,Ve.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture}get emptyTexture3D(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,Ve.TEXTUREFORMAT_RGBA,!1,!1,Ve.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D}get emptyTexture2DArray(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,Ve.TEXTUREFORMAT_RGBA,!1,!1,Ve.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray}get emptyCubeTexture(){if(!this._emptyCubeTexture){const e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,Ve.TEXTUREFORMAT_RGBA,Ve.TEXTURETYPE_UNSIGNED_BYTE,!1,!1,Ve.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture}get activeRenderLoops(){return this._activeRenderLoops}stopRenderLoop(e){if(!e)return this._activeRenderLoops.length=0,void this._cancelFrame();const t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),0==this._activeRenderLoops.length&&this._cancelFrame())}_cancelFrame(){if(0!==this._frameHandler){const e=this._frameHandler;if(this._frameHandler=0,pe()){const{cancelAnimationFrame:t}=this.getHostWindow()||window;if("function"==typeof t)return t(e)}else if("function"==typeof cancelAnimationFrame)return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}_renderLoop(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&0===this._frameHandler&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e<this._activeRenderLoops.length;e++){(0,this._activeRenderLoops[e])()}}_renderViews(){return!1}_queueNewFrame(e,t){return Ht(e,t)}runRenderLoop(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),1===this._activeRenderLoops.length&&0===this._frameHandler&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))}getDepthBuffer(){return this._depthCullingState.depthTest}setDepthBuffer(e){this._depthCullingState.depthTest=e}setZOffset(e){this._depthCullingState.zOffset=this.useReverseDepthBuffer?-e:e}getZOffset(){const e=this._depthCullingState.zOffset;return this.useReverseDepthBuffer?-e:e}setZOffsetUnits(e){this._depthCullingState.zOffsetUnits=this.useReverseDepthBuffer?-e:e}getZOffsetUnits(){const e=this._depthCullingState.zOffsetUnits;return this.useReverseDepthBuffer?-e:e}getHostWindow(){return pe()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null}get compatibilityMode(){return this._compatibilityMode}set compatibilityMode(e){this._compatibilityMode=!0}_rebuildTextures(){for(const e of this.scenes)e._rebuildTextures();for(const e of this._virtualScenes)e._rebuildTextures()}_releaseRenderTargetWrapper(e){const t=this._renderTargetWrapperCache.indexOf(e);-1!==t&&this._renderTargetWrapperCache.splice(t,1)}get currentViewport(){return this._cachedViewport}setViewport(e,t,i){const s=t||this.getRenderWidth(),r=i||this.getRenderHeight(),n=e.x||0,a=e.y||0;this._cachedViewport=e,this._viewport(n*s,a*r,s*e.width,r*e.height)}createCanvasImage(){return document.createElement("img")}get description(){let e=this.name+this.version;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e}_createTextureBase(e,t,i,s,r=Ve.TEXTURE_TRILINEAR_SAMPLINGMODE,n=null,a=null,o,h,l=null,c=null,u=null,d=null,_,f,p){const g="data:"===(e=e||"").substr(0,5),m="blob:"===e.substr(0,5),T=g&&-1!==e.indexOf(";base64,"),A=c||new kt(this,1);A!==c&&(A.label=e.substring(0,60));const E=e;!this._transformTextureUrl||T||c||l||(e=this._transformTextureUrl(e)),E!==e&&(A._originalUrl=E);const b=e.lastIndexOf(".");let R=d||(b>-1?e.substring(b).toLowerCase():"");R.indexOf("?")>-1&&(R=R.split("?")[0]);const y=Gt(R,_);s&&s.addPendingData(A),A.url=e,A.generateMipMaps=!t,A.samplingMode=r,A.invertY=i,A._useSRGBBuffer=this._getUseSRGBBuffer(!!p,t),this._doNotHandleContextLost||(A._buffer=l);let I=null;n&&!c&&(I=A.onLoadedObservable.add(n)),c||this._internalTexturesCache.push(A);const M=(i,c)=>{s&&s.removePendingData(A),e===E?(I&&A.onLoadedObservable.remove(I),O.UseFallbackTexture&&e!==O.FallbackTexture&&this._createTextureBase(O.FallbackTexture,t,A.invertY,s,r,null,a,o,h,l,A),i=(i||"Unknown error")+(O.UseFallbackTexture?" - Fallback texture was used":""),A.onErrorObservable.notifyObservers({message:i,exception:c}),a&&a(i,c)):(Ae.Warn(`Failed to load ${e}, falling back to ${E}`),this._createTextureBase(E,t,A.invertY,s,r,n,a,o,h,l,A,u,d,_,f,p))};if(y){const t=async e=>{(await y).loadData(e,A,((e,t,i,n,a,h)=>{h?M("TextureLoader failed to load data"):o(A,R,s,{width:e,height:t},A.invertY,!i,n,(()=>(a(),!1)),r)}),f)};l?l instanceof ArrayBuffer?t(new Uint8Array(l)):ArrayBuffer.isView(l)?t(l):a&&a("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,(e=>t(new Uint8Array(e))),void 0,s?s.offlineProvider:void 0,!0,((e,t)=>{M("Unable to load "+(e&&e.responseURL,t))}))}else{const i=e=>{m&&!this._doNotHandleContextLost&&(A._buffer=e),o(A,R,s,e,A.invertY,t,!1,h,r)};!g||T?l&&("string"==typeof l.decoding||l.close)?i(l):Wt._FileToolsLoadImage(e||"",i,M,s?s.offlineProvider:null,_,A.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):"string"==typeof l||l instanceof ArrayBuffer||ArrayBuffer.isView(l)||l instanceof Blob?Wt._FileToolsLoadImage(l,i,M,s?s.offlineProvider:null,_,A.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):l&&i(l)}return A}_rebuildBuffers(){for(const e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:me()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(const e in this._boundTexturesCache)Object.prototype.hasOwnProperty.call(this._boundTexturesCache,e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1}get name(){return this._name}set name(e){this._name=e}static get NpmPackage(){return"babylonjs@7.40.2"}static get Version(){return"7.40.2"}getRenderingCanvas(){return this._renderingCanvas}getAudioContext(){return this._audioContext}getAudioDestination(){return this._audioDestination}setHardwareScalingLevel(e){this._hardwareScalingLevel=e,this.resize()}getHardwareScalingLevel(){return this._hardwareScalingLevel}get doNotHandleContextLost(){return this._doNotHandleContextLost}set doNotHandleContextLost(e){this._doNotHandleContextLost=e}get isStencilEnable(){return this._isStencilEnable}getCreationOptions(){return this._creationOptions}constructor(e,t,i){this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new Pt,this._stencilStateComposer=new Ot,this._stencilState=new Dt,this._alphaState=new Lt,this._alphaMode=Ve.ALPHA_ADD,this._alphaEquation=Ve.ALPHA_DISABLE,this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this.onCanvasBlurObservable=new A,this.onCanvasFocusObservable=new A,this.onNewSceneAddedObservable=new A,this.onResizeObservable=new A,this.onCanvasPointerOutObservable=new A,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._frameId=0,this.hostInformation={isMobile:!1},this.isFullscreen=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.disableContextMenu=!0,this.currentRenderPassId=Ve.RENDERPASS_MAIN,this.isPointerLock=!1,this.postProcesses=[],this.canvasTabIndex=1,this._contextWasLost=!1,this._useReverseDepthBuffer=!1,this.isNDCHalfZRange=!1,this.hasOriginBottomLeft=!0,this._renderTargetWrapperCache=new Array,this._compiledEffects={},this._isDisposed=!1,this.scenes=[],this._virtualScenes=new Array,this.onBeforeTextureInitObservable=new A,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=()=>this._renderLoop(),this.onBeforeShaderCompilationObservable=new A,this.onAfterShaderCompilationObservable=new A,this.onBeginFrameObservable=new A,this.onEndFrameObservable=new A,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new A,this.onContextRestoredObservable=new A,this._name="",this.premultipliedAlpha=!0,this.adaptToDeviceRatio=!1,this._lastDevicePixelRatio=1,this._doNotHandleContextLost=!1,this.cullBackFaces=null,this._renderPassNames=["main"],this._fps=60,this._deltaTime=0,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._timeStep=1/60,this.onDisposeObservable=new A,O.Instances.push(this),this.startTime=Re.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,P.SetMatrixPrecision(!!t.useHighPrecisionMatrix),ge()&&navigator.userAgent&&(this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),this.adaptToDeviceRatio=i??!1,t.antialias=e??t.antialias,t.deterministicLockstep=t.deterministicLockstep??!1,t.lockstepMaxSteps=t.lockstepMaxSteps??4,t.timeStep=t.timeStep??1/60,t.audioEngine=t.audioEngine??!0,t.stencil=t.stencil??!0,this._audioContext=t.audioEngineOptions?.audioContext??null,this._audioDestination=t.audioEngineOptions?.audioDestination??null,this.premultipliedAlpha=t.premultipliedAlpha??!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=t.useExactSrgbConversions??!1;const s=pe()&&window.devicePixelRatio||1,r=t.limitDeviceRatio||s;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(r,s):1,this._lastDevicePixelRatio=s,this._creationOptions=t}resize(e=!1){let t,i;if(this.adaptToDeviceRatio){const e=pe()&&window.devicePixelRatio||1,t=this._lastDevicePixelRatio/e;this._lastDevicePixelRatio=e,this._hardwareScalingLevel*=t}if(pe()&&me())if(this._renderingCanvas){const e=this._renderingCanvas.getBoundingClientRect?this._renderingCanvas.getBoundingClientRect():{width:this._renderingCanvas.width*this._hardwareScalingLevel,height:this._renderingCanvas.height*this._hardwareScalingLevel};t=this._renderingCanvas.clientWidth||e.width||this._renderingCanvas.width||100,i=this._renderingCanvas.clientHeight||e.height||this._renderingCanvas.height||100}else t=window.innerWidth,i=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,i=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel,e)}setSize(e,t,i=!1){if(!this._renderingCanvas)return!1;if(e|=0,t|=0,!i&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t)return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let e=0;e<this.scenes.length;e++){const t=this.scenes[e];for(let e=0;e<t.cameras.length;e++){t.cameras[e]._currentRenderId=0}}this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0}createRawTexture(e,t,i,s,r,n,a,o,h,l,c){throw te("engine.rawTexture")}createRawCubeTexture(e,t,i,s,r,n,a,o){throw te("engine.rawTexture")}createRawTexture3D(e,t,i,s,r,n,a,o,h,l,c){throw te("engine.rawTexture")}createRawTexture2DArray(e,t,i,s,r,n,a,o,h,l,c){throw te("engine.rawTexture")}_sharedInit(e){this._renderingCanvas=e}_setupMobileChecks(){navigator&&navigator.userAgent&&(this._checkForMobile=()=>{const e=navigator.userAgent;this.hostInformation.isMobile=-1!==e.indexOf("Mobile")||-1!==e.indexOf("Mac")&&me()&&"ontouchend"in document},this._checkForMobile(),pe()&&window.addEventListener("resize",this._checkForMobile))}createVideoElement(e){return document.createElement("video")}_reportDrawCall(e=1){this._drawCalls?.addCount(e,!1)}getFps(){return this._fps}getDeltaTime(){return this._deltaTime}isDeterministicLockStep(){return this._deterministicLockstep}getLockstepMaxSteps(){return this._lockstepMaxSteps}getTimeStep(){return 1e3*this._timeStep}_createImageBitmapFromSource(e,t){throw new Error("createImageBitmapFromSource is not implemented")}createImageBitmap(e,t){return createImageBitmap(e,t)}resizeImageBitmap(e,t,i){throw new Error("resizeImageBitmap is not implemented")}getFontOffset(e){throw new Error("getFontOffset is not implemented")}static _CreateCanvas(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);const i=document.createElement("canvas");return i.width=e,i.height=t,i}createCanvas(e,t){return Wt._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,s,r,n){throw te("FileTools")}_loadFile(e,t,i,s,r,n){const a=He(e,t,i,s,r,n);return this._activeRequests.push(a),a.onCompleteObservable.add((()=>{const e=this._activeRequests.indexOf(a);-1!==e&&this._activeRequests.splice(e,1)})),a}static _FileToolsLoadFile(e,t,i,s,r,n){if(ze.loadFile)return ze.loadFile(e,t,i,s,r,n);throw te("FileTools")}dispose(){for(this.releaseEffects(),this._isDisposed=!0,this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._renderingCanvas=null,this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.scenes.length;)this.scenes[0].dispose();for(;this._virtualScenes.length;)this._virtualScenes[0].dispose();this.releaseComputeEffects?.(),Ct.ResetCache();for(const e of this._activeRequests)e.abort();this._boundRenderFunction=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onNewSceneAddedObservable.clear(),pe()&&window.removeEventListener("resize",this._checkForMobile);const e=O.Instances.indexOf(this);e>=0&&O.Instances.splice(e,1),O.Instances.length||(O.OnEnginesDisposedObservable.notifyObservers(this),O.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw te("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i<O.Instances.length;i++){const s=O.Instances[i];for(let i=0;i<s.scenes.length;i++)s.scenes[i].markAllMaterialsAsDirty(e,t)}}}Wt._RenderPassIdCounter=0,Wt._RescalePostProcessFactory=null,Wt.CollisionsEpsilon=.001,Wt.QueueNewFrame=Ht;const Kt=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class Yt extends xe{constructor(e,t){super(e,ve.LoadFileError),this.name="LoadFileError",Me._setPrototypeOf(this,Yt.prototype),t instanceof ye?this.request=t:this.file=t}}class Xt extends xe{constructor(e,t){super(e,ve.RequestFileError),this.request=t,this.name="RequestFileError",Me._setPrototypeOf(this,Xt.prototype)}}class Qt extends xe{constructor(e,t){super(e,ve.ReadFileError),this.file=t,this.name="ReadFileError",Me._setPrototypeOf(this,Qt.prototype)}}const qt={DefaultRetryStrategy:class{static ExponentialBackoff(e=3,t=500){return(i,s,r)=>0!==s.status||r>=e||-1!==i.indexOf("file:")?-1:Math.pow(2,r)*t}}.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:e=>e,ScriptBaseUrl:"",ScriptPreprocessUrl:e=>e,CleanUrl:e=>e=e.replace(/#/gm,"%23")},jt=(e,t)=>{if((!e||0!==e.indexOf("data:"))&&qt.CorsBehavior)if("string"==typeof qt.CorsBehavior||qt.CorsBehavior instanceof String)t.crossOrigin=qt.CorsBehavior;else{const i=qt.CorsBehavior(e);i&&(t.crossOrigin=i)}},Zt=(e,t,i,s,r="",n)=>{const a=O.LastCreatedEngine;if("undefined"==typeof HTMLImageElement&&!a?._features.forceBitmapOverHTMLImageElement)return i("LoadImage is only supported in web or BabylonNative environments."),null;let o,h=!1;e instanceof ArrayBuffer||ArrayBuffer.isView(e)?"undefined"!=typeof Blob&&"undefined"!=typeof URL?(o=URL.createObjectURL(new Blob([e],{type:r})),h=!0):o=`data:${r};base64,`+Ce(e):e instanceof Blob?(o=URL.createObjectURL(e),h=!0):(o=qt.CleanUrl(e),o=qt.PreprocessUrl(o));const l=t=>{if(i){const s=o||e.toString();i(`Error while trying to load image: ${0===s.indexOf("http")||s.length<=128?s:s.slice(0,128)+"..."}`,t)}};if(a?._features.forceBitmapOverHTMLImageElement)return $t(o,(s=>{a.createImageBitmap(new Blob([s],{type:r}),{premultiplyAlpha:"none",...n}).then((e=>{t(e),h&&URL.revokeObjectURL(o)})).catch((t=>{i&&i("Error while trying to load image: "+e,t)}))}),void 0,s||void 0,!0,((e,t)=>{l(t)})),null;const c=new Image;jt(o,c);const u=[],d=()=>{u.forEach((e=>{e.target.removeEventListener(e.name,e.handler)})),u.length=0};u.push({target:c,name:"load",handler:()=>{d(),t(c),h&&c.src&&URL.revokeObjectURL(c.src)}}),u.push({target:c,name:"error",handler:e=>{d(),l(e),h&&c.src&&URL.revokeObjectURL(c.src)}}),u.push({target:document,name:"securitypolicyviolation",handler:e=>{if(e.blockedURI!==c.src||"report"===e.disposition)return;d();const t=new Error(`CSP violation of policy ${e.effectiveDirective} ${e.blockedURI}. Current policy is ${e.originalPolicy}`);O.UseFallbackTexture=!1,l(t),h&&c.src&&URL.revokeObjectURL(c.src),c.src=""}}),u.forEach((e=>{e.target.addEventListener(e.name,e.handler)}));const _="blob:"===o.substring(0,5),f="data:"===o.substring(0,5),p=()=>{_||f||!ye.IsCustomRequestAvailable?c.src=o:$t(o,((e,t,i)=>{const s=new Blob([e],{type:!r&&i?i:r}),n=URL.createObjectURL(s);h=!0,c.src=n}),void 0,s||void 0,!0,((e,t)=>{l(t)}))},g=()=>{s&&s.loadImage(o,c)};if(!_&&!f&&s&&s.enableTexturesOffline)s.open(g,p);else{if(-1!==o.indexOf("file:")){const e=decodeURIComponent(o.substring(5).toLowerCase());if(Ie.FilesToLoad[e]&&"undefined"!=typeof URL){try{let t;try{t=URL.createObjectURL(Ie.FilesToLoad[e])}catch(i){t=URL.createObjectURL(Ie.FilesToLoad[e])}c.src=t,h=!0}catch(e){c.src=""}return c}}p()}return c},Jt=(e,t,i,s,r)=>{const n=new FileReader,a={onCompleteObservable:new A,abort:()=>n.abort()};return n.onloadend=()=>a.onCompleteObservable.notifyObservers(a),r&&(n.onerror=()=>{r(new Qt(`Unable to read ${e.name}`,e))}),n.onload=e=>{t(e.target.result)},i&&(n.onprogress=i),s?n.readAsArrayBuffer(e):n.readAsText(e),a},$t=(e,t,i,s,r,n,a)=>{if(e.name)return Jt(e,t,i,r,n?e=>{n(void 0,e)}:void 0);const o=e;if(-1!==o.indexOf("file:")){let e=decodeURIComponent(o.substring(5).toLowerCase());0===e.indexOf("./")&&(e=e.substring(2));const s=Ie.FilesToLoad[e];if(s)return Jt(s,t,i,r,n?e=>n(void 0,new Yt(e.message,e.file)):void 0)}const{match:h,type:l}=si(o);if(h){const e={onCompleteObservable:new A,abort:()=>()=>{}};try{const e=r?ri(o):ni(o);t(e,void 0,l)}catch(e){n?n(void 0,e):Ae.Error(e.message||"Failed to parse the Data URL")}return lt.SetImmediate((()=>{e.onCompleteObservable.notifyObservers(e)})),e}return ei(o,((e,i)=>{t(e,i?.responseURL,i?.getResponseHeader("content-type"))}),i,s,r,n?e=>{n(e.request,new Yt(e.message,e.request))}:void 0,a)},ei=(e,t,i,s,r,n,a)=>{e=qt.CleanUrl(e),e=qt.PreprocessUrl(e);const o=qt.BaseUrl+e;let h=!1;const l={onCompleteObservable:new A,abort:()=>h=!0},c=()=>{let e,s=new ye,c=null;const u=()=>{s&&(i&&s.removeEventListener("progress",i),e&&s.removeEventListener("readystatechange",e),s.removeEventListener("loadend",d))};let d=()=>{u(),l.onCompleteObservable.notifyObservers(l),l.onCompleteObservable.clear(),i=void 0,e=null,d=null,n=void 0,a=void 0,t=void 0};l.abort=()=>{h=!0,d&&d(),s&&s.readyState!==(XMLHttpRequest.DONE||4)&&s.abort(),null!==c&&(clearTimeout(c),c=null),s=null};const _=e=>{const t=e.message||"Unknown error";n&&s?n(new Xt(t,s)):Ae.Error(t)},f=l=>{if(s){if(s.open("GET",o),a)try{a(s)}catch(e){return void _(e)}r&&(s.responseType="arraybuffer"),i&&s.addEventListener("progress",i),d&&s.addEventListener("loadend",d),e=()=>{if(!h&&s&&s.readyState===(XMLHttpRequest.DONE||4)){if(e&&s.removeEventListener("readystatechange",e),s.status>=200&&s.status<300||0===s.status&&(!pe()||ti())){try{t&&t(r?s.response:s.responseText,s)}catch(e){_(e)}return}const i=qt.DefaultRetryStrategy;if(i){const e=i(o,s,l);if(-1!==e)return u(),s=new ye,void(c=setTimeout((()=>f(l+1)),e))}const a=new Xt("Error status: "+s.status+" "+s.statusText+" - Unable to load "+o,s);n&&n(a)}},s.addEventListener("readystatechange",e),s.send()}};f(0)};if(s&&s.enableSceneOffline){const a=e=>{e&&e.status>400?n&&n(e):c()},o=()=>{s&&s.loadFile(qt.BaseUrl+e,(e=>{!h&&t&&t(e),l.onCompleteObservable.notifyObservers(l)}),i?e=>{!h&&i&&i(e)}:void 0,a,r)};s.open(o,a)}else c();return l},ti=()=>"undefined"!=typeof location&&"file:"===location.protocol,ii=e=>Kt.test(e),si=e=>{const t=Kt.exec(e);if(null===t||0===t.length)return{match:!1,type:""};return{match:!0,type:t[0].replace("data:","").replace("base64,","")}};function ri(e){return(e=>{const t=Pe(e),i=t.length,s=new Uint8Array(new ArrayBuffer(i));for(let e=0;e<i;e++)s[e]=t.charCodeAt(e);return s.buffer})(e.split(",")[1])}const ni=e=>Pe(e.split(",")[1]);let ai;Wt._FileToolsLoadImage=Zt,ze.loadFile=$t,ht.loadFile=$t;((e,t,i,s,r,n,a,o,h,l)=>{ai={DecodeBase64UrlToBinary:e,DecodeBase64UrlToString:t,DefaultRetryStrategy:i.DefaultRetryStrategy,BaseUrl:i.BaseUrl,CorsBehavior:i.CorsBehavior,PreprocessUrl:i.PreprocessUrl,IsBase64DataUrl:s,IsFileURL:r,LoadFile:n,LoadImage:a,ReadFile:o,RequestFile:h,SetCorsBehavior:l},Object.defineProperty(ai,"DefaultRetryStrategy",{get:function(){return i.DefaultRetryStrategy},set:function(e){i.DefaultRetryStrategy=e}}),Object.defineProperty(ai,"BaseUrl",{get:function(){return i.BaseUrl},set:function(e){i.BaseUrl=e}}),Object.defineProperty(ai,"PreprocessUrl",{get:function(){return i.PreprocessUrl},set:function(e){i.PreprocessUrl=e}}),Object.defineProperty(ai,"CorsBehavior",{get:function(){return i.CorsBehavior},set:function(e){i.CorsBehavior=e}})})(ri,ni,qt,ii,ti,$t,Zt,Jt,ei,jt);class oi{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=C(e);if(t)return t;Ae.Warn(e+" not found, you may have missed an import.");const i=e.split(".");let s=window||this;for(let e=0,t=i.length;e<t;e++)s=s[i[e]];return"function"!=typeof s?null:s}}function hi(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function li(e){let t=1;do{t*=2}while(t<e);return t===e}function ci(e,t,i){return e*(1-i)+t*i}function ui(e){const t=di(e),i=_i(e);return t-e>e-i?i:t}function di(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function _i(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)}function fi(e,t,i=Ve.SCALEMODE_NEAREST){let s;switch(i){case Ve.SCALEMODE_FLOOR:s=_i(e);break;case Ve.SCALEMODE_NEAREST:s=ui(e);break;case Ve.SCALEMODE_CEILING:default:s=di(e)}return Math.min(s,t)}oi.RegisteredExternalClasses={};class pi{static get BaseUrl(){return qt.BaseUrl}static set BaseUrl(e){qt.BaseUrl=e}static get CleanUrl(){return qt.CleanUrl}static set CleanUrl(e){qt.CleanUrl=e}static IsAbsoluteUrl(e){return 0===e.indexOf("//")||-1!==e.indexOf("://")&&(-1!==e.indexOf(".")&&(-1!==e.indexOf("/")&&(!(e.indexOf(":")>e.indexOf("/"))&&(e.indexOf("://")<e.indexOf(".")||(0===e.indexOf("data:")||0===e.indexOf("blob:"))))))}static set ScriptBaseUrl(e){qt.ScriptBaseUrl=e}static get ScriptBaseUrl(){return qt.ScriptBaseUrl}static set ScriptPreprocessUrl(e){qt.ScriptPreprocessUrl=e}static get ScriptPreprocessUrl(){return qt.ScriptPreprocessUrl}static get DefaultRetryStrategy(){return qt.DefaultRetryStrategy}static set DefaultRetryStrategy(e){qt.DefaultRetryStrategy=e}static get CorsBehavior(){return qt.CorsBehavior}static set CorsBehavior(e){qt.CorsBehavior=e}static get UseFallbackTexture(){return O.UseFallbackTexture}static set UseFallbackTexture(e){O.UseFallbackTexture=e}static get RegisteredExternalClasses(){return oi.RegisteredExternalClasses}static set RegisteredExternalClasses(e){oi.RegisteredExternalClasses=e}static get fallbackTexture(){return O.FallbackTexture}static set fallbackTexture(e){O.FallbackTexture=e}static FetchToRef(e,t,i,s,r,n){const a=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*s%s|0)*i);n.r=r[a]/255,n.g=r[a+1]/255,n.b=r[a+2]/255,n.a=r[a+3]/255}static Mix(e,t,i){return 0}static Instantiate(e){return oi.Instantiate(e)}static SetImmediate(e){lt.SetImmediate(e)}static IsExponentOfTwo(e){return!0}static FloatRound(e){return Math.fround(e)}static GetFilename(e){const t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)}static GetFolderPath(e,t=!1){const i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)}static ToDegrees(e){return 180*e/Math.PI}static ToRadians(e){return e*Math.PI/180}static SmoothAngleChange(e,t,i=.9){const s=this.ToRadians(e),r=this.ToRadians(t);return this.ToDegrees(Math.atan2((1-i)*Math.sin(r)+i*Math.sin(s),(1-i)*Math.cos(r)+i*Math.cos(s)))}static MakeArray(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null}static GetPointerPrefix(e){return pe()&&!window.PointerEvent?"mouse":"pointer"}static SetCorsBehavior(e,t){jt(e,t)}static SetReferrerPolicyBehavior(e,t){t.referrerPolicy=e}static get PreprocessUrl(){return qt.PreprocessUrl}static set PreprocessUrl(e){qt.PreprocessUrl=e}static LoadImage(e,t,i,s,r,n){return Zt(e,t,i,s,r,n)}static LoadFile(e,t,i,s,r,n){return $t(e,t,i,s,r,n)}static LoadFileAsync(e,t=!0){return new Promise(((i,s)=>{$t(e,(e=>{i(e)}),void 0,void 0,t,((e,t)=>{s(t)}))}))}static GetBabylonScriptURL(e,t){if(!e)return"";if(pi.ScriptBaseUrl&&e.startsWith(pi._DefaultCdnUrl)){const t="/"===pi.ScriptBaseUrl[pi.ScriptBaseUrl.length-1]?pi.ScriptBaseUrl.substring(0,pi.ScriptBaseUrl.length-1):pi.ScriptBaseUrl;e=e.replace(pi._DefaultCdnUrl,t)}return e=pi.ScriptPreprocessUrl(e),t&&(e=pi.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,s){e=pi.GetBabylonScriptURL(e),pi.LoadScript(e,t,i)}static LoadBabylonScriptAsync(e){return e=pi.GetBabylonScriptURL(e),pi.LoadScriptAsync(e)}static LoadScript(e,t,i,s,r=!1){if("function"==typeof importScripts){try{importScripts(e),t&&t()}catch(t){i?.(`Unable to load script '${e}' in worker`,t)}return}if(!pe())return void i?.(`Cannot load script '${e}' outside of a window or a worker`);const n=document.getElementsByTagName("head")[0],a=document.createElement("script");r?(a.setAttribute("type","module"),a.innerText=e):(a.setAttribute("type","text/javascript"),a.setAttribute("src",e)),s&&(a.id=s),a.onload=()=>{t&&t()},a.onerror=t=>{i&&i(`Unable to load script '${e}'`,t)},n.appendChild(a)}static LoadScriptAsync(e,t){return new Promise(((i,s)=>{this.LoadScript(e,(()=>{i()}),((e,t)=>{s(t||new Error(e))}),t)}))}static ReadFileAsDataURL(e,t,i){const s=new FileReader,r={onCompleteObservable:new A,abort:()=>s.abort()};return s.onloadend=()=>{r.onCompleteObservable.notifyObservers(r)},s.onload=e=>{t(e.target.result)},s.onprogress=i,s.readAsDataURL(e),r}static ReadFile(e,t,i,s,r){return Jt(e,t,i,s,r)}static FileAsURL(e){const t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,i,s){be.DeepCopy(e,t,i,s)}static IsEmpty(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let i=0;i<t.length;i++){const s=t[i];e.addEventListener(s.name,s.handler,!1);try{window.parent&&window.parent.addEventListener(s.name,s.handler,!1)}catch(e){}}}static UnregisterTopRootEvents(e,t){for(let i=0;i<t.length;i++){const s=t[i];e.removeEventListener(s.name,s.handler);try{e.parent&&e.parent.removeEventListener(s.name,s.handler)}catch(e){}}}static async DumpFramebuffer(e,t,i,s,r="image/png",n,a){throw te("DumpTools")}static DumpData(e,t,i,s,r="image/png",n,a=!1,o=!1,h){throw te("DumpTools")}static DumpDataAsync(e,t,i,s="image/png",r,n=!1,a=!1,o){throw te("DumpTools")}static _IsOffScreenCanvas(e){return void 0!==e.convertToBlob}static ToBlob(e,t,i="image/png",s){pi._IsOffScreenCanvas(e)||e.toBlob||(e.toBlob=function(e,t,i){setTimeout((()=>{const s=atob(this.toDataURL(t,i).split(",")[1]),r=s.length,n=new Uint8Array(r);for(let e=0;e<r;e++)n[e]=s.charCodeAt(e);e(new Blob([n]))}))}),pi._IsOffScreenCanvas(e)?e.convertToBlob({type:i,quality:s}).then((e=>t(e))):e.toBlob((function(e){t(e)}),i,s)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){const e=new Date;t="screenshot_"+((e.getFullYear()+"-"+(e.getMonth()+1)).slice(2)+"-"+e.getDate()+"_"+e.getHours()+"-"+("0"+e.getMinutes()).slice(-2))+".png"}pi.Download(e,t)}else if(e&&"undefined"!=typeof URL){const t=URL.createObjectURL(e),i=window.open("");if(!i)return;const s=i.document.createElement("img");s.onload=function(){URL.revokeObjectURL(t)},s.src=t,i.document.body.appendChild(s)}}static EncodeScreenshotCanvasData(e,t,i="image/png",s,r){if("string"!=typeof s&&t){if(t){if(pi._IsOffScreenCanvas(e))return void e.convertToBlob({type:i,quality:r}).then((e=>{const i=new FileReader;i.readAsDataURL(e),i.onloadend=()=>{const e=i.result;t(e)}}));const s=e.toDataURL(i,r);t(s)}}else this.ToBlob(e,(function(e){e&&pi.DownloadBlob(e,s),t&&t("")}),i,r)}static Download(e,t){if("undefined"==typeof URL)return;const i=window.URL.createObjectURL(e),s=document.createElement("a");document.body.appendChild(s),s.style.display="none",s.href=i,s.download=t,s.addEventListener("click",(()=>{s.parentElement&&s.parentElement.removeChild(s)})),s.click(),window.URL.revokeObjectURL(i)}static BackCompatCameraNoPreventDefault(e){return"boolean"==typeof e[0]?e[0]:"boolean"==typeof e[1]&&e[1]}static CreateScreenshot(e,t,i,s,r="image/png",n=!1,a){throw te("ScreenshotTools")}static CreateScreenshotAsync(e,t,i,s="image/png",r){throw te("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,s,r="image/png",n=1,a=!1,o,h=!1,l=!1,c=!0,u,d){throw te("ScreenshotTools")}static CreateScreenshotUsingRenderTargetAsync(e,t,i,s="image/png",r=1,n=!1,a,o=!1,h=!1,l=!0,c,u){throw te("ScreenshotTools")}static RandomId(){return hi()}static IsBase64(e){return ii(e)}static DecodeBase64(e){return ri(e)}static get errorsCount(){return Ae.errorsCount}static Log(e){Ae.Log(e)}static Warn(e){Ae.Warn(e)}static Error(e){Ae.Error(e)}static get LogCache(){return Ae.LogCache}static ClearLogCache(){Ae.ClearLogCache()}static set LogLevels(e){Ae.LogLevels=e}static set PerformanceLogLevel(e){return(e&pi.PerformanceUserMarkLogLevel)===pi.PerformanceUserMarkLogLevel?(pi.StartPerformanceCounter=pi._StartUserMark,void(pi.EndPerformanceCounter=pi._EndUserMark)):(e&pi.PerformanceConsoleLogLevel)===pi.PerformanceConsoleLogLevel?(pi.StartPerformanceCounter=pi._StartPerformanceConsole,void(pi.EndPerformanceCounter=pi._EndPerformanceConsole)):(pi.StartPerformanceCounter=pi._StartPerformanceCounterDisabled,void(pi.EndPerformanceCounter=pi._EndPerformanceCounterDisabled))}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!pi._Performance){if(!pe())return;pi._Performance=window.performance}t&&pi._Performance.mark&&pi._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){t&&pi._Performance.mark&&(pi._Performance.mark(e+"-End"),pi._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(pi._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(pi._EndUserMark(e,t),console.timeEnd(e))}static get Now(){return Re.Now}static GetClassName(e,t=!1){let i=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__}i||(i=typeof e)}return i}static First(e,t){for(const i of e)if(t(i))return i;return null}static getFullClassName(e,t=!1){let i=null,s=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){const r=t?e:Object.getPrototypeOf(e);i=r.constructor.__bjsclassName__,s=r.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(null!=s?s+".":"")+i:null}static DelayAsync(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}static IsSafari(){return!!ge()&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}pi.UseCustomRequestHeaders=!1,pi.CustomRequestHeaders=ye.CustomRequestHeaders,pi.GetDOMTextContent=Te,pi._DefaultCdnUrl="https://cdn.babylonjs.com",pi.GetAbsoluteUrl="object"==typeof document?e=>{const t=document.createElement("a");return t.href=e,t.href}:"function"==typeof URL&&"object"==typeof location?e=>new URL(e,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")},pi.NoneLogLevel=Ae.NoneLogLevel,pi.MessageLogLevel=Ae.MessageLogLevel,pi.WarningLogLevel=Ae.WarningLogLevel,pi.ErrorLogLevel=Ae.ErrorLogLevel,pi.AllLogLevel=Ae.AllLogLevel,pi.IsWindowObjectExist=pe,pi.PerformanceNoneLogLevel=0,pi.PerformanceUserMarkLogLevel=1,pi.PerformanceConsoleLogLevel=2,pi.StartPerformanceCounter=pi._StartPerformanceCounterDisabled,pi.EndPerformanceCounter=pi._EndPerformanceCounterDisabled;class gi{constructor(e,t,i,s=0){this.iterations=e,this.index=s-1,this._done=!1,this._fn=t,this._successCallback=i}executeNext(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())}breakLoop(){this._done=!0,this._successCallback()}static Run(e,t,i,s=0){const r=new gi(e,t,i,s);return r.executeNext(),r}static SyncAsyncForLoop(e,t,i,s,r,n=0){return gi.Run(Math.ceil(e/t),(s=>{r&&r()?s.breakLoop():setTimeout((()=>{for(let n=0;n<t;++n){const a=s.index*t+n;if(a>=e)break;if(i(a),r&&r()){s.breakLoop();break}}s.executeNext()}),n)}),s)}}function mi(e,t,i){try{const s=e.next();s.done?t(s):s.value?s.value.then((()=>{s.value=void 0,t(s)}),i):t(s)}catch(e){i(e)}}function Ti(e=25){let t;return(i,s,r)=>{const n=performance.now();void 0===t||n-t>e?(t=n,setTimeout((()=>{mi(i,s,r)}),0)):mi(i,s,r)}}function Ai(e,t,i,s,r){const n=()=>{let r;const a=e=>{e.done?i(e.value):void 0===r?r=!0:n()};do{r=void 0,t(e,a,s),void 0===r&&(r=!1)}while(r)};n()}function Ei(e,t){let i;return Ai(e,mi,(e=>i=e),(e=>{throw e})),i}function bi(e,t,i){return new Promise(((i,s)=>{Ai(e,t,i,s)}))}pi.Mix=ci,pi.IsExponentOfTwo=li,O.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";class Ri{constructor(e){this.length=0,this.data=new Array(e),this._id=Ri._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;t<this.length;t++)e(this.data[t])}sort(e){this.data.sort(e)}reset(){this.length=0}dispose(){this.reset(),this.data&&(this.data.length=0)}concat(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(let t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}}indexOf(e){const t=this.data.indexOf(e);return t>=this.length?-1:t}contains(e){return-1!==this.indexOf(e)}}Ri._GlobalId=0;class yi extends Ri{constructor(){super(...arguments),this._duplicateId=0}push(e){super.push(e),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId}pushNoDuplicate(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)}reset(){super.reset(),this._duplicateId++}concatWithNoDuplicate(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(let t=0;t<e.length;t++){const i=(e.data||e)[t];this.pushNoDuplicate(i)}}}}class Ii{constructor(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}toGlobal(e,t){return new Ii(this.x*e,this.y*t,this.width*e,this.height*t)}toGlobalToRef(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this}clone(){return new Ii(this.x,this.y,this.width,this.height)}}class Mi{constructor(e,t,i,s){this.normal=new X(e,t,i),this.d=s}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new Mi(this.normal.x,this.normal.y,this.normal.z,this.d)}getClassName(){return"Plane"}getHashCode(){let e=this.normal.getHashCode();return e=397*e^this.d,e}normalize(){const e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z);let t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this}transform(e){const t=Mi._TmpMatrix;e.invertToRef(t);const i=t.m,s=this.normal.x,r=this.normal.y,n=this.normal.z,a=this.d,o=s*i[0]+r*i[1]+n*i[2]+a*i[3],h=s*i[4]+r*i[5]+n*i[6]+a*i[7],l=s*i[8]+r*i[9]+n*i[10]+a*i[11],c=s*i[12]+r*i[13]+n*i[14]+a*i[15];return new Mi(o,h,l,c)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,i){const s=t.x-e.x,r=t.y-e.y,n=t.z-e.z,a=i.x-e.x,o=i.y-e.y,h=i.z-e.z,l=r*h-n*o,c=n*a-s*h,u=s*o-r*a,d=Math.sqrt(l*l+c*c+u*u);let _;return _=0!==d?1/d:0,this.normal.x=l*_,this.normal.y=c*_,this.normal.z=u*_,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return X.Dot(this.normal,e)<=t}signedDistanceTo(e){return X.Dot(e,this.normal)+this.d}static FromArray(e){return new Mi(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){const s=new Mi(0,0,0,0);return s.copyFromPoints(e,t,i),s}static FromPositionAndNormal(e,t){const i=new Mi(0,0,0,0);return this.FromPositionAndNormalToRef(e,t,i)}static FromPositionAndNormalToRef(e,t,i){return i.normal.copyFrom(t),i.normal.normalize(),i.d=-e.dot(i.normal),i}static SignedDistanceToPlaneFromPositionAndNormal(e,t,i){const s=-(t.x*e.x+t.y*e.y+t.z*e.z);return X.Dot(i,t)+s}}Mi._TmpMatrix=j.Identity();class vi{static GetPlanes(e){const t=[];for(let e=0;e<6;e++)t.push(new Mi(0,0,0,0));return vi.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()}static GetFarPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()}static GetLeftPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()}static GetRightPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()}static GetTopPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()}static GetBottomPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()}static GetPlanesToRef(e,t){vi.GetNearPlaneToRef(e,t[0]),vi.GetFarPlaneToRef(e,t[1]),vi.GetLeftPlaneToRef(e,t[2]),vi.GetRightPlaneToRef(e,t[3]),vi.GetTopPlaneToRef(e,t[4]),vi.GetBottomPlaneToRef(e,t[5])}static IsPointInFrustum(e,t){for(let i=0;i<6;i++)if(t[i].dotCoordinate(e)<0)return!1;return!0}}class xi extends fe{get position(){return this._position}set position(e){this._position=e}set upVector(e){this._upVector=e}get upVector(){return this._upVector}get screenArea(){let e=0,t=0;if(this.mode===xi.PERSPECTIVE_CAMERA)this.fovMode===xi.FOVMODE_VERTICAL_FIXED?(t=2*this.minZ*Math.tan(this.fov/2),e=this.getEngine().getAspectRatio(this)*t):(e=2*this.minZ*Math.tan(this.fov/2),t=e/this.getEngine().getAspectRatio(this));else{const i=this.getEngine().getRenderWidth()/2,s=this.getEngine().getRenderHeight()/2;e=(this.orthoRight??i)-(this.orthoLeft??-i),t=(this.orthoTop??s)-(this.orthoBottom??-s)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(const t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(const t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(const t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(const t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}set mode(e){this._mode=e;for(const t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,i,s=!0){super(e,i,!1),this._position=X.Zero(),this._upVector=X.Up(),this.oblique=null,this._orthoLeft=null,this._orthoRight=null,this._orthoBottom=null,this._orthoTop=null,this.fov=.8,this.projectionPlaneTilt=0,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this._mode=xi.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new Ii(0,0,1,1),this.layerMask=268435455,this.fovMode=xi.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=xi.RIG_MODE_NONE,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new A,this.onProjectionMatrixChangedObservable=new A,this.onAfterCheckInputsObservable=new A,this.onRestoreStateObservable=new A,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new j,this._postProcesses=new Array,this._activeMeshes=new Ri(256),this._globalPosition=X.Zero(),this._computedViewMatrix=j.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=j.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=q.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.getScene().addCamera(this),s&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return!!this._stateStored&&(this.fov=this._storedFov,!0)}restoreState(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t}applyVerticalCorrection(){const e=this.absoluteRotation.toEulerAngles();this.projectionPlaneTilt=this._scene.useRightHandedSystem?-e.x:e.x}get globalPosition(){return this._globalPosition}getActiveMeshes(){return this._activeMeshes}isActiveMesh(e){return-1!==this._activeMeshes.indexOf(e)}isReady(e=!1){if(e)for(const e of this._postProcesses)if(e&&!e.isReady())return!1;return super.isReady(e)}_initCache(){super._initCache(),this._cache.position=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.obliqueAngle=void 0,this._cache.obliqueLength=void 0,this._cache.obliqueOffset=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0}_updateCache(e){e||super._updateCache(),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)}_isSynchronized(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()}_isSynchronizedViewMatrix(){return!!super._isSynchronized()&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())}_isSynchronizedProjectionMatrix(){let e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;const t=this.getEngine();return this.mode===xi.PERSPECTIVE_CAMERA?e=this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===t.getAspectRatio(this)&&this._cache.projectionPlaneTilt===this.projectionPlaneTilt:(e=this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight(),this.oblique&&(e=e&&this._cache.obliqueAngle===this.oblique.angle&&this._cache.obliqueLength===this.oblique.length&&this._cache.obliqueOffset===this.oblique.offset)),e}attachControl(e,t){}detachControl(e){}update(){this._hasMoved=!1,this._checkInputs(),this.cameraRigMode!==xi.RIG_MODE_NONE&&this._updateRigCameras(),this.getViewMatrix(),this.getProjectionMatrix()}_checkInputs(){this.onAfterCheckInputsObservable.notifyObservers(this)}get rigCameras(){return this._rigCameras}get rigPostProcess(){return this._rigPostProcess}_getFirstPostProcess(){for(let e=0;e<this._postProcesses.length;e++)if(null!==this._postProcesses[e])return this._postProcesses[e];return null}_cascadePostProcessesToRigCams(){const e=this._getFirstPostProcess();e&&e.markTextureDirty();for(let e=0,t=this._rigCameras.length;e<t;e++){const t=this._rigCameras[e],i=t._rigPostProcess;if(i){"pass"===i.getEffectName()&&(t.isIntermediate=0===this._postProcesses.length),t._postProcesses=this._postProcesses.slice(0).concat(i),i.markTextureDirty()}else t._postProcesses=this._postProcesses.slice(0)}}attachPostProcess(e,t=null){return!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(Ae.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){const t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()}getWorldMatrix(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix}_getViewMatrix(){return j.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()||(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;const t=this.getEngine(),i=this.getScene(),s=t.useReverseDepthBuffer;if(this.mode===xi.PERSPECTIVE_CAMERA){let e;this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=t.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1),e=i.useRightHandedSystem?j.PerspectiveFovRHToRef:j.PerspectiveFovLHToRef,e(this.fov,t.getAspectRatio(this),s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===xi.FOVMODE_VERTICAL_FIXED,t.isNDCHalfZRange,this.projectionPlaneTilt,s)}else{const e=t.getRenderWidth()/2,r=t.getRenderHeight()/2;i.useRightHandedSystem?this.oblique?j.ObliqueOffCenterRHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):j.OrthoOffCenterRHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange):this.oblique?j.ObliqueOffCenterLHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):j.OrthoOffCenterLHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=this.oblique?.angle,this._cache.obliqueLength=this.oblique?.length,this._cache.obliqueOffset=this.oblique?.offset,this._cache.renderWidth=t.getRenderWidth(),this._cache.renderHeight=t.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){return(this.radius||(this.target?X.Distance(this.position,this.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?vi.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=vi.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let t=!1;return this.rigCameras.forEach((i=>{i._updateFrustumPlanes(),t=t||e.isInFrustum(i._frustumPlanes)})),t}return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,i){throw te("Ray")}getForwardRayToRef(e,t=100,i,s){throw te("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){const e=this._rigCameras.pop();e&&e.dispose()}if(this._parentContainer){const e=this._parentContainer.cameras.indexOf(this);e>-1&&this._parentContainer.cameras.splice(e,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==xi.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let e=this._postProcesses.length;for(;--e>=0;){const t=this._postProcesses[e];t&&t.dispose(this)}}let i=this.customRenderTargets.length;for(;--i>=0;)this.customRenderTargets[i].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(e,t)}get isLeftCamera(){return this._isLeftCamera}get isRightCamera(){return this._isRightCamera}get leftCamera(){return this._rigCameras.length<1?null:this._rigCameras[0]}get rightCamera(){return this._rigCameras.length<2?null:this._rigCameras[1]}getLeftTarget(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()}getRightTarget(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()}setCameraRigMode(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){const e=this._rigCameras.pop();e&&e.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=pi.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==xi.RIG_MODE_NONE){const e=this.createRigCamera(this.name+"_L",0);e&&(e._isLeftCamera=!0);const t=this.createRigCamera(this.name+"_R",1);t&&(t._isRightCamera=!0),e&&t&&(this._rigCameras.push(e),this._rigCameras.push(t))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return j.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=pi.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov,this._rigCameras[e].upVector.copyFrom(this.upVector);this.cameraRigMode===xi.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)}_setupInputs(){}serialize(){const e=de.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(e),this.inputs&&this.inputs.serialize(e),de.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}clone(e,t=null){const i=de.Clone(xi.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this);return i.name=e,i.parent=t,this.onClonedObservable.notifyObservers(i),i}getDirection(e){const t=X.Zero();return this.getDirectionToRef(e,t),t}get absoluteRotation(){return this.getWorldMatrix().decompose(void 0,this._absoluteRotation),this._absoluteRotation}getDirectionToRef(e,t){X.TransformNormalToRef(e,this.getWorldMatrix(),t)}static GetConstructorFromName(e,t,i,s=0,r=!0){const n=fe.Construct(e,t,i,{interaxial_distance:s,isStereoscopicSideBySide:r});return n||(()=>xi._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){const i=e.type,s=xi.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),r=de.Parse(s,e,t);if(void 0!==e.parentId&&(r._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),r.inputs&&(r.inputs.parse(e),r._setupInputs()),e.upVector&&(r.upVector=X.FromArray(e.upVector)),r.setPosition&&(r.position.copyFromFloats(0,0,0),r.setPosition(X.FromArray(e.position))),e.target&&r.setTarget&&r.setTarget(X.FromArray(e.target)),e.cameraRigMode){const t=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};r.setCameraRigMode(e.cameraRigMode,t)}if(e.animations){for(let t=0;t<e.animations.length;t++){const i=e.animations[t],s=C("BABYLON.Animation");s&&r.animations.push(s.Parse(i))}fe.ParseAnimationRanges(r,e,t)}return e.autoAnimate&&t.beginAnimation(r,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),void 0!==e.isEnabled&&r.setEnabled(e.isEnabled),r}_calculateHandednessMultiplier(){let e=this.getScene().useRightHandedSystem?-1:1;return this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),e}}xi._CreateDefaultParsedCamera=(e,t)=>{throw te("UniversalCamera")},xi.PERSPECTIVE_CAMERA=Ve.PERSPECTIVE_CAMERA,xi.ORTHOGRAPHIC_CAMERA=Ve.ORTHOGRAPHIC_CAMERA,xi.FOVMODE_VERTICAL_FIXED=Ve.FOVMODE_VERTICAL_FIXED,xi.FOVMODE_HORIZONTAL_FIXED=Ve.FOVMODE_HORIZONTAL_FIXED,xi.RIG_MODE_NONE=Ve.RIG_MODE_NONE,xi.RIG_MODE_STEREOSCOPIC_ANAGLYPH=Ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH,xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=Ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=Ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,xi.RIG_MODE_STEREOSCOPIC_OVERUNDER=Ve.RIG_MODE_STEREOSCOPIC_OVERUNDER,xi.RIG_MODE_STEREOSCOPIC_INTERLACED=Ve.RIG_MODE_STEREOSCOPIC_INTERLACED,xi.RIG_MODE_VR=Ve.RIG_MODE_VR,xi.RIG_MODE_CUSTOM=Ve.RIG_MODE_CUSTOM,xi.ForceAttachControlToAlwaysPreventDefault=!1,e([u("position")],xi.prototype,"_position",void 0),e([u("upVector")],xi.prototype,"_upVector",void 0),e([a()],xi.prototype,"orthoLeft",null),e([a()],xi.prototype,"orthoRight",null),e([a()],xi.prototype,"orthoBottom",null),e([a()],xi.prototype,"orthoTop",null),e([a()],xi.prototype,"fov",void 0),e([a()],xi.prototype,"projectionPlaneTilt",void 0),e([a()],xi.prototype,"minZ",void 0),e([a()],xi.prototype,"maxZ",void 0),e([a()],xi.prototype,"inertia",void 0),e([a()],xi.prototype,"mode",null),e([a()],xi.prototype,"layerMask",void 0),e([a()],xi.prototype,"fovMode",void 0),e([a()],xi.prototype,"cameraRigMode",void 0),e([a()],xi.prototype,"interaxialDistance",void 0),e([a()],xi.prototype,"isStereoscopicSideBySide",void 0);class Si{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=Si._Counter++}}function Ci(e,t,i,s){switch(t){case Ve.BYTE:{let t=e.getInt8(i);return s&&(t=Math.max(t/127,-1)),t}case Ve.UNSIGNED_BYTE:{let t=e.getUint8(i);return s&&(t/=255),t}case Ve.SHORT:{let t=e.getInt16(i,!0);return s&&(t=Math.max(t/32767,-1)),t}case Ve.UNSIGNED_SHORT:{let t=e.getUint16(i,!0);return s&&(t/=65535),t}case Ve.INT:return e.getInt32(i,!0);case Ve.UNSIGNED_INT:return e.getUint32(i,!0);case Ve.FLOAT:return e.getFloat32(i,!0);default:throw new Error(`Invalid component type ${t}`)}}function Pi(e,t,i,s,r){switch(t){case Ve.BYTE:s&&(r=Math.round(127*r)),e.setInt8(i,r);break;case Ve.UNSIGNED_BYTE:s&&(r=Math.round(255*r)),e.setUint8(i,r);break;case Ve.SHORT:s&&(r=Math.round(32767*r)),e.setInt16(i,r,!0);break;case Ve.UNSIGNED_SHORT:s&&(r=Math.round(65535*r)),e.setUint16(i,r,!0);break;case Ve.INT:e.setInt32(i,r,!0);break;case Ve.UNSIGNED_INT:e.setUint32(i,r,!0);break;case Ve.FLOAT:e.setFloat32(i,r,!0);break;default:throw new Error(`Invalid component type ${t}`)}}function Oi(e){switch(e){case Ve.BYTE:case Ve.UNSIGNED_BYTE:return 1;case Ve.SHORT:case Ve.UNSIGNED_SHORT:return 2;case Ve.INT:case Ve.UNSIGNED_INT:case Ve.FLOAT:return 4;default:throw new Error(`Invalid type '${e}'`)}}function Di(e,t,i,s,r,n,a,o){const h=new Array(s),l=new Array(s);if(e instanceof Array){let r=t/4;const a=i/4;for(let t=0;t<n;t+=s){for(let t=0;t<s;t++)h[t]=l[t]=e[r+t];o(l,t);for(let t=0;t<s;t++)h[t]!==l[t]&&(e[r+t]=l[t]);r+=a}}else{const c=e instanceof ArrayBuffer?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),u=Oi(r);for(let e=0;e<n;e+=s){for(let e=0,i=t;e<s;e++,i+=u)h[e]=l[e]=Ci(c,r,i,a);o(l,e);for(let e=0,i=t;e<s;e++,i+=u)h[e]!==l[e]&&Pi(c,r,i,a,l[e]);t+=i}}}function Li(e,t,i,s,r,n,a,o){const h=t*Oi(i),l=a*t;if(i!==Ve.FLOAT||r!==h){const a=new Float32Array(l);return Di(e,s,r,t,i,l,n,((e,i)=>{for(let s=0;s<t;s++)a[i+s]=e[s]})),a}if(!(e instanceof Array||e instanceof Float32Array)||0!==s||e.length!==l){if(e instanceof Array){const t=s/4;return e.slice(t,t+l)}if(e instanceof ArrayBuffer)return new Float32Array(e,s,l);{const t=e.byteOffset+s;return 3&t&&(Ae.Warn("Float array must be aligned to 4-bytes border"),o=!0),o?new Float32Array(e.buffer.slice(t,t+l*Float32Array.BYTES_PER_ELEMENT)):new Float32Array(e.buffer,t,l)}}return o?e.slice():e}Si._Counter=0;class Fi{get isDisposed(){return this._isDisposed}constructor(e,t,i,s=0,r=!1,n=!1,a=!1,o,h){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=n,this._divisor=o||1,this._label=h,t instanceof Si?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=a?s:s*Float32Array.BYTES_PER_ELEMENT,r||this.create()}createVertexBuffer(e,t,i,s,r,n=!1,a){const o=n?t:t*Float32Array.BYTES_PER_ELEMENT,h=s?n?s:s*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new wi(this._engine,this,e,this._updatable,!0,h,void 0===r?this._instanced:r,o,i,void 0,void 0,!0,this._divisor||a)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0)return void(this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label));Ae.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,i,s=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,s?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),this._data=0===t&&void 0===i?e:null)}_increaseReferences(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)}dispose(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)}}class wi{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){const t=0!=e;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){const e=this.getData();return e?Array.isArray(e)?e.length/(this.byteStride/4)-this.byteOffset/4:(e.byteLength-this.byteOffset)/this.byteStride:0}constructor(e,t,i,s,r,n,a,o,h,l,c=!1,u=!1,d=1,_=!1){this._isDisposed=!1;let f=!1;if(this.engine=e,"object"==typeof s&&null!==s?(f=s.updatable??!1,r=s.postponeInternalCreation,n=s.stride,a=s.instanced,o=s.offset,h=s.size,l=s.type,c=s.normalized??!1,u=s.useBytes??!1,d=s.divisor??1,_=s.takeBufferOwnership??!1,this._label=s.label):f=!!s,t instanceof Fi?(this._buffer=t,this._ownsBuffer=_):(this._buffer=new Fi(e,t,f,n,r,a,u,d,this._label),this._ownsBuffer=!0),this.uniqueId=wi._Counter++,this._kind=i,void 0===l){const e=this.getData();this.type=e?wi.GetDataType(e):wi.FLOAT}else this.type=l;const p=Oi(this.type);u?(this._size=h||(n?n/p:wi.DeduceStride(i)),this.byteStride=n||this._buffer.byteStride||this._size*p,this.byteOffset=o||0):(this._size=h||n||wi.DeduceStride(i),this.byteStride=n?n*p:this._buffer.byteStride||this._size*p,this.byteOffset=(o||0)*p),this.normalized=c,this._instanced=void 0!==a&&a,this._instanceDivisor=a?d:0,this._alignBuffer(),this._computeHashCode()}_computeHashCode(){this.hashCode=(this.type-5120|0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)}_rebuild(){this._buffer?._rebuild()}getKind(){return this._kind}isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const i=this.getData();return i?Li(i,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,e,t):null}getBuffer(){return this._buffer.getBuffer()}getWrapperBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Oi(this.type)}getOffset(){return this.byteOffset/Oi(this.type)}getSize(e=!1){return e?this._size*Oi(this.type):this._size}getIsInstanced(){return this._instanced}getInstanceDivisor(){return this._instanceDivisor}create(e){this._buffer.create(e),this._alignBuffer()}update(e){this._buffer.update(e),this._alignBuffer()}updateDirectly(e,t,i=!1){this._buffer.updateDirectly(e,t,void 0,i),this._alignBuffer()}dispose(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0}forEach(e,t){Di(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,((e,i)=>{for(let s=0;s<this._size;s++)t(e[s],i+s)}))}_alignBuffer(){}static DeduceStride(e){switch(e){case wi.UVKind:case wi.UV2Kind:case wi.UV3Kind:case wi.UV4Kind:case wi.UV5Kind:case wi.UV6Kind:return 2;case wi.NormalKind:case wi.PositionKind:return 3;case wi.ColorKind:case wi.ColorInstanceKind:case wi.MatricesIndicesKind:case wi.MatricesIndicesExtraKind:case wi.MatricesWeightsKind:case wi.MatricesWeightsExtraKind:case wi.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?wi.BYTE:e instanceof Uint8Array?wi.UNSIGNED_BYTE:e instanceof Int16Array?wi.SHORT:e instanceof Uint16Array?wi.UNSIGNED_SHORT:e instanceof Int32Array?wi.INT:e instanceof Uint32Array?wi.UNSIGNED_INT:wi.FLOAT}static GetTypeByteLength(e){return Oi(e)}static ForEach(e,t,i,s,r,n,a,o){Di(e,t,i,s,r,n,a,((e,t)=>{for(let i=0;i<s;i++)o(e[i],t+i)}))}static GetFloatData(e,t,i,s,r,n,a,o){return Li(e,t,i,s,r,n,a,o)}}wi._Counter=0,wi.BYTE=Ve.BYTE,wi.UNSIGNED_BYTE=Ve.UNSIGNED_BYTE,wi.SHORT=Ve.SHORT,wi.UNSIGNED_SHORT=Ve.UNSIGNED_SHORT,wi.INT=Ve.INT,wi.UNSIGNED_INT=Ve.UNSIGNED_INT,wi.FLOAT=Ve.FLOAT,wi.PositionKind=Ve.PositionKind,wi.NormalKind=Ve.NormalKind,wi.TangentKind=Ve.TangentKind,wi.UVKind=Ve.UVKind,wi.UV2Kind=Ve.UV2Kind,wi.UV3Kind=Ve.UV3Kind,wi.UV4Kind=Ve.UV4Kind,wi.UV5Kind=Ve.UV5Kind,wi.UV6Kind=Ve.UV6Kind,wi.ColorKind=Ve.ColorKind,wi.ColorInstanceKind=Ve.ColorInstanceKind,wi.MatricesIndicesKind=Ve.MatricesIndicesKind,wi.MatricesWeightsKind=Ve.MatricesWeightsKind,wi.MatricesIndicesExtraKind=Ve.MatricesIndicesExtraKind,wi.MatricesWeightsExtraKind=Ve.MatricesWeightsExtraKind;class Ni{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}class Bi{constructor(e,t,i){this.vectors=y(8,X.Zero),this.center=X.Zero(),this.centerWorld=X.Zero(),this.extendSize=X.Zero(),this.extendSizeWorld=X.Zero(),this.directions=y(3,X.Zero),this.vectorsWorld=y(8,X.Zero),this.minimumWorld=X.Zero(),this.maximumWorld=X.Zero(),this.minimum=X.Zero(),this.maximum=X.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,i)}reConstruct(e,t,i){const s=e.x,r=e.y,n=e.z,a=t.x,o=t.y,h=t.z,l=this.vectors;this.minimum.copyFromFloats(s,r,n),this.maximum.copyFromFloats(a,o,h),l[0].copyFromFloats(s,r,n),l[1].copyFromFloats(a,o,h),l[2].copyFromFloats(a,r,n),l[3].copyFromFloats(s,o,n),l[4].copyFromFloats(s,r,h),l[5].copyFromFloats(a,o,n),l[6].copyFromFloats(s,o,h),l[7].copyFromFloats(a,r,h),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||j.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=Bi._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),s=i.length();i.normalizeFromLength(s);const r=s*e,n=i.scaleInPlace(.5*r),a=this.center.subtractToRef(n,t[1]),o=this.center.addToRef(n,t[2]);return this.reConstruct(a,o,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){const t=this.minimumWorld,i=this.maximumWorld,s=this.directions,r=this.vectorsWorld,n=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let e=0;e<8;++e)r[e].copyFrom(n[e]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(let s=0;s<8;++s){const a=r[s];X.TransformCoordinatesToRef(n[s],e,a),t.minimizeInPlace(a),i.maximizeInPlace(a)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}X.FromArrayToRef(e.m,0,s[0]),X.FromArrayToRef(e.m,4,s[1]),X.FromArrayToRef(e.m,8,s[2]),this._worldMatrix=e}isInFrustum(e){return Bi.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return Bi.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,i=this.maximumWorld,s=t.x,r=t.y,n=t.z,a=i.x,o=i.y,h=i.z,l=e.x,c=e.y,u=e.z,d=-.001;return!(a-l<d||d>l-s)&&(!(o-c<d||d>c-r)&&!(h-u<d||d>u-n))}intersectsSphere(e){return Bi.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const i=this.minimumWorld,s=this.maximumWorld,r=i.x,n=i.y,a=i.z,o=s.x,h=s.y,l=s.z,c=e.x,u=e.y,d=e.z,_=t.x,f=t.y,p=t.z;return!(o<c||r>_)&&(!(h<u||n>f)&&!(l<d||a>p))}dispose(){this._drawWrapperFront?.dispose(),this._drawWrapperBack?.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,i,s){const r=Bi._TmpVector3[0];X.ClampToRef(i,e,t,r);return X.DistanceSquared(i,r)<=s*s}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){const s=t[i];for(let t=0;t<8;++t)if(s.dotCoordinate(e[t])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let s=!0;const r=t[i];for(let t=0;t<8;++t)if(r.dotCoordinate(e[t])>=0){s=!1;break}if(s)return!1}return!0}}Bi._TmpVector3=y(3,X.Zero);class Ui{constructor(e,t,i){this.center=X.Zero(),this.centerWorld=X.Zero(),this.minimum=X.Zero(),this.maximum=X.Zero(),this.reConstruct(e,t,i)}reConstruct(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const s=X.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*s,this._update(i||j.IdentityReadOnly)}scale(e){const t=this.radius*e,i=Ui._TmpVector3,s=i[0].setAll(t),r=this.center.subtractToRef(s,i[1]),n=this.center.addToRef(s,i[2]);return this.reConstruct(r,n,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{X.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=Ui._TmpVector3[0];X.TransformNormalFromFloatsToRef(1,1,1,e,t),this.radiusWorld=Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.radius}}isInFrustum(e){const t=this.centerWorld,i=this.radiusWorld;for(let s=0;s<6;s++)if(e[s].dotCoordinate(t)<=-i)return!1;return!0}isCenterInFrustum(e){const t=this.centerWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){const t=X.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)}static Intersects(e,t){const i=X.DistanceSquared(e.centerWorld,t.centerWorld),s=e.radiusWorld+t.radiusWorld;return!(s*s<i)}static CreateFromCenterAndRadius(e,t,i){this._TmpVector3[0].copyFrom(e),this._TmpVector3[1].copyFromFloats(0,0,t),this._TmpVector3[2].copyFrom(e),this._TmpVector3[0].addInPlace(this._TmpVector3[1]),this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);const s=new Ui(this._TmpVector3[0],this._TmpVector3[2]);return s._worldMatrix=i||j.Identity(),s}}Ui._TmpVector3=y(3,X.Zero);const ki={min:0,max:0},Vi={min:0,max:0},zi=(e,t,i)=>{const s=X.Dot(t.centerWorld,e),r=Math.abs(X.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(X.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(X.Dot(t.directions[2],e))*t.extendSize.z;i.min=s-r,i.max=s+r},Gi=(e,t,i)=>(zi(e,t,ki),zi(e,i,Vi),!(ki.min>Vi.max||Vi.min>ki.max));class Hi{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new Bi(e,t,i),this.boundingSphere=new Ui(e,t,i)}reConstruct(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)}get minimum(){return this.boundingBox.minimum}get maximum(){return this.boundingBox.maximum}get isLocked(){return this._isLocked}set isLocked(e){this._isLocked=e}update(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))}centerOn(e,t){const i=Hi._TmpVector3[0].copyFrom(e).subtractInPlace(t),s=Hi._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this}encapsulate(e){const t=X.Minimize(this.minimum,e),i=X.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=J.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const i=J.Vector3[0];return X.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),X.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,i),this.encapsulate(i),this}scale(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this}isInFrustum(e,t=Ve.MESHES_CULLINGSTRATEGY_STANDARD){if((t===Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION||t===Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)&&this.boundingSphere.isCenterInFrustum(e))return!0;if(!this.boundingSphere.isInFrustum(e))return!1;return!(t!==Ve.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(e)}get diagonalLength(){const e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,Hi._TmpVector3[0]).length()}isCompletelyInFrustum(e){return this.boundingBox.isCompletelyInFrustum(e)}_checkCollision(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)}intersectsPoint(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))}intersects(e,t){if(!Ui.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!Bi.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const i=this.boundingBox,s=e.boundingBox;return!!Gi(i.directions[0],i,s)&&(!!Gi(i.directions[1],i,s)&&(!!Gi(i.directions[2],i,s)&&(!!Gi(s.directions[0],i,s)&&(!!Gi(s.directions[1],i,s)&&(!!Gi(s.directions[2],i,s)&&(!!Gi(X.Cross(i.directions[0],s.directions[0]),i,s)&&(!!Gi(X.Cross(i.directions[0],s.directions[1]),i,s)&&(!!Gi(X.Cross(i.directions[0],s.directions[2]),i,s)&&(!!Gi(X.Cross(i.directions[1],s.directions[0]),i,s)&&(!!Gi(X.Cross(i.directions[1],s.directions[1]),i,s)&&(!!Gi(X.Cross(i.directions[1],s.directions[2]),i,s)&&(!!Gi(X.Cross(i.directions[2],s.directions[0]),i,s)&&(!!Gi(X.Cross(i.directions[2],s.directions[1]),i,s)&&!!Gi(X.Cross(i.directions[2],s.directions[2]),i,s))))))))))))))}}Hi._TmpVector3=y(2,X.Zero);class Wi{static extractMinAndMaxIndexed(e,t,i,s,r,n){for(let a=i;a<i+s;a++){const i=3*t[a],s=e[i],o=e[i+1],h=e[i+2];r.minimizeInPlaceFromFloats(s,o,h),n.maximizeInPlaceFromFloats(s,o,h)}}static extractMinAndMax(e,t,i,s,r,n){for(let a=t,o=t*s;a<t+i;a++,o+=s){const t=e[o],i=e[o+1],s=e[o+2];r.minimizeInPlaceFromFloats(t,i,s),n.maximizeInPlaceFromFloats(t,i,s)}}}function Ki(e,t,i,s=null,r){const n=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new X(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return r||(r=3),Wi.extractMinAndMax(e,t,i,r,n,a),s&&(n.x-=n.x*s.x+s.y,n.y-=n.y*s.x+s.y,n.z-=n.z*s.x+s.y,a.x+=a.x*s.x+s.y,a.y+=a.y*s.x+s.y,a.z+=a.z*s.x+s.y),{minimum:n,maximum:a}}e([p.filter(((...[e,t])=>!Array.isArray(e)&&!Array.isArray(t)))],Wi,"extractMinAndMaxIndexed",null),e([p.filter(((...[e])=>!Array.isArray(e)))],Wi,"extractMinAndMax",null);class Yi{static GetEffect(e){return void 0===e.getPipelineContext?e.effect:e}constructor(e,t=!0){this._wasPreviouslyReady=!1,this._forceRebindOnNextCall=!0,this._wasPreviouslyUsingInstances=null,this.effect=null,this.defines=null,this.drawContext=e.createDrawContext(),t&&(this.materialContext=e.createMaterialContext())}setEffect(e,t,i=!0){this.effect=e,void 0!==t&&(this.defines=t),i&&this.drawContext?.reset()}dispose(e=!1){if(this.effect){const t=this.effect;e?t.dispose():lt.SetImmediate((()=>{t.getEngine().onEndFrameObservable.addOnce((()=>{t.dispose()}))})),this.effect=null}this.drawContext?.dispose()}}class Xi{get materialDefines(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:this._getDrawWrapper()?.defines}set materialDefines(e){(this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)).defines=e}_getDrawWrapper(e,t=!1){e=e??this._engine.currentRenderPassId;let i=this._drawWrappers[e];return!i&&t&&(this._drawWrappers[e]=i=new Yi(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){t&&this._drawWrappers[e]?.dispose(i),this._drawWrappers[e]=void 0}get effect(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:this._getDrawWrapper()?.effect??null}get _drawWrapper(){return this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)}get _drawWrapperOverride(){return this._mainDrawWrapperOverride}_setMainDrawWrapperOverride(e){this._mainDrawWrapperOverride=e}setEffect(e,t=null,i,s=!0){const r=this._drawWrapper;r.setEffect(e,t,s),void 0!==i&&(r.materialContext=i),e||(r.defines=null,r.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers){if(void 0!==e)return void this._removeDrawWrapper(e,!0,t);for(const e of this._drawWrappers)e?.dispose(t)}this._drawWrappers=[]}static AddToMesh(e,t,i,s,r,n,a,o=!0){return new Xi(e,t,i,s,r,n,a,o)}constructor(e,t,i,s,r,n,a,o=!0,h=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=s,this.indexCount=r,this._mainDrawWrapperOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._wasDispatched=!1,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=n,this._renderingMesh=a||n,h&&n.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=n.subMeshes.length-1,o&&(this.refreshBoundingInfo(),n.computeWorldMatrix(!0))}get IsGlobal(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()&&0===this.indexStart&&this.indexCount===this._mesh.getTotalIndices()}getBoundingInfo(){return this.IsGlobal||this._mesh.hasThinInstances?this._mesh.getBoundingInfo():this._boundingInfo}setBoundingInfo(e){return this._boundingInfo=e,this}getMesh(){return this._mesh}getRenderingMesh(){return this._renderingMesh}getReplacementMesh(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null}getEffectiveMesh(){const e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh}getMaterial(e=!0){const t=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)??this._renderingMesh.material;if(!t)return e?this._mesh.getScene().defaultMaterial:null;if(this._isMultiMaterial(t)){const e=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==e&&(this._currentMaterial=e,this.resetDrawCache()),e}return t}_isMultiMaterial(e){return void 0!==e.getSubMaterial}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(wi.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;const t=this._renderingMesh.getIndices();let i;if(0===this.indexStart&&this.indexCount===t.length){const e=this._renderingMesh.getBoundingInfo();i={minimum:e.minimum.clone(),maximum:e.maximum.clone()}}else i=function(e,t,i,s,r=null){const n=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new X(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return Wi.extractMinAndMaxIndexed(e,t,i,s,n,a),r&&(n.x-=n.x*r.x+r.y,n.y-=n.y*r.x+r.y,n.z-=n.z*r.x+r.y,a.x+=a.x*r.x+r.y,a.y+=a.y*r.x+r.y,a.z+=a.z*r.x+r.y),{minimum:n,maximum:a}}(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Hi(i.minimum,i.maximum),this}_checkCollision(e){return this.getBoundingInfo()._checkCollision(e)}updateBoundingInfo(e){let t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this}isInFrustum(e){const t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)}isCompletelyInFrustum(e){const t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)}render(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this}_getLinesIndexBuffer(e,t){if(!this._linesIndexBuffer){const i=[];for(let t=this.indexStart;t<this.indexStart+this.indexCount;t+=3)i.push(e[t],e[t+1],e[t+1],e[t+2],e[t+2],e[t]);this._linesIndexBuffer=t.createIndexBuffer(i),this._linesIndexCount=i.length}return this._linesIndexBuffer}canIntersects(e){const t=this.getBoundingInfo();return!!t&&e.intersectsBox(t.boundingBox)}intersects(e,t,i,s,r){const n=this.getMaterial();if(!n)return null;let a=3,o=!1;switch(n.fillMode){case Ve.MATERIAL_PointListDrawMode:case Ve.MATERIAL_LineLoopDrawMode:case Ve.MATERIAL_LineStripDrawMode:case Ve.MATERIAL_TriangleFanDrawMode:return null;case Ve.MATERIAL_TriangleStripDrawMode:a=1,o=!0}return n.fillMode===Ve.MATERIAL_LineListDrawMode?i.length?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,s):this._intersectUnIndexedLines(e,t,i,this._mesh.intersectionThreshold,s):!i.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(e,t,i,s,r):this._intersectTriangles(e,t,i,a,o,s,r)}_intersectLines(e,t,i,s,r){let n=null;for(let a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){const o=t[i[a]],h=t[i[a+1]],l=e.intersectionSegment(o,h,s);if(!(l<0)&&((r||!n||l<n.distance)&&(n=new Ni(null,null,l),n.faceId=a/2,r)))break}return n}_intersectUnIndexedLines(e,t,i,s,r){let n=null;for(let i=this.verticesStart;i<this.verticesStart+this.verticesCount;i+=2){const a=t[i],o=t[i+1],h=e.intersectionSegment(a,o,s);if(!(h<0)&&((r||!n||h<n.distance)&&(n=new Ni(null,null,h),n.faceId=i/2,r)))break}return n}_intersectTriangles(e,t,i,s,r,n,a){let o=null,h=-1;for(let l=this.indexStart;l<this.indexStart+this.indexCount-(3-s);l+=s){h++;const s=i[l],c=i[l+1],u=i[l+2];if(r&&4294967295===u){l+=2;continue}const d=t[s],_=t[c],f=t[u];if(!d||!_||!f)continue;if(a&&!a(d,_,f,e,s,c,u))continue;const p=e.intersectsTriangle(d,_,f);if(p){if(p.distance<0)continue;if((n||!o||p.distance<o.distance)&&(o=p,o.faceId=h,n))break}}return o}_intersectUnIndexedTriangles(e,t,i,s,r){let n=null;for(let i=this.verticesStart;i<this.verticesStart+this.verticesCount;i+=3){const a=t[i],o=t[i+1],h=t[i+2];if(r&&!r(a,o,h,e,-1,-1,-1))continue;const l=e.intersectsTriangle(a,o,h);if(l){if(l.distance<0)continue;if((s||!n||l.distance<n.distance)&&(n=l,n.faceId=i/3,s))break}}return n}_rebuild(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)}clone(e,t){const i=new Xi(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,t,!1);if(!this.IsGlobal){const e=this.getBoundingInfo();if(!e)return i;i._boundingInfo=new Hi(e.minimum,e.maximum)}return i}dispose(e=!1){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);const t=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(t,1),this.resetDrawCache(void 0,e)}getClassName(){return"SubMesh"}static CreateFromIndices(e,t,i,s,r,n=!0){let a=Number.MAX_VALUE,o=-Number.MAX_VALUE;const h=(r||s).getIndices();for(let e=t;e<t+i;e++){const t=h[e];t<a&&(a=t),t>o&&(o=t)}return new Xi(e,a,o-a+1,t,i,s,r,n)}}class Qi{}class qi{constructor(){var e;this.uniqueId=0,this.metadata={},this._applyTo=(e=this._applyToCoroutine.bind(this),(...t)=>Ei(e(...t))),this.uniqueId=qi._UniqueIDGenerator,qi._UniqueIDGenerator++}set(e,t){switch(e.length||Ae.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case wi.PositionKind:this.positions=e;break;case wi.NormalKind:this.normals=e;break;case wi.TangentKind:this.tangents=e;break;case wi.UVKind:this.uvs=e;break;case wi.UV2Kind:this.uvs2=e;break;case wi.UV3Kind:this.uvs3=e;break;case wi.UV4Kind:this.uvs4=e;break;case wi.UV5Kind:this.uvs5=e;break;case wi.UV6Kind:this.uvs6=e;break;case wi.ColorKind:this.colors=e;break;case wi.MatricesIndicesKind:this.matricesIndices=e;break;case wi.MatricesWeightsKind:this.matricesWeights=e;break;case wi.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case wi.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}}applyToMesh(e,t){return this._applyTo(e,t,!1),this}applyToGeometry(e,t){return this._applyTo(e,t,!1),this}updateMesh(e){return this._update(e),this}updateGeometry(e){return this._update(e),this}*_applyToCoroutine(e,t=!1,i){if(this.positions&&(e.setVerticesData(wi.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(wi.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(wi.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(wi.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(wi.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(wi.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(wi.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(wi.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(wi.UV6Kind,this.uvs6,t),i&&(yield)),this.colors&&(e.setVerticesData(wi.ColorKind,this.colors,t),this.hasVertexAlpha&&void 0!==e.hasVertexAlpha&&(e.hasVertexAlpha=!0),i&&(yield)),this.matricesIndices&&(e.setVerticesData(wi.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(wi.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(wi.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(wi.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),i&&(yield)),this.indices?(e.setIndices(this.indices,null,t),i&&(yield)):e.setIndices([],null),e.subMeshes&&this.materialInfos&&this.materialInfos.length>1){const t=e;t.subMeshes=[];for(const e of this.materialInfos)new Xi(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,t)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(wi.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(wi.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(wi.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(wi.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(wi.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(wi.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(wi.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(wi.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(wi.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(wi.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(wi.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(wi.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(wi.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(wi.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,s=e.length){const r=J.Vector3[0],n=J.Vector3[1];for(let a=i;a<i+s;a+=3)X.FromArrayToRef(e,a,r),X.TransformCoordinatesToRef(r,t,n),e[a]=n.x,e[a+1]=n.y,e[a+2]=n.z}static _TransformVector3Normals(e,t,i=0,s=e.length){const r=J.Vector3[0],n=J.Vector3[1];for(let a=i;a<i+s;a+=3)X.FromArrayToRef(e,a,r),X.TransformNormalToRef(r,t,n),e[a]=n.x,e[a+1]=n.y,e[a+2]=n.z}static _TransformVector4Normals(e,t,i=0,s=e.length){const r=J.Vector4[0],n=J.Vector4[1];for(let a=i;a<i+s;a+=4)Q.FromArrayToRef(e,a,r),Q.TransformNormalToRef(r,t,n),e[a]=n.x,e[a+1]=n.y,e[a+2]=n.z,e[a+3]=n.w}static _FlipFaces(e,t=0,i=e.length){for(let s=t;s<t+i;s+=3){const t=e[s+1];e[s+1]=e[s+2],e[s+2]=t}}transform(e){const t=e.determinant()<0;return this.positions&&qi._TransformVector3Coordinates(this.positions,e),this.normals&&qi._TransformVector3Normals(this.normals,e),this.tangents&&qi._TransformVector4Normals(this.tangents,e),t&&this.indices&&qi._FlipFaces(this.indices),this}splitBasedOnMaterialID(){if(!this.materialInfos||this.materialInfos.length<2)return[this];const e=[];for(const t of this.materialInfos){const i=new qi;if(this.positions&&(i.positions=this.positions.slice(3*t.verticesStart,3*(t.verticesCount+t.verticesStart))),this.normals&&(i.normals=this.normals.slice(3*t.verticesStart,3*(t.verticesCount+t.verticesStart))),this.tangents&&(i.tangents=this.tangents.slice(4*t.verticesStart,4*(t.verticesCount+t.verticesStart))),this.colors&&(i.colors=this.colors.slice(4*t.verticesStart,4*(t.verticesCount+t.verticesStart))),this.uvs&&(i.uvs=this.uvs.slice(2*t.verticesStart,2*(t.verticesCount+t.verticesStart))),this.uvs2&&(i.uvs2=this.uvs2.slice(2*t.verticesStart,2*(t.verticesCount+t.verticesStart))),this.uvs3&&(i.uvs3=this.uvs3.slice(2*t.verticesStart,2*(t.verticesCount+t.verticesStart))),this.uvs4&&(i.uvs4=this.uvs4.slice(2*t.verticesStart,2*(t.verticesCount+t.verticesStart))),this.uvs5&&(i.uvs5=this.uvs5.slice(2*t.verticesStart,2*(t.verticesCount+t.verticesStart))),this.uvs6&&(i.uvs6=this.uvs6.slice(2*t.verticesStart,2*(t.verticesCount+t.verticesStart))),this.matricesIndices&&(i.matricesIndices=this.matricesIndices.slice(4*t.verticesStart,4*(t.verticesCount+t.verticesStart))),this.matricesIndicesExtra&&(i.matricesIndicesExtra=this.matricesIndicesExtra.slice(4*t.verticesStart,4*(t.verticesCount+t.verticesStart))),this.matricesWeights&&(i.matricesWeights=this.matricesWeights.slice(4*t.verticesStart,4*(t.verticesCount+t.verticesStart))),this.matricesWeightsExtra&&(i.matricesWeightsExtra=this.matricesWeightsExtra.slice(4*t.verticesStart,4*(t.verticesCount+t.verticesStart))),this.indices){i.indices=[];for(let e=t.indexStart;e<t.indexStart+t.indexCount;e++)i.indices.push(this.indices[e]-t.verticesStart)}const s=new Qi;s.indexStart=0,s.indexCount=i.indices?i.indices.length:0,s.materialIndex=t.materialIndex,s.verticesStart=0,s.verticesCount=(i.positions?i.positions.length:0)/3,i.materialInfos=[s],e.push(i)}return e}merge(e,t=!1,i=!1,s=!1,r=!1){const n=Array.isArray(e)?e.map((e=>({vertexData:e}))):[{vertexData:e}];return Ei(this._mergeCoroutine(void 0,n,t,!1,i,s,r))}*_mergeCoroutine(e,t,i=!1,s,r,n=!1,a=!1){this._validate();let o=t.map((e=>e.vertexData)),h=this;if(a)for(const e of o)e&&(e._validate(),!this.normals&&e.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&e.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&e.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&e.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&e.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&e.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&e.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&e.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&e.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&e.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&e.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&e.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&e.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const e of o)if(e)if(a)this.normals&&!e.normals&&(e.normals=new Float32Array(e.positions.length)),this.tangents&&!e.tangents&&(e.tangents=new Float32Array(e.positions.length/3*4)),this.uvs&&!e.uvs&&(e.uvs=new Float32Array(e.positions.length/3*2)),this.uvs2&&!e.uvs2&&(e.uvs2=new Float32Array(e.positions.length/3*2)),this.uvs3&&!e.uvs3&&(e.uvs3=new Float32Array(e.positions.length/3*2)),this.uvs4&&!e.uvs4&&(e.uvs4=new Float32Array(e.positions.length/3*2)),this.uvs5&&!e.uvs5&&(e.uvs5=new Float32Array(e.positions.length/3*2)),this.uvs6&&!e.uvs6&&(e.uvs6=new Float32Array(e.positions.length/3*2)),this.colors&&!e.colors&&(e.colors=new Float32Array(e.positions.length/3*4),e.colors.fill(1)),this.matricesIndices&&!e.matricesIndices&&(e.matricesIndices=new Float32Array(e.positions.length/3*4)),this.matricesWeights&&!e.matricesWeights&&(e.matricesWeights=new Float32Array(e.positions.length/3*4)),this.matricesIndicesExtra&&!e.matricesIndicesExtra&&(e.matricesIndicesExtra=new Float32Array(e.positions.length/3*4)),this.matricesWeightsExtra&&!e.matricesWeightsExtra&&(e.matricesWeightsExtra=new Float32Array(e.positions.length/3*4));else if(e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(n){let i=0,s=0,r=0;const n=[];let a=null;const l=[];for(const t of this.splitBasedOnMaterialID())l.push({vertexData:t,transform:e});for(const e of t)if(e.vertexData)for(const t of e.vertexData.splitBasedOnMaterialID())l.push({vertexData:t,transform:e.transform});l.sort(((e,t)=>{const i=e.vertexData.materialInfos?e.vertexData.materialInfos[0].materialIndex:0,s=t.vertexData.materialInfos?t.vertexData.materialInfos[0].materialIndex:0;return i>s?1:i===s?0:-1}));for(const e of l){const t=e.vertexData;if(i=t.materialInfos?t.materialInfos[0].materialIndex:0,a&&a.materialIndex===i)a.indexCount+=t.indices.length,a.verticesCount+=t.positions.length/3;else{const e=new Qi;e.materialIndex=i,e.indexStart=s,e.indexCount=t.indices.length,e.verticesStart=r,e.verticesCount=t.positions.length/3,n.push(e),a=e}s+=t.indices.length,r+=t.positions.length/3}const c=l.splice(0,1)[0];h=c.vertexData,e=c.transform,o=l.map((e=>e.vertexData)),t=l,this.materialInfos=n}const l=o.reduce(((e,t)=>e+(t.indices?.length??0)),h.indices?.length??0);let c=r||o.some((e=>e.indices===h.indices))?h.indices?.slice():h.indices;if(l>0){let r=c?.length??0;if(c||(c=new Array(l)),c.length!==l){if(Array.isArray(c))c.length=l;else{const e=i||c instanceof Uint32Array?new Uint32Array(l):new Uint16Array(l);e.set(c),c=e}e&&e.determinant()<0&&qi._FlipFaces(c,0,r)}let n=h.positions?h.positions.length/3:0;for(const{vertexData:e,transform:i}of t)if(e.indices){for(let t=0;t<e.indices.length;t++)c[r+t]=e.indices[t]+n;i&&i.determinant()<0&&qi._FlipFaces(c,r,e.indices.length),n+=e.positions.length/3,r+=e.indices.length,s&&(yield)}}return this.indices=c,this.positions=qi._MergeElement(wi.PositionKind,h.positions,e,t.map((e=>[e.vertexData.positions,e.transform]))),s&&(yield),h.normals&&(this.normals=qi._MergeElement(wi.NormalKind,h.normals,e,t.map((e=>[e.vertexData.normals,e.transform]))),s&&(yield)),h.tangents&&(this.tangents=qi._MergeElement(wi.TangentKind,h.tangents,e,t.map((e=>[e.vertexData.tangents,e.transform]))),s&&(yield)),h.uvs&&(this.uvs=qi._MergeElement(wi.UVKind,h.uvs,e,t.map((e=>[e.vertexData.uvs,e.transform]))),s&&(yield)),h.uvs2&&(this.uvs2=qi._MergeElement(wi.UV2Kind,h.uvs2,e,t.map((e=>[e.vertexData.uvs2,e.transform]))),s&&(yield)),h.uvs3&&(this.uvs3=qi._MergeElement(wi.UV3Kind,h.uvs3,e,t.map((e=>[e.vertexData.uvs3,e.transform]))),s&&(yield)),h.uvs4&&(this.uvs4=qi._MergeElement(wi.UV4Kind,h.uvs4,e,t.map((e=>[e.vertexData.uvs4,e.transform]))),s&&(yield)),h.uvs5&&(this.uvs5=qi._MergeElement(wi.UV5Kind,h.uvs5,e,t.map((e=>[e.vertexData.uvs5,e.transform]))),s&&(yield)),h.uvs6&&(this.uvs6=qi._MergeElement(wi.UV6Kind,h.uvs6,e,t.map((e=>[e.vertexData.uvs6,e.transform]))),s&&(yield)),h.colors&&(this.colors=qi._MergeElement(wi.ColorKind,h.colors,e,t.map((e=>[e.vertexData.colors,e.transform]))),(void 0!==h.hasVertexAlpha||t.some((e=>void 0!==e.vertexData.hasVertexAlpha)))&&(this.hasVertexAlpha=h.hasVertexAlpha||t.some((e=>e.vertexData.hasVertexAlpha))),s&&(yield)),h.matricesIndices&&(this.matricesIndices=qi._MergeElement(wi.MatricesIndicesKind,h.matricesIndices,e,t.map((e=>[e.vertexData.matricesIndices,e.transform]))),s&&(yield)),h.matricesWeights&&(this.matricesWeights=qi._MergeElement(wi.MatricesWeightsKind,h.matricesWeights,e,t.map((e=>[e.vertexData.matricesWeights,e.transform]))),s&&(yield)),h.matricesIndicesExtra&&(this.matricesIndicesExtra=qi._MergeElement(wi.MatricesIndicesExtraKind,h.matricesIndicesExtra,e,t.map((e=>[e.vertexData.matricesIndicesExtra,e.transform]))),s&&(yield)),h.matricesWeightsExtra&&(this.matricesWeightsExtra=qi._MergeElement(wi.MatricesWeightsExtraKind,h.matricesWeightsExtra,e,t.map((e=>[e.vertexData.matricesWeightsExtra,e.transform])))),this}static _MergeElement(e,t,i,s){const r=s.filter((e=>null!==e[0]&&void 0!==e[0]));if(!t&&0==r.length)return t;if(!t)return this._MergeElement(e,r[0][0],r[0][1],r.slice(1));const n=r.reduce(((e,t)=>e+t[0].length),t.length),a=e===wi.PositionKind?qi._TransformVector3Coordinates:e===wi.NormalKind?qi._TransformVector3Normals:e===wi.TangentKind?qi._TransformVector4Normals:()=>{};if(t instanceof Float32Array){const e=new Float32Array(n);e.set(t),i&&a(e,i,0,t.length);let s=t.length;for(const[t,i]of r)e.set(t,s),i&&a(e,i,s,t.length),s+=t.length;return e}{const e=new Array(n);for(let i=0;i<t.length;i++)e[i]=t[i];i&&a(e,i,0,t.length);let s=t.length;for(const[t,i]of r){for(let i=0;i<t.length;i++)e[s+i]=t[i];i&&a(e,i,s,t.length),s+=t.length}return e}}_validate(){if(!this.positions)throw new xe("Positions are required",ve.MeshInvalidPositionsError);const e=(e,t)=>{const i=wi.DeduceStride(e);if(t.length%i!=0)throw new Error("The "+e+"s array count must be a multiple of "+i);return t.length/i},t=e(wi.PositionKind,this.positions),i=(i,s)=>{const r=e(i,s);if(r!==t)throw new Error("The "+i+"s element count ("+r+") does not match the positions count ("+t+")")};this.normals&&i(wi.NormalKind,this.normals),this.tangents&&i(wi.TangentKind,this.tangents),this.uvs&&i(wi.UVKind,this.uvs),this.uvs2&&i(wi.UV2Kind,this.uvs2),this.uvs3&&i(wi.UV3Kind,this.uvs3),this.uvs4&&i(wi.UV4Kind,this.uvs4),this.uvs5&&i(wi.UV5Kind,this.uvs5),this.uvs6&&i(wi.UV6Kind,this.uvs6),this.colors&&i(wi.ColorKind,this.colors),this.matricesIndices&&i(wi.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(wi.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(wi.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(wi.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return qi.Parse(e)}serialize(){const e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=Array.from(this.indices),this.materialInfos){e.materialInfos=[];for(const t of this.materialInfos){const i={indexStart:t.indexStart,indexCount:t.indexCount,materialIndex:t.materialIndex,verticesStart:t.verticesStart,verticesCount:t.verticesCount};e.materialInfos.push(i)}}return e}static ExtractFromMesh(e,t,i){return qi._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return qi._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){const s=new qi;if(e.isVerticesDataPresent(wi.PositionKind)&&(s.positions=e.getVerticesData(wi.PositionKind,t,i)),e.isVerticesDataPresent(wi.NormalKind)&&(s.normals=e.getVerticesData(wi.NormalKind,t,i)),e.isVerticesDataPresent(wi.TangentKind)&&(s.tangents=e.getVerticesData(wi.TangentKind,t,i)),e.isVerticesDataPresent(wi.UVKind)&&(s.uvs=e.getVerticesData(wi.UVKind,t,i)),e.isVerticesDataPresent(wi.UV2Kind)&&(s.uvs2=e.getVerticesData(wi.UV2Kind,t,i)),e.isVerticesDataPresent(wi.UV3Kind)&&(s.uvs3=e.getVerticesData(wi.UV3Kind,t,i)),e.isVerticesDataPresent(wi.UV4Kind)&&(s.uvs4=e.getVerticesData(wi.UV4Kind,t,i)),e.isVerticesDataPresent(wi.UV5Kind)&&(s.uvs5=e.getVerticesData(wi.UV5Kind,t,i)),e.isVerticesDataPresent(wi.UV6Kind)&&(s.uvs6=e.getVerticesData(wi.UV6Kind,t,i)),e.isVerticesDataPresent(wi.ColorKind)){const r=e.geometry||e,n=r.getVertexBuffer(wi.ColorKind),a=r.getVerticesData(wi.ColorKind,t,i);if(3===n.getSize()){const e=new Float32Array(4*a.length/3);for(let t=0,i=0;t<a.length;t+=3,i+=4)e[i]=a[t],e[i+1]=a[t+1],e[i+2]=a[t+2],e[i+3]=1;s.colors=e}else{if(4!==n.getSize())throw new Error(`Unexpected number of color components: ${n.getSize()}`);s.colors=a}}return e.isVerticesDataPresent(wi.MatricesIndicesKind)&&(s.matricesIndices=e.getVerticesData(wi.MatricesIndicesKind,t,i)),e.isVerticesDataPresent(wi.MatricesWeightsKind)&&(s.matricesWeights=e.getVerticesData(wi.MatricesWeightsKind,t,i)),e.isVerticesDataPresent(wi.MatricesIndicesExtraKind)&&(s.matricesIndicesExtra=e.getVerticesData(wi.MatricesIndicesExtraKind,t,i)),e.isVerticesDataPresent(wi.MatricesWeightsExtraKind)&&(s.matricesWeightsExtra=e.getVerticesData(wi.MatricesWeightsExtraKind,t,i)),s.indices=e.getIndices(t,i),s}static CreateRibbon(e){throw te("ribbonBuilder")}static CreateBox(e){throw te("boxBuilder")}static CreateTiledBox(e){throw te("tiledBoxBuilder")}static CreateTiledPlane(e){throw te("tiledPlaneBuilder")}static CreateSphere(e){throw te("sphereBuilder")}static CreateCylinder(e){throw te("cylinderBuilder")}static CreateTorus(e){throw te("torusBuilder")}static CreateLineSystem(e){throw te("linesBuilder")}static CreateDashedLines(e){throw te("linesBuilder")}static CreateGround(e){throw te("groundBuilder")}static CreateTiledGround(e){throw te("groundBuilder")}static CreateGroundFromHeightMap(e){throw te("groundBuilder")}static CreatePlane(e){throw te("planeBuilder")}static CreateDisc(e){throw te("discBuilder")}static CreatePolygon(e,t,i,s,r,n,a){throw te("polygonBuilder")}static CreateIcoSphere(e){throw te("icoSphereBuilder")}static CreatePolyhedron(e){throw te("polyhedronBuilder")}static CreateCapsule(e={orientation:X.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){throw te("capsuleBuilder")}static CreateTorusKnot(e){throw te("torusKnotBuilder")}static ComputeNormals(e,t,i,s){let r=0,n=0,a=0,o=0,h=0,l=0,c=0,u=0,d=0,_=0,f=0,p=0,g=0,m=0,T=0,A=0,E=0,b=0,R=0,y=0,I=!1,M=!1,v=!1,x=!1,S=1,C=0,P=null;s&&(I=!!s.facetNormals,M=!!s.facetPositions,v=!!s.facetPartitioning,S=!0===s.useRightHandedSystem?-1:1,C=s.ratio||0,x=!!s.depthSort,P=s.distanceTo,x&&void 0===P&&(P=X.Zero()));let O=0,D=0,L=0,F=0;for(v&&s&&s.bbSize&&(O=s.subDiv.X*C/s.bbSize.x,D=s.subDiv.Y*C/s.bbSize.y,L=s.subDiv.Z*C/s.bbSize.z,F=s.subDiv.max*s.subDiv.max,s.facetPartitioning.length=0),r=0;r<e.length;r++)i[r]=0;const w=t.length/3|0;for(r=0;r<w;r++){if(p=3*t[3*r],g=p+1,m=p+2,T=3*t[3*r+1],A=T+1,E=T+2,b=3*t[3*r+2],R=b+1,y=b+2,n=e[p]-e[T],a=e[g]-e[A],o=e[m]-e[E],h=e[b]-e[T],l=e[R]-e[A],c=e[y]-e[E],u=S*(a*c-o*l),d=S*(o*h-n*c),_=S*(n*l-a*h),f=Math.sqrt(u*u+d*d+_*_),f=0===f?1:f,u/=f,d/=f,_/=f,I&&s&&(s.facetNormals[r].x=u,s.facetNormals[r].y=d,s.facetNormals[r].z=_),M&&s&&(s.facetPositions[r].x=(e[p]+e[T]+e[b])/3,s.facetPositions[r].y=(e[g]+e[A]+e[R])/3,s.facetPositions[r].z=(e[m]+e[E]+e[y])/3),v&&s){const t=Math.floor((s.facetPositions[r].x-s.bInfo.minimum.x*C)*O),i=Math.floor((s.facetPositions[r].y-s.bInfo.minimum.y*C)*D),n=Math.floor((s.facetPositions[r].z-s.bInfo.minimum.z*C)*L),a=Math.floor((e[p]-s.bInfo.minimum.x*C)*O),o=Math.floor((e[g]-s.bInfo.minimum.y*C)*D),h=Math.floor((e[m]-s.bInfo.minimum.z*C)*L),l=Math.floor((e[T]-s.bInfo.minimum.x*C)*O),c=Math.floor((e[A]-s.bInfo.minimum.y*C)*D),u=Math.floor((e[E]-s.bInfo.minimum.z*C)*L),d=Math.floor((e[b]-s.bInfo.minimum.x*C)*O),_=Math.floor((e[R]-s.bInfo.minimum.y*C)*D),f=Math.floor((e[y]-s.bInfo.minimum.z*C)*L),I=a+s.subDiv.max*o+F*h,M=l+s.subDiv.max*c+F*u,v=d+s.subDiv.max*_+F*f,x=t+s.subDiv.max*i+F*n;s.facetPartitioning[x]=s.facetPartitioning[x]?s.facetPartitioning[x]:new Array,s.facetPartitioning[I]=s.facetPartitioning[I]?s.facetPartitioning[I]:new Array,s.facetPartitioning[M]=s.facetPartitioning[M]?s.facetPartitioning[M]:new Array,s.facetPartitioning[v]=s.facetPartitioning[v]?s.facetPartitioning[v]:new Array,s.facetPartitioning[I].push(r),M!=I&&s.facetPartitioning[M].push(r),v!=M&&v!=I&&s.facetPartitioning[v].push(r),x!=I&&x!=M&&x!=v&&s.facetPartitioning[x].push(r)}if(x&&s&&s.facetPositions){const e=s.depthSortedFacets[r];e.ind=3*r,e.sqDistance=X.DistanceSquared(s.facetPositions[r],P)}i[p]+=u,i[g]+=d,i[m]+=_,i[T]+=u,i[A]+=d,i[E]+=_,i[b]+=u,i[R]+=d,i[y]+=_}for(r=0;r<i.length/3;r++)u=i[3*r],d=i[3*r+1],_=i[3*r+2],f=Math.sqrt(u*u+d*d+_*_),f=0===f?1:f,u/=f,d/=f,_/=f,i[3*r]=u,i[3*r+1]=d,i[3*r+2]=_}static _ComputeSides(e,t,i,s,r,n,a){const o=i.length,h=s.length;let l,c;switch(e=e||qi.DEFAULTSIDE){case qi.FRONTSIDE:break;case qi.BACKSIDE:for(l=0;l<o;l+=3){const e=i[l];i[l]=i[l+2],i[l+2]=e}for(c=0;c<h;c++)s[c]=-s[c];break;case qi.DOUBLESIDE:{const e=t.length,u=e/3;for(let i=0;i<e;i++)t[e+i]=t[i];for(l=0;l<o;l+=3)i[l+o]=i[l+2]+u,i[l+1+o]=i[l+1]+u,i[l+2+o]=i[l]+u;for(c=0;c<h;c++)s[h+c]=-s[c];const d=r.length;let _=0;for(_=0;_<d;_++)r[_+d]=r[_];for(n=n||new Q(0,0,1,1),a=a||new Q(0,0,1,1),_=0,l=0;l<d/2;l++)r[_]=n.x+(n.z-n.x)*r[_],r[_+1]=n.y+(n.w-n.y)*r[_+1],r[_+d]=a.x+(a.z-a.x)*r[_+d],r[_+d+1]=a.y+(a.w-a.y)*r[_+d+1],_+=2;break}}}static Parse(e){const t=new qi,i=e.positions;i&&t.set(i,wi.PositionKind);const s=e.normals;s&&t.set(s,wi.NormalKind);const r=e.tangents;r&&t.set(r,wi.TangentKind);const n=e.uvs;n&&t.set(n,wi.UVKind);const a=e.uvs2;a&&t.set(a,wi.UV2Kind);const o=e.uvs3;o&&t.set(o,wi.UV3Kind);const h=e.uvs4;h&&t.set(h,wi.UV4Kind);const l=e.uvs5;l&&t.set(l,wi.UV5Kind);const c=e.uvs6;c&&t.set(c,wi.UV6Kind);const u=e.colors;u&&(t.set(le.CheckColors4(u,i.length/3),wi.ColorKind),void 0!==e.hasVertexAlpha&&(t.hasVertexAlpha=e.hasVertexAlpha));const d=e.matricesIndices;d&&t.set(d,wi.MatricesIndicesKind);const _=e.matricesWeights;_&&t.set(_,wi.MatricesWeightsKind);const f=e.indices;f&&(t.indices=f);const p=e.materialInfos;if(p){t.materialInfos=[];for(const e of p){const i=new Qi;i.indexCount=e.indexCount,i.indexStart=e.indexStart,i.verticesCount=e.verticesCount,i.verticesStart=e.verticesStart,i.materialIndex=e.materialIndex,t.materialInfos.push(i)}}return t}static ImportVertexData(e,t){const i=qi.Parse(e);t.setAllVerticesData(i,e.updatable)}}qi.FRONTSIDE=0,qi.BACKSIDE=1,qi.DOUBLESIDE=2,qi.DEFAULTSIDE=0,qi._UniqueIDGenerator=0,e([p.filter(((...[e])=>!Array.isArray(e)))],qi,"_TransformVector3Coordinates",null),e([p.filter(((...[e])=>!Array.isArray(e)))],qi,"_TransformVector3Normals",null),e([p.filter(((...[e])=>!Array.isArray(e)))],qi,"_TransformVector4Normals",null),e([p.filter(((...[e])=>!Array.isArray(e)))],qi,"_FlipFaces",null);class ji{static get ForceFullSceneLoadingForIncremental(){return ji._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){ji._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return ji._ShowLoadingScreen}static set ShowLoadingScreen(e){ji._ShowLoadingScreen=e}static get loggingLevel(){return ji._LoggingLevel}static set loggingLevel(e){ji._LoggingLevel=e}static get CleanBoneMatrixWeights(){return ji._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){ji._CleanBoneMatrixWeights=e}}ji._ForceFullSceneLoadingForIncremental=!1,ji._ShowLoadingScreen=!0,ji._CleanBoneMatrixWeights=!1,ji._LoggingLevel=Ve.SCENELOADER_NO_LOGGING;class Zi{get boundingBias(){return this._boundingBias}set boundingBias(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)}static CreateGeometryForMesh(e){const t=new Zi(Zi.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,s=!1,r=null){this.delayLoadState=Ve.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||O.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=s,i?this.setAllVerticesData(i,s):this._totalVertices=0,this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),r&&(this.applyToMesh(r),r.computeWorldMatrix(!0)))}get extend(){return this._extend}getScene(){return this._scene}getEngine(){return this._engine}isReady(){return this.delayLoadState===Ve.DELAYLOADSTATE_LOADED||this.delayLoadState===Ve.DELAYLOADSTATE_NONE}get doNotSerialize(){for(let e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0}_rebuild(){this._vertexArrayObjects&&(this._vertexArrayObjects={}),0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer"));const e=new Set;for(const t in this._vertexBuffers)e.add(this._vertexBuffers[t].getWrapperBuffer());e.forEach((e=>{e._rebuild()}))}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,i=!1,s){i&&Array.isArray(t)&&(t=new Float32Array(t));const r=new wi(this._engine,t,e,{updatable:i,postponeInternalCreation:0===this._meshes.length,stride:s,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(r)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,i=!0){const s=e.getKind();this._vertexBuffers[s]&&i&&this._vertexBuffers[s].dispose(),e._buffer&&e._buffer._increaseReferences(),this._vertexBuffers[s]=e;const r=this._meshes,n=r.length;if(s===wi.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const i=this._extend&&this._extend.minimum||new X(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),s=this._extend&&this._extend.maximum||new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let e=0;e<n;e++){const t=r[e];t.buildBoundingInfo(i,s),t._createGlobalSubMesh(t.isUnIndexed),t.computeWorldMatrix(!0),t.synchronizeInstances()}}this._notifyUpdate(s)}updateVerticesDataDirectly(e,t,i,s=!1){const r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i,s),this._notifyUpdate(e))}updateVerticesData(e,t,i=!1){const s=this.getVertexBuffer(e);s&&(s.update(t),e===wi.PositionKind&&this._updateBoundingInfo(i,t),this._notifyUpdate(e))}_updateBoundingInfo(e,t){if(e&&this._updateExtend(t),this._resetPointsArrayCache(),e){const e=this._meshes;for(const t of e){t.hasBoundingInfo?t.getBoundingInfo().reConstruct(this._extend.minimum,this._extend.maximum):t.buildBoundingInfo(this._extend.minimum,this._extend.maximum);const e=t.subMeshes;for(const t of e)t.refreshBoundingInfo()}}}_bind(e,t,i,s){if(!e)return;void 0===t&&(t=this._indexBuffer);const r=this.getVertexBuffers();if(!r)return;if(t!=this._indexBuffer||!this._vertexArrayObjects&&!s)return void this._engine.bindBuffers(r,t,e,i);const n=s||this._vertexArrayObjects,a=this._engine;n[e.key]||(n[e.key]=a.recordVertexArrayObject(r,t,e,i)),a.bindVertexArrayObject(n[e.key],t)}getTotalVertices(){return this.isReady()?this._totalVertices:0}getVerticesData(e,t,i){const s=this.getVertexBuffer(e);return s?s.getFloatData(this._totalVertices,i||t&&1!==this._meshes.length):null}copyVerticesData(e,t){const i=this.getVertexBuffer(e);if(!i)return;t[e]||=new Float32Array(this._totalVertices*i.getSize());const s=i.getData();s&&function(e,t,i,s,r,n,a,o){const h=t*Oi(i),l=a*t;if(o.length!==l)throw new Error("Output length is not valid");if(i===Ve.FLOAT&&r===h)if(e instanceof Array){const t=s/4;o.set(e,t)}else if(e instanceof ArrayBuffer){const t=new Float32Array(e,s,l);o.set(t)}else{const t=e.byteOffset+s;if(3&t)return Ae.Warn("Float array must be aligned to 4-bytes border"),void o.set(new Float32Array(e.buffer.slice(t,t+l*Float32Array.BYTES_PER_ELEMENT)));const i=new Float32Array(e.buffer,t,l);o.set(i)}else Di(e,s,r,t,i,l,n,((e,i)=>{for(let s=0;s<t;s++)o[i+s]=e[s]}))}(s,i.getSize(),i.type,i.byteOffset,i.byteStride,i.normalized,this._totalVertices,t[e])}isVertexBufferUpdatable(e){const t=this._vertexBuffers[e];return!!t&&t.isUpdatable()}getVertexBuffer(e){return this.isReady()?this._vertexBuffers[e]:null}getVertexBuffers(){return this.isReady()?this._vertexBuffers:null}isVerticesDataPresent(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)}getVerticesDataKinds(){const e=[];let t;if(!this._vertexBuffers&&this._delayInfo)for(t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e}updateIndices(e,t,i=!1){if(this._indexBuffer)if(this._indexBufferIsUpdatable){const s=e.length!==this._indices.length;if(i||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),s)for(const e of this._meshes)e._createGlobalSubMesh(!0)}else this.setIndices(e,null,!0)}setIndexBuffer(e,t,i){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=i,e.is32Bits||=this._totalIndices>65535;for(const e of this._meshes)e._createGlobalSubMesh(!0),e.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,i=!1,s=!1){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,this._indexBufferIsUpdatable=i,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i,"Geometry_"+this.id+"_IndexBuffer")),null!=t&&(this._totalVertices=t);for(const e of this._meshes)e._createGlobalSubMesh(!s),e.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?void 0!==this._totalIndices?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;const i=this._indices;return t||e&&1!==this._meshes.length?i.slice():i}getIndexBuffer(){return this.isReady()?this._indexBuffer:null}_releaseVertexArrayObject(e=null){e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])}releaseForMesh(e,t){const i=this._meshes,s=i.indexOf(e);-1!==s&&(i.splice(s,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,0===i.length&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;const t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();const i=this._meshes;e._geometry=this,e._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):this._boundingInfo&&e.setBoundingInfo(this._boundingInfo)}_updateExtend(e=null){if(this.useBoundingInfoFromGeometry&&this._boundingInfo)this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()};else{if(!e&&!(e=this.getVerticesData(wi.PositionKind)))return;this._extend=Ki(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){const t=this._meshes.length;for(const i in this._vertexBuffers)1===t&&this._vertexBuffers[i].create(),i===wi.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo());1===t&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(const e of this._meshes)e._markSubMeshesAsAttributesDirty()}load(e,t){this.delayLoadState!==Ve.DELAYLOADSTATE_LOADING&&(this.isReady()?t&&t():(this.delayLoadState=Ve.DELAYLOADSTATE_LOADING,this._queueLoad(e,t)))}_queueLoad(e,t){this.delayLoadingFile&&(e.addPendingData(this),e._loadFile(this.delayLoadingFile,(i=>{if(!this._delayLoadingFunction)return;this._delayLoadingFunction(JSON.parse(i),this),this.delayLoadState=Ve.DELAYLOADSTATE_LOADED,this._delayInfo=[],e.removePendingData(this);const s=this._meshes,r=s.length;for(let e=0;e<r;e++)this._applyToMesh(s[e]);t&&t()}),void 0,!0))}toLeftHanded(){const e=this.getIndices(!1);if(null!=e&&e.length>0){for(let t=0;t<e.length;t+=3){const i=e[t+0];e[t+0]=e[t+2],e[t+2]=i}this.setIndices(e)}const t=this.getVerticesData(wi.PositionKind,!1);if(null!=t&&t.length>0){for(let e=0;e<t.length;e+=3)t[e+2]=-t[e+2];this.setVerticesData(wi.PositionKind,t,!1)}const i=this.getVerticesData(wi.NormalKind,!1);if(null!=i&&i.length>0){for(let e=0;e<i.length;e+=3)i[e+2]=-i[e+2];this.setVerticesData(wi.NormalKind,i,!1)}}_resetPointsArrayCache(){this._positions=null}_generatePointsArray(){if(this._positions)return!0;const e=this.getVerticesData(wi.PositionKind);if(!e||0===e.length)return!1;for(let t=3*this._positionsCache.length,i=this._positionsCache.length;t<e.length;t+=3,++i)this._positionsCache[i]=X.FromArray(e,t);for(let t=0,i=0;t<e.length;t+=3,++i)this._positionsCache[i].set(e[0+t],e[1+t],e[2+t]);return this._positionsCache.length=e.length/3,this._positions=this._positionsCache,!0}isDisposed(){return this._isDisposed}_disposeVertexArrayObjects(){if(this._vertexArrayObjects){for(const e in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);this._vertexArrayObjects={};const e=this._meshes,t=e.length;for(let i=0;i<t;i++)e[i]._invalidateInstanceVertexArrayObject()}}dispose(){const e=this._meshes,t=e.length;let i;for(i=0;i<t;i++)this.releaseForMesh(e[i]);this._meshes.length=0,this._disposeVertexArrayObjects();for(const e in this._vertexBuffers)this._vertexBuffers[e].dispose();if(this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=Ve.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._parentContainer){const e=this._parentContainer.geometries.indexOf(this);e>-1&&this._parentContainer.geometries.splice(e,1),this._parentContainer=null}this._isDisposed=!0}copy(e){const t=new qi;t.indices=[];const i=this.getIndices();if(i)for(let e=0;e<i.length;e++)t.indices.push(i[e]);let s,r=!1,n=!1;for(s in this._vertexBuffers){const e=this.getVerticesData(s);if(e&&(e instanceof Float32Array?t.set(new Float32Array(e),s):t.set(e.slice(0),s),!n)){const e=this.getVertexBuffer(s);e&&(r=e.isUpdatable(),n=!r)}}const a=new Zi(e,this._scene,t,r);for(s in a.delayLoadState=this.delayLoadState,a.delayLoadingFile=this.delayLoadingFile,a._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)a._delayInfo=a._delayInfo||[],a._delayInfo.push(s);return a._boundingInfo=new Hi(this._extend.minimum,this._extend.maximum),a}serialize(){const e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,se&&se.HasTags(this)&&(e.tags=se.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){this._indices=[],this._resetPointsArrayCache();for(const e in this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,e)&&(this._vertexBuffers[e]._buffer._data=null)}serializeVerticeData(){const e=this.serialize();return this.isVerticesDataPresent(wi.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(wi.PositionKind)),this.isVertexBufferUpdatable(wi.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(wi.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(wi.NormalKind)),this.isVertexBufferUpdatable(wi.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(wi.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(wi.TangentKind)),this.isVertexBufferUpdatable(wi.TangentKind)&&(e.tangents._updatable=!0)),this.isVerticesDataPresent(wi.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(wi.UVKind)),this.isVertexBufferUpdatable(wi.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(wi.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(wi.UV2Kind)),this.isVertexBufferUpdatable(wi.UV2Kind)&&(e.uvs2._updatable=!0)),this.isVerticesDataPresent(wi.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(wi.UV3Kind)),this.isVertexBufferUpdatable(wi.UV3Kind)&&(e.uvs3._updatable=!0)),this.isVerticesDataPresent(wi.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(wi.UV4Kind)),this.isVertexBufferUpdatable(wi.UV4Kind)&&(e.uvs4._updatable=!0)),this.isVerticesDataPresent(wi.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(wi.UV5Kind)),this.isVertexBufferUpdatable(wi.UV5Kind)&&(e.uvs5._updatable=!0)),this.isVerticesDataPresent(wi.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(wi.UV6Kind)),this.isVertexBufferUpdatable(wi.UV6Kind)&&(e.uvs6._updatable=!0)),this.isVerticesDataPresent(wi.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(wi.ColorKind)),this.isVertexBufferUpdatable(wi.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(wi.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(wi.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(wi.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(wi.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(wi.MatricesWeightsKind)),this.isVertexBufferUpdatable(wi.MatricesWeightsKind)&&(e.matricesWeights._updatable=!0)),e.indices=this._toNumberArray(this.getIndices()),e}static ExtractFromMesh(e,t){const i=e._geometry;return i?i.copy(t):null}static RandomId(){return pi.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i<t.geometries.length;i++)if(t.geometries[i]._loadedUniqueId===e)return t.geometries[i];return null}static _ImportGeometry(e,t){const i=t.getScene(),s=e.geometryUniqueId,r=e.geometryId;if(s||r){const e=s?this._GetGeometryByLoadedUniqueId(s,i):i.getGeometryById(r);e&&e.applyToMesh(t)}else if(e instanceof ArrayBuffer){const i=t._binaryInfo;if(i.positionsAttrDesc&&i.positionsAttrDesc.count>0){const s=new Float32Array(e,i.positionsAttrDesc.offset,i.positionsAttrDesc.count);t.setVerticesData(wi.PositionKind,s,!1)}if(i.normalsAttrDesc&&i.normalsAttrDesc.count>0){const s=new Float32Array(e,i.normalsAttrDesc.offset,i.normalsAttrDesc.count);t.setVerticesData(wi.NormalKind,s,!1)}if(i.tangetsAttrDesc&&i.tangetsAttrDesc.count>0){const s=new Float32Array(e,i.tangetsAttrDesc.offset,i.tangetsAttrDesc.count);t.setVerticesData(wi.TangentKind,s,!1)}if(i.uvsAttrDesc&&i.uvsAttrDesc.count>0){const s=new Float32Array(e,i.uvsAttrDesc.offset,i.uvsAttrDesc.count);t.setVerticesData(wi.UVKind,s,!1)}if(i.uvs2AttrDesc&&i.uvs2AttrDesc.count>0){const s=new Float32Array(e,i.uvs2AttrDesc.offset,i.uvs2AttrDesc.count);t.setVerticesData(wi.UV2Kind,s,!1)}if(i.uvs3AttrDesc&&i.uvs3AttrDesc.count>0){const s=new Float32Array(e,i.uvs3AttrDesc.offset,i.uvs3AttrDesc.count);t.setVerticesData(wi.UV3Kind,s,!1)}if(i.uvs4AttrDesc&&i.uvs4AttrDesc.count>0){const s=new Float32Array(e,i.uvs4AttrDesc.offset,i.uvs4AttrDesc.count);t.setVerticesData(wi.UV4Kind,s,!1)}if(i.uvs5AttrDesc&&i.uvs5AttrDesc.count>0){const s=new Float32Array(e,i.uvs5AttrDesc.offset,i.uvs5AttrDesc.count);t.setVerticesData(wi.UV5Kind,s,!1)}if(i.uvs6AttrDesc&&i.uvs6AttrDesc.count>0){const s=new Float32Array(e,i.uvs6AttrDesc.offset,i.uvs6AttrDesc.count);t.setVerticesData(wi.UV6Kind,s,!1)}if(i.colorsAttrDesc&&i.colorsAttrDesc.count>0){const s=new Float32Array(e,i.colorsAttrDesc.offset,i.colorsAttrDesc.count);t.setVerticesData(wi.ColorKind,s,!1,i.colorsAttrDesc.stride)}if(i.matricesIndicesAttrDesc&&i.matricesIndicesAttrDesc.count>0){const s=new Int32Array(e,i.matricesIndicesAttrDesc.offset,i.matricesIndicesAttrDesc.count),r=[];for(let e=0;e<s.length;e++){const t=s[e];r.push(255&t),r.push((65280&t)>>8),r.push((16711680&t)>>16),r.push(t>>24&255)}t.setVerticesData(wi.MatricesIndicesKind,r,!1)}if(i.matricesIndicesExtraAttrDesc&&i.matricesIndicesExtraAttrDesc.count>0){const s=new Int32Array(e,i.matricesIndicesExtraAttrDesc.offset,i.matricesIndicesExtraAttrDesc.count),r=[];for(let e=0;e<s.length;e++){const t=s[e];r.push(255&t),r.push((65280&t)>>8),r.push((16711680&t)>>16),r.push(t>>24&255)}t.setVerticesData(wi.MatricesIndicesExtraKind,r,!1)}if(i.matricesWeightsAttrDesc&&i.matricesWeightsAttrDesc.count>0){const s=new Float32Array(e,i.matricesWeightsAttrDesc.offset,i.matricesWeightsAttrDesc.count);t.setVerticesData(wi.MatricesWeightsKind,s,!1)}if(i.indicesAttrDesc&&i.indicesAttrDesc.count>0){const s=new Int32Array(e,i.indicesAttrDesc.offset,i.indicesAttrDesc.count);t.setIndices(s,null)}if(i.subMeshesAttrDesc&&i.subMeshesAttrDesc.count>0){const s=new Int32Array(e,i.subMeshesAttrDesc.offset,5*i.subMeshesAttrDesc.count);t.subMeshes=[];for(let e=0;e<i.subMeshesAttrDesc.count;e++){const i=s[5*e+0],r=s[5*e+1],n=s[5*e+2],a=s[5*e+3],o=s[5*e+4];Xi.AddToMesh(i,r,n,a,o,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(wi.PositionKind,e.positions,e.positions._updatable),t.setVerticesData(wi.NormalKind,e.normals,e.normals._updatable),e.tangents&&t.setVerticesData(wi.TangentKind,e.tangents,e.tangents._updatable),e.uvs&&t.setVerticesData(wi.UVKind,e.uvs,e.uvs._updatable),e.uvs2&&t.setVerticesData(wi.UV2Kind,e.uvs2,e.uvs2._updatable),e.uvs3&&t.setVerticesData(wi.UV3Kind,e.uvs3,e.uvs3._updatable),e.uvs4&&t.setVerticesData(wi.UV4Kind,e.uvs4,e.uvs4._updatable),e.uvs5&&t.setVerticesData(wi.UV5Kind,e.uvs5,e.uvs5._updatable),e.uvs6&&t.setVerticesData(wi.UV6Kind,e.uvs6,e.uvs6._updatable),e.colors&&t.setVerticesData(wi.ColorKind,le.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(e.matricesIndices._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(wi.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable);else{const i=[];for(let t=0;t<e.matricesIndices.length;t++){const s=e.matricesIndices[t];i.push(255&s),i.push((65280&s)>>8),i.push((16711680&s)>>16),i.push(s>>24&255)}t.setVerticesData(wi.MatricesIndicesKind,i,e.matricesIndices._updatable)}if(e.matricesIndicesExtra)if(e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(wi.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable);else{const i=[];for(let t=0;t<e.matricesIndicesExtra.length;t++){const s=e.matricesIndicesExtra[t];i.push(255&s),i.push((65280&s)>>8),i.push((16711680&s)>>16),i.push(s>>24&255)}t.setVerticesData(wi.MatricesIndicesExtraKind,i,e.matricesIndicesExtra._updatable)}e.matricesWeights&&(Zi._CleanMatricesWeights(e,t),t.setVerticesData(wi.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(wi.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let i=0;i<e.subMeshes.length;i++){const s=e.subMeshes[i];Xi.AddToMesh(s.materialIndex,s.verticesStart,s.verticesCount,s.indexStart,s.indexCount,t)}}t._shouldGenerateFlatShading&&(t.convertToFlatShadedMesh(),t._shouldGenerateFlatShading=!1),t.computeWorldMatrix(!0),i.onMeshImportedObservable.notifyObservers(t)}static _CleanMatricesWeights(e,t){const i=.001;if(!ji.CleanBoneMatrixWeights)return;let s=0;if(!(e.skeletonId>-1))return;{const i=t.getScene().getLastSkeletonById(e.skeletonId);if(!i)return;s=i.bones.length}const r=t.getVerticesData(wi.MatricesIndicesKind),n=t.getVerticesData(wi.MatricesIndicesExtraKind),a=e.matricesWeights,o=e.matricesWeightsExtra,h=e.numBoneInfluencer,l=a.length;for(let e=0;e<l;e+=4){let t=0,l=-1;for(let s=0;s<4;s++){const r=a[e+s];t+=r,r<i&&l<0&&(l=s)}if(o)for(let s=0;s<4;s++){const r=o[e+s];t+=r,r<i&&l<0&&(l=s+4)}if((l<0||l>h-1)&&(l=h-1),t>i){const i=1/t;for(let t=0;t<4;t++)a[e+t]*=i;if(o)for(let t=0;t<4;t++)o[e+t]*=i}else l>=4?(o[e+l-4]=1-t,n[e+l-4]=s):(a[e+l]=1-t,r[e+l]=s)}t.setVerticesData(wi.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(wi.MatricesIndicesExtraKind,n)}static Parse(e,t,i){const s=new Zi(e.id,t,void 0,e.updatable);return s._loadedUniqueId=e.uniqueId,se&&se.AddTagsTo(s,e.tags),e.delayLoadingFile?(s.delayLoadState=Ve.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=i+e.delayLoadingFile,s._boundingInfo=new Hi(X.FromArray(e.boundingBoxMinimum),X.FromArray(e.boundingBoxMaximum)),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(wi.UVKind),e.hasUVs2&&s._delayInfo.push(wi.UV2Kind),e.hasUVs3&&s._delayInfo.push(wi.UV3Kind),e.hasUVs4&&s._delayInfo.push(wi.UV4Kind),e.hasUVs5&&s._delayInfo.push(wi.UV5Kind),e.hasUVs6&&s._delayInfo.push(wi.UV6Kind),e.hasColors&&s._delayInfo.push(wi.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(wi.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(wi.MatricesWeightsKind),s._delayLoadingFunction=qi.ImportVertexData):qi.ImportVertexData(e,s),t.pushGeometry(s,!0),s}}const Ji=j.Compose(X.One(),q.FromEulerAngles(0,Math.PI,0),X.Zero());class $i extends fe{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=!!(this._billboardMode&$i.BILLBOARDMODE_USE_POSITION),this._computeUseBillboardPath())}get preserveParentRotationForBillboard(){return this._preserveParentRotationForBillboard}set preserveParentRotationForBillboard(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e,this._computeUseBillboardPath())}_computeUseBillboardPath(){this._cache.useBillboardPath=this._billboardMode!==$i.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,i=!0){super(e,t,!1),this._forward=new X(0,0,1),this._up=new X(0,1,0),this._right=new X(1,0,0),this._position=X.Zero(),this._rotation=X.Zero(),this._rotationQuaternion=null,this._scaling=X.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=$i.BILLBOARDMODE_NONE,this._preserveParentRotationForBillboard=!1,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=j.Zero(),this._usePivotMatrix=!1,this._absolutePosition=X.Zero(),this._absoluteScaling=X.Zero(),this._absoluteRotationQuaternion=q.Identity(),this._pivotMatrix=j.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new A,this._nonUniformScaling=!1,i&&this.getScene().addTransformNode(this)}getClassName(){return"TransformNode"}get position(){return this._position}set position(e){this._position=e,this._markAsDirtyInternal()}isUsingPivotMatrix(){return this._usePivotMatrix}isUsingPostMultiplyPivotMatrix(){return this._postMultiplyPivotMatrix}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._rotationQuaternion=null,this._markAsDirtyInternal()}get scaling(){return this._scaling}set scaling(e){this._scaling=e,this._markAsDirtyInternal()}get rotationQuaternion(){return this._rotationQuaternion}set rotationQuaternion(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._markAsDirtyInternal()}_markAsDirtyInternal(){this._isDirty||(this._isDirty=!0,this.customMarkAsDirty&&this.customMarkAsDirty())}get forward(){return X.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return X.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return X.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()}updatePoseMatrix(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)}getPoseMatrix(){return this._poseMatrix||(this._poseMatrix=j.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return this._billboardMode===e.billboardMode&&this._billboardMode===$i.BILLBOARDMODE_NONE&&(!e.pivotMatrixUpdated&&(!this._infiniteDistance&&(!this._position._isDirty&&(!this._scaling._isDirty&&!(this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)))))}_initCache(){super._initCache();const e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1,e.useBillboardPath=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=j.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,i){const s=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);s&&i&&i(this,s);for(const e of this.getChildTransformNodes(!0))e.instantiateHierarchy(s,t,i);return s}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||q.Identity(),e.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=e,this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._afterComputeWorldMatrix()):(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this}unfreezeWorldMatrix(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this}get isWorldMatrixFrozen(){return this._isWorldMatrixFrozen}getAbsolutePosition(){return this.computeWorldMatrix(),this._absolutePosition}setAbsolutePosition(e){if(!e)return this;let t,i,s;if(void 0===e.x){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],s=arguments[2]}else t=e.x,i=e.y,s=e.z;if(this.parent){const e=J.Matrix[0];this.parent.getWorldMatrix().invertToRef(e),X.TransformCoordinatesFromFloatsToRef(t,i,s,e,this.position)}else this.position.x=t,this.position.y=i,this.position.z=s;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=X.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const e=J.Matrix[0];return this._localMatrix.invertToRef(e),X.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=X.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,i=0,s=0,r=0){const n=$i._LookAtVectorCache,a=0===r?this.position:this.getAbsolutePosition();if(e.subtractToRef(a,n),this.setDirection(n,t,i,s),1===r&&this.parent)if(this.rotationQuaternion){const e=J.Matrix[0];this.rotationQuaternion.toRotationMatrix(e);const t=J.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(t),t.invert(),e.multiplyToRef(t,e),this.rotationQuaternion.fromRotationMatrix(e)}else{const e=J.Quaternion[0];q.FromEulerVectorToRef(this.rotation,e);const t=J.Matrix[0];e.toRotationMatrix(t);const i=J.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(i),i.invert(),t.multiplyToRef(i,t),e.fromRotationMatrix(t),e.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){const t=X.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return X.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,i=0,s=0){const r=-Math.atan2(e.z,e.x)+Math.PI/2,n=Math.sqrt(e.x*e.x+e.z*e.z),a=-Math.atan2(e.y,n);return this.rotationQuaternion?q.RotationYawPitchRollToRef(r+t,a+i,s,this.rotationQuaternion):(this.rotation.x=a+i,this.rotation.y=r+t,this.rotation.z=s),this}setPivotPoint(e,t=0){0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);const i=this.getWorldMatrix();if(1==t){const t=J.Matrix[0];i.invertToRef(t),e=X.TransformCoordinates(e,t)}return this.setPivotMatrix(j.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){const e=X.Zero();return this.getPivotPointToRef(e),e}getPivotPointToRef(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this}getAbsolutePivotPoint(){const e=X.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),X.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this}markAsDirty(e){if(this._isDirty)return this;if(this._children)for(const t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,i=!1){if(!e&&!this.parent)return this;const s=J.Quaternion[0],r=J.Vector3[0],n=J.Vector3[1],a=J.Matrix[1];j.IdentityToRef(a);const o=J.Matrix[0];this.computeWorldMatrix(!0);let h=this.rotationQuaternion;return h||(h=$i._TmpRotation,q.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,h)),j.ComposeToRef(this.scaling,h,this.position,o),this.parent&&o.multiplyToRef(this.parent.computeWorldMatrix(!0),o),e&&(e.computeWorldMatrix(!0).invertToRef(a),o.multiplyToRef(a,o)),o.decompose(n,s,r,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(s):s.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(n),this.position.copyFrom(r),this.parent=e,i&&this.setPivotMatrix(j.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.setParent(null,t),this}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=e?this._currentParentWhenAttachingToBone:null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,i){let s;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),i&&0!==i){if(this.parent){const i=this.parent.getWorldMatrix(),s=J.Matrix[0];i.invertToRef(s),e=X.TransformNormal(e,s),i.determinant()<0&&(t*=-1)}s=q.RotationAxisToRef(e,t,$i._RotationAxisCache),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else s=q.RotationAxisToRef(e,t,$i._RotationAxisCache),this.rotationQuaternion.multiplyToRef(s,this.rotationQuaternion);return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=q.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const s=J.Vector3[0],r=J.Vector3[1],n=J.Vector3[2],a=J.Quaternion[0],o=J.Matrix[0],h=J.Matrix[1],l=J.Matrix[2],c=J.Matrix[3];return e.subtractToRef(this.position,s),j.TranslationToRef(s.x,s.y,s.z,o),j.TranslationToRef(-s.x,-s.y,-s.z,h),j.RotationAxisToRef(t,i,l),h.multiplyToRef(l,c),c.multiplyToRef(o,c),c.decompose(r,a,n),this.position.addInPlace(n),a.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,i){const s=e.scale(t);if(i&&0!==i)this.setAbsolutePosition(this.getAbsolutePosition().add(s));else{const e=this.getPositionExpressedInLocalSpace().add(s);this.setPositionWithLocalVector(e)}return this}addRotation(e,t,i){let s;this.rotationQuaternion?s=this.rotationQuaternion:(s=J.Quaternion[1],q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,s));const r=J.Quaternion[0];return q.RotationYawPitchRollToRef(t,e,i,r),s.multiplyInPlace(r),this.rotationQuaternion||s.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==$i.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;const i=this.getScene().getRenderId();if(!this._isDirty&&!e&&(this._currentRenderId===i||this.isSynchronized()))return this._currentRenderId=i,this._worldMatrix;t=t||this.getScene().activeCamera,this._updateCache();const s=this._cache;s.pivotMatrixUpdated=!1,s.billboardMode=this.billboardMode,s.infiniteDistance=this.infiniteDistance,s.parent=this._parentNode,this._currentRenderId=i,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;const r=this._getEffectiveParent(),n=$i._TmpScaling;let a,o=this._position;if(this._infiniteDistance&&!this.parent&&t){const e=t.getWorldMatrix(),i=new X(e.m[12],e.m[13],e.m[14]);o=$i._TmpTranslation,o.copyFromFloats(this._position.x+i.x,this._position.y+i.y,this._position.z+i.z)}if(n.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion){if(this._rotationQuaternion._isDirty=!1,a=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion){this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(q.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))}}else a=$i._TmpRotation,q.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,a);if(this._usePivotMatrix){const e=J.Matrix[1];j.ScalingToRef(n.x,n.y,n.z,e);const t=J.Matrix[0];a.toRotationMatrix(t),this._pivotMatrix.multiplyToRef(e,J.Matrix[4]),J.Matrix[4].multiplyToRef(t,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(o.x,o.y,o.z)}else j.ComposeToRef(n,a,o,this._localMatrix);if(r&&r.getWorldMatrix){if(e&&r.computeWorldMatrix(e),s.useBillboardPath){if(this._transformToBoneReferal){const e=this.parent;e.getSkeleton().prepare(),e.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),J.Matrix[7])}else J.Matrix[7].copyFrom(r.getWorldMatrix());const e=J.Vector3[5],t=J.Vector3[6],i=J.Quaternion[0];J.Matrix[7].decompose(t,i,e),j.ScalingToRef(t.x,t.y,t.z,J.Matrix[7]),J.Matrix[7].setTranslation(e),$i.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(i,e),this._localMatrix.setTranslation(e)),this._localMatrix.multiplyToRef(J.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const e=this.parent;e.getSkeleton().prepare(),this._localMatrix.multiplyToRef(e.getFinalMatrix(),J.Matrix[6]),J.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(r.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(s.useBillboardPath&&t&&this.billboardMode&&!s.useBillboardPosition){const e=J.Vector3[0];if(this._worldMatrix.getTranslationToRef(e),J.Matrix[1].copyFrom(t.getViewMatrix()),this._scene.useRightHandedSystem&&J.Matrix[1].multiplyToRef(Ji,J.Matrix[1]),J.Matrix[1].setTranslationFromFloats(0,0,0),J.Matrix[1].invertToRef(J.Matrix[0]),(this.billboardMode&$i.BILLBOARDMODE_ALL)!==$i.BILLBOARDMODE_ALL){J.Matrix[0].decompose(void 0,J.Quaternion[0],void 0);const e=J.Vector3[1];J.Quaternion[0].toEulerAnglesToRef(e),(this.billboardMode&$i.BILLBOARDMODE_X)!==$i.BILLBOARDMODE_X&&(e.x=0),(this.billboardMode&$i.BILLBOARDMODE_Y)!==$i.BILLBOARDMODE_Y&&(e.y=0),(this.billboardMode&$i.BILLBOARDMODE_Z)!==$i.BILLBOARDMODE_Z&&(e.z=0),j.RotationYawPitchRollToRef(e.y,e.x,e.z,J.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(J.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(J.Vector3[0])}else if(s.useBillboardPath&&t&&s.useBillboardPosition){const e=J.Vector3[0];this._worldMatrix.getTranslationToRef(e);const i=t.globalPosition;this._worldMatrix.invertToRef(J.Matrix[1]);const s=J.Vector3[1];X.TransformCoordinatesToRef(i,J.Matrix[1],s),s.normalize();const r=-Math.atan2(s.z,s.x)+Math.PI/2,n=Math.sqrt(s.x*s.x+s.z*s.z),a=-Math.atan2(s.y,n);if(q.RotationYawPitchRollToRef(r,a,0,J.Quaternion[0]),(this.billboardMode&$i.BILLBOARDMODE_ALL)!==$i.BILLBOARDMODE_ALL){const e=J.Vector3[1];J.Quaternion[0].toEulerAnglesToRef(e),(this.billboardMode&$i.BILLBOARDMODE_X)!==$i.BILLBOARDMODE_X&&(e.x=0),(this.billboardMode&$i.BILLBOARDMODE_Y)!==$i.BILLBOARDMODE_Y&&(e.y=0),(this.billboardMode&$i.BILLBOARDMODE_Z)!==$i.BILLBOARDMODE_Z&&(e.z=0),j.RotationYawPitchRollToRef(e.y,e.x,e.z,J.Matrix[0])}else j.FromQuaternionToRef(J.Quaternion[0],J.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(J.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(J.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):r&&r._nonUniformScaling?this._updateNonUniformScalingState(r._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=j.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){const e=this.getChildren();for(let t=0;t<e.length;++t){const i=e[t];if(i){i.computeWorldMatrix();const e=J.Matrix[0];i._localMatrix.multiplyToRef(this._localMatrix,e);const t=J.Quaternion[0];e.decompose(i.scaling,t,i.position),i.rotationQuaternion?i.rotationQuaternion.copyFrom(t):t.toEulerAnglesToRef(i.rotation)}}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=q.Identity()),this._worldMatrix=j.Identity()}_afterComputeWorldMatrix(){}registerAfterWorldMatrixUpdate(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this}unregisterAfterWorldMatrixUpdate(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this}getPositionInCameraSpace(e=null){return e||(e=this.getScene().activeCamera),X.TransformCoordinates(this.getAbsolutePosition(),e.getViewMatrix())}getDistanceToCamera(e=null){return e||(e=this.getScene().activeCamera),this.getAbsolutePosition().subtract(e.globalPosition).length()}clone(e,t,i){const s=de.Clone((()=>new $i(e,this.getScene())),this);if(s.name=e,s.id=e,t&&(s.parent=t),!i){const t=this.getDescendants(!0);for(let i=0;i<t.length;i++){const r=t[i];r.clone&&r.clone(e+"."+r.name,s)}}return s}serialize(e){const t=de.Serialize(this,e);return t.type=this.getClassName(),t.uniqueId=this.uniqueId,this.parent&&this.parent._serializeAsParent(t),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),de.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t}static Parse(e,t,i){const s=de.Parse((()=>new $i(e.name,t)),e,t,i);if(e.localMatrix?s.setPreTransformMatrix(j.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(j.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s._waitingParsedUniqueId=e.uniqueId,void 0!==e.parentId&&(s._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.animations){for(let t=0;t<e.animations.length;t++){const i=e.animations[t],r=C("BABYLON.Animation");r&&s.animations.push(r.Parse(i))}fe.ParseAnimationRanges(s,e,t)}return e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),s}getChildTransformNodes(e,t){const i=[];return this._getDescendants(i,e,(e=>(!t||t(e))&&e instanceof $i)),i}dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){const e=this._parentContainer.transformNodes.indexOf(this);e>-1&&this._parentContainer.transformNodes.splice(e,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){const e=this.getChildTransformNodes(!0);for(const t of e)t.parent=null,t.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,i){let s=null,r=null;t&&(this.rotationQuaternion?(r=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(s=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const n=this.getHierarchyBoundingVectors(e,i),a=n.max.subtract(n.min),o=Math.max(a.x,a.y,a.z);if(0===o)return this;const h=1/o;return this.scaling.scaleInPlace(h),t&&(this.rotationQuaternion&&r?this.rotationQuaternion.copyFrom(r):this.rotation&&s&&this.rotation.copyFrom(s)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}}var es,ts,is;$i.BILLBOARDMODE_NONE=0,$i.BILLBOARDMODE_X=1,$i.BILLBOARDMODE_Y=2,$i.BILLBOARDMODE_Z=4,$i.BILLBOARDMODE_ALL=7,$i.BILLBOARDMODE_USE_POSITION=128,$i.BillboardUseParentOrientation=!1,$i._TmpRotation=q.Zero(),$i._TmpScaling=X.Zero(),$i._TmpTranslation=X.Zero(),$i._LookAtVectorCache=new X(0,0,0),$i._RotationAxisCache=new q,e([u("position")],$i.prototype,"_position",void 0),e([u("rotation")],$i.prototype,"_rotation",void 0),e([(es="rotationQuaternion",r(10,es))],$i.prototype,"_rotationQuaternion",void 0),e([u("scaling")],$i.prototype,"_scaling",void 0),e([a("billboardMode")],$i.prototype,"_billboardMode",void 0),e([a()],$i.prototype,"scalingDeterminant",void 0),e([a("infiniteDistance")],$i.prototype,"_infiniteDistance",void 0),e([a()],$i.prototype,"ignoreNonUniformScaling",void 0),e([a()],$i.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0);class ss{constructor(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,this.ray=null,this.originMesh=null,this.aimTransform=null,this.gripTransform=null}getNormal(e=!1,t=!0){if(!this.pickedMesh||t&&!this.pickedMesh.isVerticesDataPresent(wi.NormalKind))return null;let i,s=this.pickedMesh.getIndices();0===s?.length&&(s=null);const r=J.Vector3[0],n=J.Vector3[1],a=J.Vector3[2];if(t){const e=this.pickedMesh.getVerticesData(wi.NormalKind);let t=s?X.FromArrayToRef(e,3*s[3*this.faceId],r):r.copyFromFloats(e[3*this.faceId*3],e[3*this.faceId*3+1],e[3*this.faceId*3+2]),o=s?X.FromArrayToRef(e,3*s[3*this.faceId+1],n):n.copyFromFloats(e[3*(3*this.faceId+1)],e[3*(3*this.faceId+1)+1],e[3*(3*this.faceId+1)+2]),h=s?X.FromArrayToRef(e,3*s[3*this.faceId+2],a):a.copyFromFloats(e[3*(3*this.faceId+2)],e[3*(3*this.faceId+2)+1],e[3*(3*this.faceId+2)+2]);t=t.scale(this.bu),o=o.scale(this.bv),h=h.scale(1-this.bu-this.bv),i=new X(t.x+o.x+h.x,t.y+o.y+h.y,t.z+o.z+h.z)}else{const e=this.pickedMesh.getVerticesData(wi.PositionKind),t=s?X.FromArrayToRef(e,3*s[3*this.faceId],r):r.copyFromFloats(e[3*this.faceId*3],e[3*this.faceId*3+1],e[3*this.faceId*3+2]),o=s?X.FromArrayToRef(e,3*s[3*this.faceId+1],n):n.copyFromFloats(e[3*(3*this.faceId+1)],e[3*(3*this.faceId+1)+1],e[3*(3*this.faceId+1)+2]),h=s?X.FromArrayToRef(e,3*s[3*this.faceId+2],a):a.copyFromFloats(e[3*(3*this.faceId+2)],e[3*(3*this.faceId+2)+1],e[3*(3*this.faceId+2)+2]),l=t.subtract(o),c=h.subtract(o);i=X.Cross(l,c)}const o=(e,t)=>{let i=e.getWorldMatrix();e.nonUniformScaling&&(J.Matrix[0].copyFrom(i),i=J.Matrix[0],i.setTranslationFromFloats(0,0,0),i.invert(),i.transposeToRef(J.Matrix[1]),i=J.Matrix[1]),X.TransformNormalToRef(t,i,t)};if(e&&o(this.pickedMesh,i),this.ray){const t=J.Vector3[0].copyFrom(i);e||o(this.pickedMesh,t),X.Dot(t,this.ray.direction)>0&&i.negateInPlace()}return i.normalize(),i}getTextureCoordinates(e=wi.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;const t=this.pickedMesh.getIndices();if(!t)return null;const i=this.pickedMesh.getVerticesData(e);if(!i)return null;let s=Y.FromArray(i,2*t[3*this.faceId]),r=Y.FromArray(i,2*t[3*this.faceId+1]),n=Y.FromArray(i,2*t[3*this.faceId+2]);return s=s.scale(this.bu),r=r.scale(this.bv),n=n.scale(1-this.bu-this.bv),new Y(s.x+r.x+n.x,s.y+r.y+n.y)}}class rs{constructor(e,t,i,s,r=!1){this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||r,this._dynamic=i,this._name=s??"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return void 0!==this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}_fillAlignment(e){let t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){const e=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;const i=this._uniformLocationPointer-e;for(let e=0;e<i;e++)this._data.push(0)}}addUniform(e,t,i=0){if(this._noUBO)return;if(void 0!==this._uniformLocations[e])return;let s;if(i>0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),this._uniformArraySizes[e]={strideSize:t,arraySize:i},16==t)t*=i;else{t=t*i+(4-t)*i}s=[];for(let e=0;e<t;e++)s.push(0)}else{if(t instanceof Array)s=t,t=s.length;else{s=[];for(let e=0;e<t;e++)s.push(0)}this._fillAlignment(t)}this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(let e=0;e<t;e++)this._data.push(s[e]);this._needSync=!0}addMatrix(e,t){this.addUniform(e,Array.prototype.slice.call(t.asArray()))}addFloat2(e,t,i){const s=[t,i];this.addUniform(e,s)}addFloat3(e,t,i,s){const r=[t,i,s];this.addUniform(e,r)}addColor3(e,t){const i=[t.r,t.g,t.b];this.addUniform(e,i)}addColor4(e,t,i){const s=[t.r,t.g,t.b,i];this.addUniform(e,s)}addVector3(e,t){const i=[t.x,t.y,t.z];this.addUniform(e,i)}addMatrix3x3(e){this.addUniform(e,12)}addMatrix2x2(e){this.addUniform(e,8)}create(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)}_getNames(){const e=[];let t=0;for(const i in this._uniformLocations)if(e.push(i),10==++t)break;return e.join(",")}_rebuild(){!this._noUBO&&this._bufferData&&(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNames()):this._buffer=this._engine.createUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNames()),this._engine._features.trackUbosInFrame&&(this._buffers.push([this._buffer,this._engine._features.checkUbosContentBeforeUpload?this._bufferData.slice():void 0]),this._bufferIndex=this._buffers.length-1,this._createBufferOnWrite=!1))}_rebuildAfterContextLost(){this._engine._features.trackUbosInFrame&&(this._buffers=[],this._currentFrameId=0),this._rebuild()}get _numBuffers(){return this._buffers.length}get _indexBuffer(){return this._bufferIndex}get name(){return this._name}get currentEffect(){return this._currentEffect}_buffersEqual(e,t){for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}_copyBuffer(e,t){for(let i=0;i<e.length;++i)t[i]=e[i]}update(){if(!this._noUBO)if(this.bindUniformBuffer(),this._buffer)if(this._dynamic||this._needSync){if(this._buffers&&this._buffers.length>1&&this._buffers[this._bufferIndex][1]){if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1]))return this._needSync=!1,void(this._createBufferOnWrite=this._engine._features.trackUbosInFrame);this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1])}this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(rs._UpdatedUbosInFrame[this._name]||(rs._UpdatedUbosInFrame[this._name]=0),rs._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.trackUbosInFrame}else this._createBufferOnWrite=this._engine._features.trackUbosInFrame;else this.create()}_createNewBuffer(){this._bufferIndex+1<this._buffers.length?(this._bufferIndex++,this._buffer=this._buffers[this._bufferIndex][0],this._createBufferOnWrite=!1,this._needSync=!0):this._rebuild()}_checkNewFrame(){this._engine._features.trackUbosInFrame&&this._currentFrameId!==this._engine.frameId&&(this._currentFrameId=this._engine.frameId,this._createBufferOnWrite=!1,this._buffers&&this._buffers.length>0?(this._needSync=0!==this._bufferIndex,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,i){this._checkNewFrame();let s=this._uniformLocations[e];if(void 0===s){if(this._buffer)return void Ae.Error("Cannot add an uniform after UBO has been created. uniformName="+e);this.addUniform(e,i),s=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let e=0;e<i;e++)this._bufferData[s+e]=t[e];else{let e=!1;for(let r=0;r<i;r++)(16===i&&!this._engine._features.uniformBufferHardCheckMatrix||this._bufferData[s+r]!==Math.fround(t[r]))&&(e=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+r]=t[r]);this._needSync=this._needSync||e}}updateUniformArray(e,t,i){this._checkNewFrame();const s=this._uniformLocations[e];if(void 0===s)return void Ae.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.");this._buffer||this.create();const r=this._uniformArraySizes[e];if(this._dynamic)for(let e=0;e<i;e++)this._bufferData[s+e]=t[e];else{let e=!1,n=0,a=0;for(let o=0;o<i;o++)if(this._bufferData[s+4*a+n]!==pi.FloatRound(t[o])&&(e=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+4*a+n]=t[o]),n++,n===r.strideSize){for(;n<4;n++)this._bufferData[s+4*a+n]=0;n=0,a++}this._needSync=this._needSync||e}}_cacheMatrix(e,t){this._checkNewFrame();const i=this._valueCache[e],s=t.updateFlag;return(void 0===i||i!==s)&&(this._valueCache[e]=s,!0)}_updateMatrix3x3ForUniform(e,t){for(let e=0;e<3;e++)rs._TempBuffer[4*e]=t[3*e],rs._TempBuffer[4*e+1]=t[3*e+1],rs._TempBuffer[4*e+2]=t[3*e+2],rs._TempBuffer[4*e+3]=0;this.updateUniform(e,rs._TempBuffer,12)}_updateMatrix3x3ForEffect(e,t){this._currentEffect.setMatrix3x3(e,t)}_updateMatrix2x2ForEffect(e,t){this._currentEffect.setMatrix2x2(e,t)}_updateMatrix2x2ForUniform(e,t){for(let e=0;e<2;e++)rs._TempBuffer[4*e]=t[2*e],rs._TempBuffer[4*e+1]=t[2*e+1],rs._TempBuffer[4*e+2]=0,rs._TempBuffer[4*e+3]=0;this.updateUniform(e,rs._TempBuffer,8)}_updateFloatForEffect(e,t){this._currentEffect.setFloat(e,t)}_updateFloatForUniform(e,t){rs._TempBuffer[0]=t,this.updateUniform(e,rs._TempBuffer,1)}_updateFloat2ForEffect(e,t,i,s=""){this._currentEffect.setFloat2(e+s,t,i)}_updateFloat2ForUniform(e,t,i){rs._TempBuffer[0]=t,rs._TempBuffer[1]=i,this.updateUniform(e,rs._TempBuffer,2)}_updateFloat3ForEffect(e,t,i,s,r=""){this._currentEffect.setFloat3(e+r,t,i,s)}_updateFloat3ForUniform(e,t,i,s){rs._TempBuffer[0]=t,rs._TempBuffer[1]=i,rs._TempBuffer[2]=s,this.updateUniform(e,rs._TempBuffer,3)}_updateFloat4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setFloat4(e+n,t,i,s,r)}_updateFloat4ForUniform(e,t,i,s,r){rs._TempBuffer[0]=t,rs._TempBuffer[1]=i,rs._TempBuffer[2]=s,rs._TempBuffer[3]=r,this.updateUniform(e,rs._TempBuffer,4)}_updateFloatArrayForEffect(e,t){this._currentEffect.setFloatArray(e,t)}_updateFloatArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateArrayForEffect(e,t){this._currentEffect.setArray(e,t)}_updateArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateIntArrayForEffect(e,t){this._currentEffect.setIntArray(e,t)}_updateIntArrayForUniform(e,t){rs._TempBufferInt32View.set(t),this.updateUniformArray(e,rs._TempBuffer,t.length)}_updateUIntArrayForEffect(e,t){this._currentEffect.setUIntArray(e,t)}_updateUIntArrayForUniform(e,t){rs._TempBufferUInt32View.set(t),this.updateUniformArray(e,rs._TempBuffer,t.length)}_updateMatrixForEffect(e,t){this._currentEffect.setMatrix(e,t)}_updateMatrixForUniform(e,t){this._cacheMatrix(e,t)&&this.updateUniform(e,t.asArray(),16)}_updateMatricesForEffect(e,t){this._currentEffect.setMatrices(e,t)}_updateMatricesForUniform(e,t){this.updateUniform(e,t,t.length)}_updateVector3ForEffect(e,t){this._currentEffect.setVector3(e,t)}_updateVector3ForUniform(e,t){rs._TempBuffer[0]=t.x,rs._TempBuffer[1]=t.y,rs._TempBuffer[2]=t.z,this.updateUniform(e,rs._TempBuffer,3)}_updateVector4ForEffect(e,t){this._currentEffect.setVector4(e,t)}_updateVector4ForUniform(e,t){rs._TempBuffer[0]=t.x,rs._TempBuffer[1]=t.y,rs._TempBuffer[2]=t.z,rs._TempBuffer[3]=t.w,this.updateUniform(e,rs._TempBuffer,4)}_updateColor3ForEffect(e,t,i=""){this._currentEffect.setColor3(e+i,t)}_updateColor3ForUniform(e,t){rs._TempBuffer[0]=t.r,rs._TempBuffer[1]=t.g,rs._TempBuffer[2]=t.b,this.updateUniform(e,rs._TempBuffer,3)}_updateColor4ForEffect(e,t,i,s=""){this._currentEffect.setColor4(e+s,t,i)}_updateDirectColor4ForEffect(e,t,i=""){this._currentEffect.setDirectColor4(e+i,t)}_updateColor4ForUniform(e,t,i){rs._TempBuffer[0]=t.r,rs._TempBuffer[1]=t.g,rs._TempBuffer[2]=t.b,rs._TempBuffer[3]=i,this.updateUniform(e,rs._TempBuffer,4)}_updateDirectColor4ForUniform(e,t){rs._TempBuffer[0]=t.r,rs._TempBuffer[1]=t.g,rs._TempBuffer[2]=t.b,rs._TempBuffer[3]=t.a,this.updateUniform(e,rs._TempBuffer,4)}_updateIntForEffect(e,t,i=""){this._currentEffect.setInt(e+i,t)}_updateIntForUniform(e,t){rs._TempBufferInt32View[0]=t,this.updateUniform(e,rs._TempBuffer,1)}_updateInt2ForEffect(e,t,i,s=""){this._currentEffect.setInt2(e+s,t,i)}_updateInt2ForUniform(e,t,i){rs._TempBufferInt32View[0]=t,rs._TempBufferInt32View[1]=i,this.updateUniform(e,rs._TempBuffer,2)}_updateInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setInt3(e+r,t,i,s)}_updateInt3ForUniform(e,t,i,s){rs._TempBufferInt32View[0]=t,rs._TempBufferInt32View[1]=i,rs._TempBufferInt32View[2]=s,this.updateUniform(e,rs._TempBuffer,3)}_updateInt4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setInt4(e+n,t,i,s,r)}_updateInt4ForUniform(e,t,i,s,r){rs._TempBufferInt32View[0]=t,rs._TempBufferInt32View[1]=i,rs._TempBufferInt32View[2]=s,rs._TempBufferInt32View[3]=r,this.updateUniform(e,rs._TempBuffer,4)}_updateUIntForEffect(e,t,i=""){this._currentEffect.setUInt(e+i,t)}_updateUIntForUniform(e,t){rs._TempBufferUInt32View[0]=t,this.updateUniform(e,rs._TempBuffer,1)}_updateUInt2ForEffect(e,t,i,s=""){this._currentEffect.setUInt2(e+s,t,i)}_updateUInt2ForUniform(e,t,i){rs._TempBufferUInt32View[0]=t,rs._TempBufferUInt32View[1]=i,this.updateUniform(e,rs._TempBuffer,2)}_updateUInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setUInt3(e+r,t,i,s)}_updateUInt3ForUniform(e,t,i,s){rs._TempBufferUInt32View[0]=t,rs._TempBufferUInt32View[1]=i,rs._TempBufferUInt32View[2]=s,this.updateUniform(e,rs._TempBuffer,3)}_updateUInt4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setUInt4(e+n,t,i,s,r)}_updateUInt4ForUniform(e,t,i,s,r){rs._TempBufferUInt32View[0]=t,rs._TempBufferUInt32View[1]=i,rs._TempBufferUInt32View[2]=s,rs._TempBufferUInt32View[3]=r,this.updateUniform(e,rs._TempBuffer,4)}setTexture(e,t){this._currentEffect.setTexture(e,t)}setTextureArray(e,t){this._currentEffect.setTextureArray(e,t)}bindTexture(e,t){this._currentEffect._bindTexture(e,t)}updateUniformDirectly(e,t){this.updateUniform(e,t,t.length),this.update()}bindToEffect(e,t){this._currentEffect=e,this._currentEffectName=t}bindUniformBuffer(){!this._noUBO&&this._buffer&&this._currentEffect&&this._currentEffect.bindUniformBuffer(this._buffer,this._currentEffectName)}unbindEffect(){this._currentEffect=void 0,this._currentEffectName=void 0}setDataBuffer(e){if(!this._buffers)return this._buffer===e;for(let t=0;t<this._buffers.length;++t){if(this._buffers[t][0]===e)return this._bufferIndex=t,this._buffer=e,this._createBufferOnWrite=!1,this._currentEffect=void 0,!0}return!1}dispose(){if(this._noUBO)return;const e=this._engine._uniformBuffers,t=e.indexOf(this);if(-1!==t&&(e[t]=e[e.length-1],e.pop()),this._engine._features.trackUbosInFrame&&this._buffers)for(let e=0;e<this._buffers.length;++e){const t=this._buffers[e][0];this._engine._releaseBuffer(t)}else this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}}rs._UpdatedUbosInFrame={},rs._MAX_UNIFORM_SIZE=256,rs._TempBuffer=new Float32Array(rs._MAX_UNIFORM_SIZE),rs._TempBufferInt32View=new Int32Array(rs._TempBuffer.buffer),rs._TempBufferUInt32View=new Uint32Array(rs._TempBuffer.buffer);class ns{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new X(0,0,0),this._diffPositionForCollisions=new X(0,0,0),this._collisionResponse=!0}}!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(ts||(ts={}));class as{}as.X=new X(1,0,0),as.Y=new X(0,1,0),as.Z=new X(0,0,1),function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(is||(is={}));class os{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=X.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class hs{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new os,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new ns,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._inheritVisibility=!1}}class ls extends $i{static get BILLBOARDMODE_NONE(){return $i.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return $i.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return $i.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return $i.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return $i.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return $i.BILLBOARDMODE_USE_POSITION}get facetNb(){return this._internalAbstractMeshDataInfo._facetData.facetNb}get partitioningSubdivisions(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions}set partitioningSubdivisions(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e}get partitioningBBoxRatio(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio}set partitioningBBoxRatio(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e}get mustDepthSortFacets(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort}set mustDepthSortFacets(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e}get facetDepthSortFrom(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom}set facetDepthSortFrom(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e}get collisionRetryCount(){return this._internalAbstractMeshDataInfo._collisionRetryCount}set collisionRetryCount(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e}get isFacetDataEnabled(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled}get morphTargetManager(){return this._internalAbstractMeshDataInfo._morphTargetManager}set morphTargetManager(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())}get bakedVertexAnimationManager(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager}set bakedVertexAnimationManager(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())}_syncGeometryWithMorphTargetManager(){}_updateNonUniformScalingState(e){return!!super._updateNonUniformScalingState(e)&&(this._markSubMeshesAsMiscDirty(),!0)}get rawBoundingInfo(){return this._internalAbstractMeshDataInfo._rawBoundingInfo}set rawBoundingInfo(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e}set onCollide(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)}set onCollisionPositionChange(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)}get visibility(){return this._internalAbstractMeshDataInfo._visibility}set visibility(e){if(this._internalAbstractMeshDataInfo._visibility===e)return;const t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(1===t&&1!==e||1!==t&&1===e)&&this._markSubMeshesAsDirty((e=>{e.markAsMiscDirty(),e.markAsPrePassDirty()}))}get inheritVisibility(){return this._internalAbstractMeshDataInfo._inheritVisibility}set inheritVisibility(e){this._internalAbstractMeshDataInfo._inheritVisibility=e}get isVisible(){if(!this._isVisible||!this.inheritVisibility||!this._parentNode)return this._isVisible;if(this._isVisible){let e=this._parentNode;for(;e;){const t=e.isVisible;if(void 0!==t)return t;e=e.parent}}return this._isVisible}set isVisible(e){this._isVisible=e}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(void 0,null==e),this._unBindEffect()))}getMaterialForRenderPass(e){return this._internalAbstractMeshDataInfo._materialForRenderPass?.[e]}setMaterialForRenderPass(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]);const i=this._internalAbstractMeshDataInfo._materialForRenderPass[e];i?.meshMap?.[this.uniqueId]&&(i.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t,t&&t.meshMap&&(t.meshMap[this.uniqueId]=this)}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){const t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()}get skeleton(){return this._internalAbstractMeshDataInfo._skeleton}constructor(e,t=null){switch(super(e,t,!1),this._internalAbstractMeshDataInfo=new hs,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=ls.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new A,this.onCollisionPositionChangeObservable=new A,this.onMaterialChangedObservable=new A,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this._isVisible=!0,this.isPickable=!0,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=he.Red(),this.outlineWidth=.02,this.overlayColor=he.Red(),this.overlayAlpha=.5,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.alwaysSelectAsActiveMesh=!1,this.doNotSyncBoundingInfo=!1,this.actionManager=null,this.ellipsoid=new X(.5,1,.5),this.ellipsoidOffset=new X(0,0,0),this.edgesWidth=1,this.edgesColor=new le(1,0,0,1),this._edgesRenderer=null,this._masterMesh=null,this._boundingInfo=null,this._boundingInfoIsDirty=!0,this._renderId=0,this._intersectionsInProgress=new Array,this._unIndexed=!1,this._lightSources=new Array,this._waitingData={lods:null,actions:null,freezeWorldMatrix:null},this._bonesTransformMatrices=null,this._transformMatrixTexture=null,this.onRebuildObservable=new A,this._onCollisionPositionChange=(e,t,i=null)=>{t.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>Wt.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),i&&this.onCollideObservable.notifyObservers(i),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},(t=this.getScene()).addMesh(this),this._resyncLightSources(),this._uniformBuffer=new rs(this.getScene().getEngine(),void 0,void 0,e,!this.getScene().getEngine().isWebGPU),this._buildUniformLayout(),t.performancePriority){case 2:this.doNotSyncBoundingInfo=!0;case 1:this.alwaysSelectAsActiveMesh=!0,this.isPickable=!1}}_buildUniformLayout(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()}transferToEffect(e){const t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()}getMeshUniformBuffer(){return this._uniformBuffer}getClassName(){return"AbstractMesh"}toString(e){let t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);const i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t}_getEffectiveParent(){return this._masterMesh&&this.billboardMode!==$i.BILLBOARDMODE_NONE?this._masterMesh:super._getEffectiveParent()}_getActionManagerForTrigger(e,t=!0){if(this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),null!==this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes){for(const e of this.subMeshes)e._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(const e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){const t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e);let s=!1;if(-1===i){if(!t)return;this._lightSources.push(e)}else{if(t)return;s=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(s)}_unBindEffect(){for(const e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){const i=this._lightSources.indexOf(e);-1!==i&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(const t of this.subMeshes)for(let i=0;i<t._drawWrappers.length;++i){const s=t._drawWrappers[i];s&&s.defines&&s.defines.markAllAsDirty&&e(s.defines)}}_markSubMeshesAsLightDirty(e=!1){this._markSubMeshesAsDirty((t=>t.markAsLightDirty(e)))}_markSubMeshesAsAttributesDirty(){this._markSubMeshesAsDirty((e=>e.markAsAttributesDirty()))}_markSubMeshesAsMiscDirty(){this._markSubMeshesAsDirty((e=>e.markAsMiscDirty()))}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,super.markAsDirty(e),this._isDirty=!0,this}resetDrawCache(e,t=!1){if(this.subMeshes)for(const i of this.subMeshes)i.resetDrawCache(e,t)}get isBlocked(){return!1}getLOD(e){return this}getTotalVertices(){return 0}getTotalIndices(){return 0}getIndices(){return null}getVerticesData(e){return null}setVerticesData(e,t,i,s){return this}updateVerticesData(e,t,i,s){return this}setIndices(e,t){return this}isVerticesDataPresent(e){return!1}getBoundingInfo(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfoIsDirty&&(this._boundingInfoIsDirty=!1,this._updateBoundingInfo()),this._boundingInfo)}getRawBoundingInfo(){return this.rawBoundingInfo??this.getBoundingInfo()}setBoundingInfo(e){return this._boundingInfo=e,this}get hasBoundingInfo(){return null!==this._boundingInfo}buildBoundingInfo(e,t,i){return this._boundingInfo=new Hi(e,t,i),this._boundingInfo}normalizeToUnitCube(e=!0,t=!1,i){return super.normalizeToUnitCube(e,t,i)}get useBones(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(wi.MatricesIndicesKind)&&this.isVerticesDataPresent(wi.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===$i.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():super.getWorldMatrix()}_getWorldMatrixDeterminant(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():super._getWorldMatrixDeterminant()}get isAnInstance(){return!1}get hasInstances(){return!1}get hasThinInstances(){return!1}movePOV(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this}calcMovePOV(e,t,i){const s=new j;(this.rotationQuaternion?this.rotationQuaternion:q.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(s);const r=X.Zero(),n=this.definedFacingForward?-1:1;return X.TransformCoordinatesFromFloatsToRef(e*n,t,i*n,s,r),r}rotatePOV(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this}calcRotatePOV(e,t,i){const s=this.definedFacingForward?1:-1;return new X(e*s,t,i*s)}_refreshBoundingInfo(e,t){if(e){const i=Ki(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Hi(i.minimum,i.maximum)}if(this.subMeshes)for(let t=0;t<this.subMeshes.length;t++)this.subMeshes[t].refreshBoundingInfo(e);this._updateBoundingInfo()}_refreshBoundingInfoDirect(e){if(this._boundingInfo?this._boundingInfo.reConstruct(e.minimum,e.maximum):this._boundingInfo=new Hi(e.minimum,e.maximum),this.subMeshes)for(let e=0;e<this.subMeshes.length;e++)this.subMeshes[e].refreshBoundingInfo(null);this._updateBoundingInfo()}static _ApplySkeleton(e,t,i,s,r,n,a){!function(e,t,i,s,r,n,a){const o=J.Vector3[0],h=J.Matrix[0],l=J.Matrix[1],c=t===wi.NormalKind?X.TransformNormalFromFloatsToRef:X.TransformCoordinatesFromFloatsToRef;for(let t=0,u=0;t<e.length;t+=3,u+=4){let d,_;for(h.reset(),d=0;d<4;d++)_=r[u+d],_>0&&(j.FromFloat32ArrayToRefScaled(i,Math.floor(16*s[u+d]),_,l),h.addToSelf(l));if(n&&a)for(d=0;d<4;d++)_=a[u+d],_>0&&(j.FromFloat32ArrayToRefScaled(i,Math.floor(16*n[u+d]),_,l),h.addToSelf(l));c(e[t],e[t+1],e[t+2],h,o),o.toArray(e,t)}}(e,t,i,s,r,n,a)}_getData(e,t,i=wi.PositionKind){const s=e.cache,r=e=>{if(s){const t=s._vertexData||={};return t[e]||this.copyVerticesData(e,t),t[e]}return this.getVerticesData(e)};if(t||=r(i),!t)return null;if(s?(s._outputData?s._outputData.set(t):s._outputData=new Float32Array(t),t=s._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&function(e,t,i){let s=null;switch(t){case wi.PositionKind:s=e=>e.getPositions();break;case wi.NormalKind:s=e=>e.getNormals();break;case wi.TangentKind:s=e=>e.getTangents();break;case wi.UVKind:s=e=>e.getUVs();break;default:return}for(let t=0;t<e.length;t++){let r=e[t];for(let n=0;n<i.numTargets;n++){const a=i.getTarget(n),o=a.influence;if(0!==o){const i=s(a);i&&(r+=(i[t]-e[t])*o)}}e[t]=r}}(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){const e=r(wi.MatricesIndicesKind),s=r(wi.MatricesWeightsKind);if(s&&e){const n=this.numBoneInfluencers>4,a=n?r(wi.MatricesIndicesExtraKind):null,o=n?r(wi.MatricesWeightsExtraKind):null,h=this.skeleton.getTransformMatrices(this);ls._ApplySkeleton(t,i,h,e,s,a,o)}}if(!1!==e.updatePositionsArray&&i===wi.PositionKind){const e=this._internalAbstractMeshDataInfo._positions||[],i=e.length;if(e.length=t.length/3,i<e.length)for(let t=i;t<e.length;t++)e[t]=new X;for(let i=0,s=0;i<e.length;i++,s+=3)e[i].copyFromFloats(t[s],t[s+1],t[s+2]);this._internalAbstractMeshDataInfo._positions=e}return t}getNormalsData(e=!1,t=!1){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},null,wi.NormalKind)}getPositionData(e=!1,t=!1,i=null){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},i,wi.PositionKind)}_updateBoundingInfo(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new Hi(X.Zero(),X.Zero(),this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}_updateSubMeshesBoundingInfo(e){if(!this.subMeshes)return this;const t=this.subMeshes.length;for(let i=0;i<t;i++){const s=this.subMeshes[i];(t>1||!s.IsGlobal)&&s.updateBoundingInfo(e)}return this}_afterComputeWorldMatrix(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)}isInFrustum(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)}isCompletelyInFrustum(e){return this.getBoundingInfo().isCompletelyInFrustum(e)}intersectsMesh(e,t=!1,i){const s=this.getBoundingInfo(),r=e.getBoundingInfo();if(s.intersects(r,t))return!0;if(i)for(const i of this.getChildMeshes())if(i.intersectsMesh(e,t,!0))return!0;return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const t=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=t.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,t.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId),this}_collideForSubMesh(e,t,i){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];const i=e.verticesStart,s=e.verticesStart+e.verticesCount;for(let r=i;r<s;r++)e._lastColliderWorldVertices.push(X.TransformCoordinates(this._positions[r],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this,this._shouldConvertRHS(),e.getMaterial()?.fillMode===Ve.MATERIAL_TriangleStripDrawMode),this}_processCollisionsForSubMeshes(e,t){const i=this._scene.getCollidingSubMeshCandidates(this,e),s=i.length;for(let r=0;r<s;r++){const n=i.data[r];s>1&&!n._checkCollision(e)||this._collideForSubMesh(n,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;const t=J.Matrix[0],i=J.Matrix[1];return j.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this}_generatePointsArray(){return!1}intersects(e,t,i,s=!1,r,n=!1){const a=new ss,o=this.getClassName(),h="InstancedLinesMesh"===o||"LinesMesh"===o||"GreasedLineMesh"===o?this.intersectionThreshold:0,l=this.getBoundingInfo();if(!this.subMeshes)return a;if(!(n||e.intersectsSphere(l.boundingSphere,h)&&e.intersectsBox(l.boundingBox,h)))return a;if(s)return a.hit=!n,a.pickedMesh=n?null:this,a.distance=n?0:X.Distance(e.origin,l.boundingSphere.center),a.subMeshId=0,a;if(!this._generatePointsArray())return a;let c=null;const u=this._scene.getIntersectingSubMeshCandidates(this,e),d=u.length;let _=!1;for(let e=0;e<d;e++){const t=u.data[e].getMaterial();if(t&&(t.fillMode==Ve.MATERIAL_TriangleStripDrawMode||t.fillMode==Ve.MATERIAL_TriangleFillMode||t.fillMode==Ve.MATERIAL_WireFrameFillMode||t.fillMode==Ve.MATERIAL_PointFillMode||t.fillMode==Ve.MATERIAL_LineListDrawMode)){_=!0;break}}if(!_)return a.hit=!0,a.pickedMesh=this,a.distance=X.Distance(e.origin,l.boundingSphere.center),a.subMeshId=-1,a;for(let s=0;s<d;s++){const r=u.data[s];if(d>1&&!n&&!r.canIntersects(e))continue;const a=r.intersects(e,this._positions,this.getIndices(),t,i);if(a&&(t||!c||a.distance<c.distance)&&(c=a,c.subMeshId=s,t))break}if(c){const t=r??this.getWorldMatrix(),i=J.Vector3[0],s=J.Vector3[1];X.TransformCoordinatesToRef(e.origin,t,i),e.direction.scaleToRef(c.distance,s);const n=X.TransformNormal(s,t).addInPlace(i);return a.hit=!0,a.distance=X.Distance(i,n),a.pickedPoint=n,a.pickedMesh=this,a.bu=c.bu||0,a.bv=c.bv||0,a.subMeshFaceId=c.faceId,a.faceId=c.faceId+u.data[c.subMeshId].indexStart/(-1!==this.getClassName().indexOf("LinesMesh")?2:3),a.subMeshId=c.subMeshId,a}return a}clone(e,t,i){return null}releaseSubMeshes(e=!1){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose(e);else this.subMeshes=[];return this}dispose(e,t=!1){let i;const s=this.getScene();for(this._scene.useMaterialMeshMap&&this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),s.freeActiveMeshes(),s.freeRenderingGroups(),s.renderingManager.maintainStateBetweenFrames&&s.renderingManager.restoreDispachedFlags(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.disposeWhenUnowned&&!this._scene.meshes.some((e=>e!==this&&e.actionManager===this.actionManager))&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),i=0;i<this._intersectionsInProgress.length;i++){const e=this._intersectionsInProgress[i],t=e._intersectionsInProgress.indexOf(this);e._intersectionsInProgress.splice(t,1)}this._intersectionsInProgress.length=0;s.lights.forEach((e=>{let t=e.includedOnlyMeshes.indexOf(this);-1!==t&&e.includedOnlyMeshes.splice(t,1),t=e.excludedMeshes.indexOf(this),-1!==t&&e.excludedMeshes.splice(t,1);const i=e.getShadowGenerators();if(i){const e=i.values();for(let i=e.next();!0!==i.done;i=e.next()){const e=i.value.getShadowMap();e&&e.renderList&&(t=e.renderList.indexOf(this),-1!==t&&e.renderList.splice(t,1))}}})),"InstancedMesh"===this.getClassName()&&"InstancedLinesMesh"===this.getClassName()||this.releaseSubMeshes(!0);const r=s.getEngine();if(null!==this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,r.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),r.wipeCaches(),s.removeMesh(this),this._parentContainer){const e=this._parentContainer.meshes.indexOf(this);e>-1&&this._parentContainer.meshes.splice(e,1),this._parentContainer=null}if(t&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!e)for(i=0;i<s.particleSystems.length;i++)s.particleSystems[i].emitter===this&&(s.particleSystems[i].dispose(),i--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this._uniformBuffer.dispose(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),super.dispose(e,t)}_initFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetNormals||(e.facetNormals=[]),e.facetPositions||(e.facetPositions=[]),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(let t=0;t<e.facetNb;t++)e.facetNormals[t]=X.Zero(),e.facetPositions[t]=X.Zero();return e.facetDataEnabled=!0,this}updateFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();const t=this.getVerticesData(wi.PositionKind),i=this.getIndices(),s=this.getVerticesData(wi.NormalKind),r=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{let t=!1;for(let e=0;e<i.length;e++)if(i[e]>65535){t=!0;break}e.depthSortedIndices=t?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){const t=this.getScene().activeCamera;e.facetDepthSortFrom=t?t.position:X.Zero()}e.depthSortedFacets=[];for(let t=0;t<e.facetNb;t++){const i={ind:3*t,sqDistance:0};e.depthSortedFacets.push(i)}e.invertedMatrix=j.Identity(),e.facetDepthSortOrigin=X.Zero()}e.bbSize.x=r.maximum.x-r.minimum.x>R?r.maximum.x-r.minimum.x:R,e.bbSize.y=r.maximum.y-r.minimum.y>R?r.maximum.y-r.minimum.y:R,e.bbSize.z=r.maximum.z-r.minimum.z>R?r.maximum.z-r.minimum.z:R;let n=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(n=n>e.bbSize.z?n:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/n),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/n),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/n),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=r,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),X.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,s&&qi.ComputeNormals(t,i,s,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);const t=e.depthSortedIndices.length/3|0;for(let s=0;s<t;s++){const t=e.depthSortedFacets[s].ind;e.depthSortedIndices[3*s]=i[t],e.depthSortedIndices[3*s+1]=i[t+1],e.depthSortedIndices[3*s+2]=i[t+2]}this.updateIndices(e.depthSortedIndices,void 0,!0)}return this}getFacetLocalNormals(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetNormals||this.updateFacetData(),e.facetNormals}getFacetLocalPositions(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetPositions||this.updateFacetData(),e.facetPositions}getFacetLocalPartitioning(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetPartitioning||this.updateFacetData(),e.facetPartitioning}getFacetPosition(e){const t=X.Zero();return this.getFacetPositionToRef(e,t),t}getFacetPositionToRef(e,t){const i=this.getFacetLocalPositions()[e],s=this.getWorldMatrix();return X.TransformCoordinatesToRef(i,s,t),this}getFacetNormal(e){const t=X.Zero();return this.getFacetNormalToRef(e,t),t}getFacetNormalToRef(e,t){const i=this.getFacetLocalNormals()[e];return X.TransformNormalToRef(i,this.getWorldMatrix(),t),this}getFacetsAtLocalCoordinates(e,t,i){const s=this.getBoundingInfo(),r=this._internalAbstractMeshDataInfo._facetData,n=Math.floor((e-s.minimum.x*r.partitioningBBoxRatio)*r.subDiv.X*r.partitioningBBoxRatio/r.bbSize.x),a=Math.floor((t-s.minimum.y*r.partitioningBBoxRatio)*r.subDiv.Y*r.partitioningBBoxRatio/r.bbSize.y),o=Math.floor((i-s.minimum.z*r.partitioningBBoxRatio)*r.subDiv.Z*r.partitioningBBoxRatio/r.bbSize.z);return n<0||n>r.subDiv.max||a<0||a>r.subDiv.max||o<0||o>r.subDiv.max?null:r.facetPartitioning[n+r.subDiv.max*a+r.subDiv.max*r.subDiv.max*o]}getClosestFacetAtCoordinates(e,t,i,s,r=!1,n=!0){const a=this.getWorldMatrix(),o=J.Matrix[5];a.invertToRef(o);const h=J.Vector3[8];X.TransformCoordinatesFromFloatsToRef(e,t,i,o,h);const l=this.getClosestFacetAtLocalCoordinates(h.x,h.y,h.z,s,r,n);return s&&X.TransformCoordinatesFromFloatsToRef(s.x,s.y,s.z,a,s),l}getClosestFacetAtLocalCoordinates(e,t,i,s,r=!1,n=!0){let a=null,o=0,h=0,l=0,c=0,u=0,d=0,_=0,f=0;const p=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),m=this.getFacetsAtLocalCoordinates(e,t,i);if(!m)return null;let T,A,E,b=Number.MAX_VALUE,R=b;for(let y=0;y<m.length;y++)T=m[y],A=g[T],E=p[T],c=(e-E.x)*A.x+(t-E.y)*A.y+(i-E.z)*A.z,(!r||r&&n&&c>=0||r&&!n&&c<=0)&&(c=A.x*E.x+A.y*E.y+A.z*E.z,u=-(A.x*e+A.y*t+A.z*i-c)/(A.x*A.x+A.y*A.y+A.z*A.z),d=e+A.x*u,_=t+A.y*u,f=i+A.z*u,o=d-e,h=_-t,l=f-i,R=o*o+h*h+l*l,R<b&&(b=R,a=T,s&&(s.x=d,s.y=_,s.z=f)));return a}getFacetDataParameters(){return this._internalAbstractMeshDataInfo._facetData.facetParameters}disableFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=[],e.facetNormals=[],e.facetPartitioning=new Array,e.facetParameters={},e.depthSortedIndices=new Uint32Array(0)),this}updateIndices(e,t,i=!1){return this}createNormals(e){const t=this.getVerticesData(wi.PositionKind),i=this.getIndices();let s;return s=this.isVerticesDataPresent(wi.NormalKind)?this.getVerticesData(wi.NormalKind):[],qi.ComputeNormals(t,i,s,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(wi.NormalKind,s,e),this}alignWithNormal(e,t){t||(t=as.Y);const i=J.Vector3[0],s=J.Vector3[1];return X.CrossToRef(t,e,s),X.CrossToRef(e,s,i),this.rotationQuaternion?q.RotationQuaternionFromAxisToRef(i,e,s,this.rotationQuaternion):X.RotationFromAxisToRef(i,e,s,this.rotation),this}_checkOcclusionQuery(){return!1}disableEdgesRendering(){throw te("EdgesRenderer")}enableEdgesRendering(e,t,i){throw te("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter((e=>e.emitter===this))}}ls.OCCLUSION_TYPE_NONE=0,ls.OCCLUSION_TYPE_OPTIMISTIC=1,ls.OCCLUSION_TYPE_STRICT=2,ls.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,ls.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,ls.CULLINGSTRATEGY_STANDARD=Ve.MESHES_CULLINGSTRATEGY_STANDARD,ls.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=Ve.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,ls.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION,ls.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=Ve.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY,e([p.filter(((...[e,t,i,s,r])=>!(Array.isArray(e)||Array.isArray(t)||Array.isArray(i)||Array.isArray(s)||Array.isArray(r))))],ls,"_ApplySkeleton",null),S("BABYLON.AbstractMesh",ls);class cs{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=Ve.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=Ve.KEEP,this.opDepthFail=Ve.KEEP,this.opStencilDepthPass=Ve.REPLACE}get func(){return this._func}set func(e){this._func=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){de.Clone((()=>e),this)}serialize(){return de.Serialize(this)}parse(e,t,i){de.Parse((()=>this),e,t,i)}}e([a()],cs.prototype,"func",null),e([a()],cs.prototype,"funcRef",null),e([a()],cs.prototype,"funcMask",null),e([a()],cs.prototype,"opStencilFail",null),e([a()],cs.prototype,"opDepthFail",null),e([a()],cs.prototype,"opStencilDepthPass",null),e([a()],cs.prototype,"mask",null),e([a()],cs.prototype,"enabled",null);class us{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}function ds(e){-1===e.indexOf("vClipPlane")&&e.push("vClipPlane"),-1===e.indexOf("vClipPlane2")&&e.push("vClipPlane2"),-1===e.indexOf("vClipPlane3")&&e.push("vClipPlane3"),-1===e.indexOf("vClipPlane4")&&e.push("vClipPlane4"),-1===e.indexOf("vClipPlane5")&&e.push("vClipPlane5"),-1===e.indexOf("vClipPlane6")&&e.push("vClipPlane6")}function _s(e,t,i){let s=t.clipPlane??i.clipPlane;fs(e,"vClipPlane",s),s=t.clipPlane2??i.clipPlane2,fs(e,"vClipPlane2",s),s=t.clipPlane3??i.clipPlane3,fs(e,"vClipPlane3",s),s=t.clipPlane4??i.clipPlane4,fs(e,"vClipPlane4",s),s=t.clipPlane5??i.clipPlane5,fs(e,"vClipPlane5",s),s=t.clipPlane6??i.clipPlane6,fs(e,"vClipPlane6",s)}function fs(e,t,i){i&&e.setFloat4(t,i.normal.x,i.normal.y,i.normal.z,i.d)}us.FALLOFF_DEFAULT=0,us.FALLOFF_PHYSICAL=1,us.FALLOFF_GLTF=2,us.FALLOFF_STANDARD=3,us.LIGHTMAP_DEFAULT=0,us.LIGHTMAP_SPECULAR=1,us.LIGHTMAP_SHADOWSONLY=2,us.INTENSITYMODE_AUTOMATIC=0,us.INTENSITYMODE_LUMINOUSPOWER=1,us.INTENSITYMODE_LUMINOUSINTENSITY=2,us.INTENSITYMODE_ILLUMINANCE=3,us.INTENSITYMODE_LUMINANCE=4,us.LIGHTTYPEID_POINTLIGHT=0,us.LIGHTTYPEID_DIRECTIONALLIGHT=1,us.LIGHTTYPEID_SPOTLIGHT=2,us.LIGHTTYPEID_HEMISPHERICLIGHT=3;const ps=he.Black();function gs(e,t,i){if(!e||e.LOGARITHMICDEPTH||e.indexOf&&e.indexOf("LOGARITHMICDEPTH")>=0){const e=i.activeCamera;e.mode===Ve.ORTHOGRAPHIC_CAMERA&&Ae.Error("Logarithmic depth is not compatible with orthographic cameras!",20),t.setFloat("logarithmicDepthConstant",2/(Math.log(e.maxZ+1)/Math.LN2))}}function ms(e,t,i,s=!1){i&&e.fogEnabled&&(!t||t.applyFog)&&e.fogMode!==Ve.FOGMODE_NONE&&(i.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),s?(e.fogColor.toLinearSpaceToRef(ps,e.getEngine().useExactSrgbConversions),i.setColor3("vFogColor",ps)):i.setColor3("vFogColor",e.fogColor))}function Ts(e,t,i){const s=i.NUM_MORPH_INFLUENCERS;if(s>0&&O.LastCreatedEngine){const r=O.LastCreatedEngine.getCaps().maxVertexAttribs,n=t.morphTargetManager;if(n?.isUsingTextureForTargets)return;const a=n&&n.supportsNormals&&i.NORMAL,o=n&&n.supportsTangents&&i.TANGENT,h=n&&n.supportsUVs&&i.UV1;for(let i=0;i<s;i++)e.push(Ve.PositionKind+i),a&&e.push(Ve.NormalKind+i),o&&e.push(Ve.TangentKind+i),h&&e.push(Ve.UVKind+"_"+i),e.length>r&&Ae.Error("Cannot add more vertex attributes for mesh "+t.name)}}function As(e,t){const i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)}function Es(e,t,i){t._needUVs=!0,t[i]=!0,e.optimizeUVAllocation&&e.getTextureMatrix().isIdentityAs3x2()?(t[i+"DIRECTUV"]=e.coordinatesIndex+1,t["MAINUV"+(e.coordinatesIndex+1)]=!0):t[i+"DIRECTUV"]=0}function bs(e,t,i){const s=e.getTextureMatrix();t.updateMatrix(i+"Matrix",s)}function Rs(e,t,i){i.BAKED_VERTEX_ANIMATION_TEXTURE&&i.INSTANCES&&e.push("bakedVertexAnimationSettingsInstanced")}function ys(e,t,i){var s;if(t&&e&&(e.computeBonesUsingShaders&&t._bonesComputationForcedToCPU&&(e.computeBonesUsingShaders=!1),e.useBones&&e.computeBonesUsingShaders&&e.skeleton)){const r=e.skeleton;if(r.isUsingTextureForMatrices&&t.getUniformIndex("boneTextureWidth")>-1){const i=r.getTransformMatrixTexture(e);t.setTexture("boneSampler",i),t.setFloat("boneTextureWidth",4*(r.bones.length+1))}else{const n=r.getTransformMatrices(e);n&&(t.setMatrices("mBones",n),i&&e.getScene().prePassRenderer&&e.getScene().prePassRenderer.getIndex(Ve.PREPASS_VELOCITY_TEXTURE_TYPE)&&(i.previousBones[e.uniqueId]||(i.previousBones[e.uniqueId]=n.slice()),t.setMatrices("mPreviousBones",i.previousBones[e.uniqueId]),s=n,i.previousBones[e.uniqueId].set(s)))}}}function Is(e,t,i,s,r,n=!0){e._bindLight(t,i,s,r,n)}function Ms(e,t,i,s,r=4){const n=Math.min(t.lightSources.length,r);for(let r=0;r<n;r++){Is(t.lightSources[r],r,e,i,"boolean"==typeof s?s:s.SPECULARTERM,t.receiveShadows)}}function vs(e,t,i,s){i.NUM_BONE_INFLUENCERS>0&&(s.addCPUSkinningFallback(0,t),e.push(Ve.MatricesIndicesKind),e.push(Ve.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(Ve.MatricesIndicesExtraKind),e.push(Ve.MatricesWeightsExtraKind)))}function xs(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&function(e,t=!1){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"),t&&(e.push("previousWorld0"),e.push("previousWorld1"),e.push("previousWorld2"),e.push("previousWorld3"))}(e,!!t.PREPASS_VELOCITY),t.INSTANCESCOLOR&&e.push(Ve.ColorInstanceKind)}function Ss(e,t,i=4,s=0){let r=0;for(let n=0;n<i&&e["LIGHT"+n];n++)n>0&&(r=s+n,t.addFallback(r,"LIGHT"+n)),e.SHADOWS||(e["SHADOW"+n]&&t.addFallback(s,"SHADOW"+n),e["SHADOWPCF"+n]&&t.addFallback(s,"SHADOWPCF"+n),e["SHADOWPCSS"+n]&&t.addFallback(s,"SHADOWPCSS"+n),e["SHADOWPOISSON"+n]&&t.addFallback(s,"SHADOWPOISSON"+n),e["SHADOWESM"+n]&&t.addFallback(s,"SHADOWESM"+n),e["SHADOWCLOSEESM"+n]&&t.addFallback(s,"SHADOWCLOSEESM"+n));return r++}function Cs(e,t,i,s,r,n,a,o=!1){a._areMiscDirty&&(a.LOGARITHMICDEPTH=i,a.POINTSIZE=s,a.FOG=r&&function(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==Ve.FOGMODE_NONE}(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=n,a.DECAL_AFTER_DETAIL=o)}function Ps(e,t,i,s,r=4,n=!1){if(!i._areLightsDirty)return i._needNormals;let a=0;const o={needNormals:i._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!n)for(const n of t.lightSources)if(Os(e,t,n,a,i,s,o),a++,a===r)break;i.SPECULARTERM=o.specularEnabled,i.SHADOWS=o.shadowEnabled;for(let e=a;e<r;e++)void 0!==i["LIGHT"+e]&&(i["LIGHT"+e]=!1,i["HEMILIGHT"+e]=!1,i["POINTLIGHT"+e]=!1,i["DIRLIGHT"+e]=!1,i["SPOTLIGHT"+e]=!1,i["SHADOW"+e]=!1,i["SHADOWCSM"+e]=!1,i["SHADOWCSMDEBUG"+e]=!1,i["SHADOWCSMNUM_CASCADES"+e]=!1,i["SHADOWCSMUSESHADOWMAXZ"+e]=!1,i["SHADOWCSMNOBLEND"+e]=!1,i["SHADOWCSM_RIGHTHANDED"+e]=!1,i["SHADOWPCF"+e]=!1,i["SHADOWPCSS"+e]=!1,i["SHADOWPOISSON"+e]=!1,i["SHADOWESM"+e]=!1,i["SHADOWCLOSEESM"+e]=!1,i["SHADOWCUBE"+e]=!1,i["SHADOWLOWQUALITY"+e]=!1,i["SHADOWMEDIUMQUALITY"+e]=!1);const h=e.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(o.needRebuild=!0),i.SHADOWFLOAT=o.shadowEnabled&&(h.textureFloatRender&&h.textureFloatLinearFiltering||h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=o.lightmapMode,o.needRebuild&&i.rebuild(),o.needNormals}function Os(e,t,i,s,r,n,a){switch(a.needNormals=!0,void 0===r["LIGHT"+s]&&(a.needRebuild=!0),r["LIGHT"+s]=!0,r["SPOTLIGHT"+s]=!1,r["HEMILIGHT"+s]=!1,r["POINTLIGHT"+s]=!1,r["DIRLIGHT"+s]=!1,i.prepareLightSpecificDefines(r,s),r["LIGHT_FALLOFF_PHYSICAL"+s]=!1,r["LIGHT_FALLOFF_GLTF"+s]=!1,r["LIGHT_FALLOFF_STANDARD"+s]=!1,i.falloffType){case us.FALLOFF_GLTF:r["LIGHT_FALLOFF_GLTF"+s]=!0;break;case us.FALLOFF_PHYSICAL:r["LIGHT_FALLOFF_PHYSICAL"+s]=!0;break;case us.FALLOFF_STANDARD:r["LIGHT_FALLOFF_STANDARD"+s]=!0}if(i.specular.equalsFloats(0,0,0)||(a.specularEnabled=!0),r["SHADOW"+s]=!1,r["SHADOWCSM"+s]=!1,r["SHADOWCSMDEBUG"+s]=!1,r["SHADOWCSMNUM_CASCADES"+s]=!1,r["SHADOWCSMUSESHADOWMAXZ"+s]=!1,r["SHADOWCSMNOBLEND"+s]=!1,r["SHADOWCSM_RIGHTHANDED"+s]=!1,r["SHADOWPCF"+s]=!1,r["SHADOWPCSS"+s]=!1,r["SHADOWPOISSON"+s]=!1,r["SHADOWESM"+s]=!1,r["SHADOWCLOSEESM"+s]=!1,r["SHADOWCUBE"+s]=!1,r["SHADOWLOWQUALITY"+s]=!1,r["SHADOWMEDIUMQUALITY"+s]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&i.shadowEnabled){const t=i.getShadowGenerator(e.activeCamera)??i.getShadowGenerator();if(t){const e=t.getShadowMap();e&&e.renderList&&e.renderList.length>0&&(a.shadowEnabled=!0,t.prepareDefines(r,s))}}i.lightmapMode!=us.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+s]=!0,r["LIGHTMAPNOSPECULAR"+s]=i.lightmapMode==us.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+s]=!1,r["LIGHTMAPNOSPECULAR"+s]=!1)}function Ds(e,t,i,s,r,n=null,a=!1){let o=function(e,t){let i=!1;if(e.activeCamera){const s=t.CAMERA_ORTHOGRAPHIC?1:0,r=t.CAMERA_PERSPECTIVE?1:0,n=e.activeCamera.mode===Ve.ORTHOGRAPHIC_CAMERA?1:0,a=e.activeCamera.mode===Ve.PERSPECTIVE_CAMERA?1:0;(s^n||r^a)&&(t.CAMERA_ORTHOGRAPHIC=1===n,t.CAMERA_PERSPECTIVE=1===a,i=!0)}return i}(e,s);!1!==n&&(o=function(e,t,i){let s=!1;const r=!!(e.clipPlane??t.clipPlane),n=!!(e.clipPlane2??t.clipPlane2),a=!!(e.clipPlane3??t.clipPlane3),o=!!(e.clipPlane4??t.clipPlane4),h=!!(e.clipPlane5??t.clipPlane5),l=!!(e.clipPlane6??t.clipPlane6);return i.CLIPPLANE!==r&&(i.CLIPPLANE=r,s=!0),i.CLIPPLANE2!==n&&(i.CLIPPLANE2=n,s=!0),i.CLIPPLANE3!==a&&(i.CLIPPLANE3=a,s=!0),i.CLIPPLANE4!==o&&(i.CLIPPLANE4=o,s=!0),i.CLIPPLANE5!==h&&(i.CLIPPLANE5=h,s=!0),i.CLIPPLANE6!==l&&(i.CLIPPLANE6=l,s=!0),s}(i,e,s)),s.DEPTHPREPASS!==!t.getColorWrite()&&(s.DEPTHPREPASS=!s.DEPTHPREPASS,o=!0),s.INSTANCES!==r&&(s.INSTANCES=r,o=!0),s.THIN_INSTANCES!==a&&(s.THIN_INSTANCES=a,o=!0),o&&s.markAsUnprocessed()}function Ls(e,t,i,s,r=!1,n=!0,a=!0){if(!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(Ve.NormalKind),t._needNormals&&e.isVerticesDataPresent(Ve.TangentKind)&&(t.TANGENT=!0);for(let i=1;i<=Ve.MAX_SUPPORTED_UV_SETS;++i)t["UV"+i]=!!t._needUVs&&e.isVerticesDataPresent(`uv${1===i?"":i}`);if(i){const i=e.useVertexColors&&e.isVerticesDataPresent(Ve.ColorKind);t.VERTEXCOLOR=i,t.VERTEXALPHA=e.hasVertexAlpha&&i&&n}return e.isVerticesDataPresent(Ve.ColorInstanceKind)&&(e.hasInstances||e.hasThinInstances)&&(t.INSTANCESCOLOR=!0),s&&function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;const i=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&i)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!i&&void 0;const s=e.getScene().prePassRenderer;if(s&&s.enabled){const i=-1===s.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=i}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,void 0!==t.BONETEXTURE&&(t.BONETEXTURE=!1)}(e,t),r&&function(e,t){const i=e.morphTargetManager;i?(t.MORPHTARGETS_UV=i.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=i.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=i.supportsNormals&&t.NORMAL,t.NUM_MORPH_INFLUENCERS=i.numMaxInfluencers||i.numInfluencers,t.MORPHTARGETS=t.NUM_MORPH_INFLUENCERS>0,t.MORPHTARGETS_TEXTURE=i.isUsingTextureForTargets):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}(e,t),a&&function(e,t){const i=e.bakedVertexAnimationManager;t.BAKED_VERTEX_ANIMATION_TEXTURE=!(!i||!i.isEnabled)}(e,t),!0}function Fs(e,t){if(e.activeCamera){const i=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=i&&t.markAsUnprocessed()}}function ws(e,t,i){const s=t.ORDER_INDEPENDENT_TRANSPARENCY,r=t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;t.ORDER_INDEPENDENT_TRANSPARENCY=e.useOrderIndependentTransparency&&i,t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!e.getEngine().getCaps().textureFloatLinearFiltering,s===t.ORDER_INDEPENDENT_TRANSPARENCY&&r===t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS||t.markAsUnprocessed()}function Ns(e,t,i){const s=t.PREPASS;if(!t._arePrePassDirty)return;const r=[{type:Ve.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:Ve.PREPASS_LOCAL_POSITION_TEXTURE_TYPE,define:"PREPASS_LOCAL_POSITION",index:"PREPASS_LOCAL_POSITION_INDEX"},{type:Ve.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:Ve.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE,define:"PREPASS_VELOCITY_LINEAR",index:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:Ve.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:Ve.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:Ve.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:Ve.PREPASS_DEPTH_TEXTURE_TYPE,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:Ve.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE,define:"PREPASS_SCREENSPACE_DEPTH",index:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:Ve.PREPASS_NORMAL_TEXTURE_TYPE,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"},{type:Ve.PREPASS_WORLD_NORMAL_TEXTURE_TYPE,define:"PREPASS_WORLD_NORMAL",index:"PREPASS_WORLD_NORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&i){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount,t.PREPASS_NORMAL_WORLDSPACE=e.prePassRenderer.generateNormalsInWorldSpace,t.PREPASS_COLOR=!0,t.PREPASS_COLOR_INDEX=0;for(let i=0;i<r.length;i++){const s=e.prePassRenderer.getIndex(r[i].type);-1!==s?(t[r[i].define]=!0,t[r[i].index]=s):t[r[i].define]=!1}}else{t.PREPASS=!1;for(let e=0;e<r.length;e++)t[r[e].define]=!1}t.PREPASS!=s&&(t.markAsUnprocessed(),t.markAsImageProcessingDirty())}function Bs(e,t,i,s,r=null,n=!1,a=!1){r&&r.push("Light"+e),n||(t.push("vLightData"+e,"vLightDiffuse"+e,"vLightSpecular"+e,"vLightDirection"+e,"vLightFalloff"+e,"vLightGround"+e,"lightMatrix"+e,"shadowsInfo"+e,"depthValues"+e),i.push("shadowTexture"+e),i.push("depthTexture"+e),t.push("viewFrustumZ"+e,"cascadeBlendFactor"+e,"lightSizeUVCorrection"+e,"depthCorrection"+e,"penumbraDarkness"+e,"frustumLengths"+e),s&&(i.push("projectionLightTexture"+e),t.push("textureProjectionMatrix"+e)),a&&i.push("iesLightTexture"+e))}function Us(e,t,i,s=4){let r,n=null;if(e.uniformsNames){const a=e;r=a.uniformsNames,n=a.uniformBuffersNames,t=a.samplers,i=a.defines,s=a.maxSimultaneousLights||0}else r=e,t||(t=[]);for(let e=0;e<s&&i["LIGHT"+e];e++)Bs(e,r,t,i["PROJECTEDLIGHTTEXTURE"+e],n,!1,i["IESLIGHTTEXTURE"+e]);i.NUM_MORPH_INFLUENCERS&&(r.push("morphTargetInfluences"),r.push("morphTargetCount")),i.BAKED_VERTEX_ANIMATION_TEXTURE&&(r.push("bakedVertexAnimationSettings"),r.push("bakedVertexAnimationTextureSizeInverted"),r.push("bakedVertexAnimationTime"),t.push("bakedVertexAnimationTexture"))}class ks{get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;const t=this._alpha;this._alpha=e,1!==t&&1!==e||this.markAsDirty(ks.MiscDirtyFlag+ks.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(ks.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(ks.TextureDirtyFlag))}get cullBackFaces(){return this._cullBackFaces}get blockDirtyMechanism(){return this._blockDirtyMechanism}set blockDirtyMechanism(e){this._blockDirtyMechanism!==e&&(this._blockDirtyMechanism=e,e||this.markDirty())}atomicMaterialsUpdate(e){this.blockDirtyMechanism=!0;try{e(this)}finally{this.blockDirtyMechanism=!1}}get hasRenderTargetTextures(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new A),this._onBindObservable}set onBind(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)}get onUnBindObservable(){return this._onUnBindObservable||(this._onUnBindObservable=new A),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new A),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode!==e&&(this._alphaMode=e,this.markAsDirty(ks.TextureDirtyFlag))}get alphaMode(){return this._alphaMode}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(ks.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case ks.WireFrameFillMode:case ks.LineListDrawMode:case ks.LineLoopDrawMode:case ks.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?ks.WireFrameFillMode:ks.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case ks.PointFillMode:case ks.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?ks.PointFillMode:ks.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(ks.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&Ae.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,i,s=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new A,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=Ve.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new cs,this._useUBO=!1,this._fillMode=ks.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{},this._callbackPluginEventFillRenderTargetTextures=()=>{},this._forceAlphaTest=!1,this._transparencyMode=null,this.name=e;const r=t||O.LastCreatedScene;r&&(this._scene=r,this._dirtyCallbacks={},this._forceGLSL=s,this._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[Ve.MATERIAL_LightDirtyFlag]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[Ve.MATERIAL_FresnelDirtyFlag]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[Ve.MATERIAL_AttributesDirtyFlag]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[Ve.MATERIAL_MiscDirtyFlag]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[Ve.MATERIAL_PrePassDirtyFlag]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[Ve.MATERIAL_AllDirtyFlag]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||pi.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new Yi(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new rs(this._scene.getEngine(),void 0,void 0,e),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,this._createUniformBuffer(),i||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),ks.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const e=this.getScene().getEngine();this._uniformBuffer?.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new rs(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new rs(this._scene.getEngine(),void 0,void 0,this.name),this._uniformBufferLayoutBuilt=!1}toString(e){return"Name: "+this.name}getClassName(){return"Material"}get _isMaterial(){return!0}get isFrozen(){return this.checkReadyOnlyOnce}freeze(){this.markDirty(),this.checkReadyOnlyOnce=!0}unfreeze(){this.markDirty(),this.checkReadyOnlyOnce=!1}isReady(e,t){return!0}isReadyForSubMesh(e,t,i){const s=t.materialDefines;return!!s&&(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh)}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return null!==this.sideOrientation?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._forceAlphaTest=e===ks.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _disableAlphaBlending(){return this._transparencyMode===ks.MATERIAL_OPAQUE||this._transparencyMode===ks.MATERIAL_ALPHATEST}needAlphaBlending(){return!this._disableAlphaBlending&&this.alpha<1}needAlphaBlendingForMesh(e){return e.visibility<1||!this._disableAlphaBlending&&(e.hasVertexAlpha||this.needAlphaBlending())}needAlphaTesting(){return!!this._forceAlphaTest}_shouldTurnAlphaTestOn(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){const t=this.getScene().meshes;for(const i of t)if(i.subMeshes)for(const t of i.subMeshes)if(t.getMaterial()===this)for(const i of t._drawWrappers)i&&this._materialContext===i.materialContext&&(i._wasPreviouslyReady=!1,i._wasPreviouslyUsingInstances=null,i._forceRebindOnNextCall=e);e&&this.markAsDirty(ks.AllDirtyFlag)}_preBind(e,t=null){const i=this._scene.getEngine(),s=(null==t?this.sideOrientation:t)===ks.ClockWiseSideOrientation;return i.enableEffect(e||this._getDrawWrapper()),i.setState(this.backFaceCulling,this.zOffset,!1,s,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),s}bind(e,t){}buildUniformLayout(){const e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,i){const s=i._drawWrapper;this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),s._forceRebindOnNextCall=!1}bindOnlyWorldMatrix(e){}bindView(e){this._useUBO?this._needToBindSceneUbo=!0:e.setMatrix("view",this.getScene().getViewMatrix())}bindViewProjection(e){this._useUBO?this._needToBindSceneUbo=!0:(e.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.setMatrix("projection",this.getScene().getProjectionMatrix()))}bindEyePosition(e,t){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(e,t)}_afterBind(e,t=null,i){if(this._scene._cachedMaterial=this,this._needToBindSceneUbo&&t&&(this._needToBindSceneUbo=!1,function(e,t){t.bindToEffect(e,"Scene")}(t,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),this._scene._cachedVisibility=e?e.visibility:1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){const e=this._scene.getEngine();this._cachedDepthWriteState=e.getDepthWrite(),e.setDepthWrite(!1)}if(this.disableColorWrite){const e=this._scene.getEngine();this._cachedColorWriteState=e.getColorWrite(),e.setColorWrite(!1)}if(0!==this.depthFunction){const e=this._scene.getEngine();this._cachedDepthFunctionState=e.getDepthFunction()||0,e.setDepthFunction(this.depthFunction)}}unbind(){if(this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),0!==this.depthFunction){this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState)}if(this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}if(this.disableColorWrite){this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){const i={};if(this._serializePlugins(i),ks._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(const t of this.pluginManager._plugins){const i=e.pluginManager.getPlugin(t.name);i&&t.copyTo(i)}}getBindedMeshes(){if(this.meshMap){const e=[];for(const t in this.meshMap){const i=this.meshMap[t];i&&e.push(i)}return e}return this._scene.meshes.filter((e=>e.material===this))}forceCompilation(e,t,i,s){const r={clipPlane:!1,useInstances:!1,...i},n=this.getScene(),a=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const o=()=>{if(!this._scene||!this._scene.getEngine())return;const i=n.clipPlane;if(r.clipPlane&&(n.clipPlane=new Mi(0,0,0,1)),this._storeEffectOnSubMeshes){let i=!0,n=null;if(e.subMeshes){const t=new Xi(0,0,0,0,0,e,void 0,!1,!1);t.materialDefines&&(t.materialDefines._renderId=-1),this.isReadyForSubMesh(e,t,r.useInstances)||(t.effect&&t.effect.getCompilationError()&&t.effect.allFallbacksProcessed()?n=t.effect.getCompilationError():(i=!1,setTimeout(o,16)))}i&&(this.allowShaderHotSwapping=a,n&&s&&s(n),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=a,t&&t(this)):setTimeout(o,16);r.clipPlane&&(n.clipPlane=i)};o()}forceCompilationAsync(e,t){return new Promise(((i,s)=>{this.forceCompilation(e,(()=>{i()}),t,(e=>{s(e)}))}))}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(ks._DirtyCallbackArray.length=0,e&ks.TextureDirtyFlag&&ks._DirtyCallbackArray.push(ks._TextureDirtyCallBack),e&ks.LightDirtyFlag&&ks._DirtyCallbackArray.push(ks._LightsDirtyCallBack),e&ks.FresnelDirtyFlag&&ks._DirtyCallbackArray.push(ks._FresnelDirtyCallBack),e&ks.AttributesDirtyFlag&&ks._DirtyCallbackArray.push(ks._AttributeDirtyCallBack),e&ks.MiscDirtyFlag&&ks._DirtyCallbackArray.push(ks._MiscDirtyCallBack),e&ks.PrePassDirtyFlag&&ks._DirtyCallbackArray.push(ks._PrePassDirtyCallBack),ks._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(ks._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){const e=this.getScene().meshes;for(const t of e)if(t.subMeshes)for(const e of t.subMeshes)e.getMaterial()===this&&e.resetDrawCache()}_markAllSubMeshesAsDirty(e){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const t=this.getScene().meshes;for(const i of t)if(i.subMeshes)for(const t of i.subMeshes)if(t.getMaterial(!1)===this)for(const i of t._drawWrappers)i&&i.defines&&i.defines.markAllAsDirty&&this._materialContext===i.materialContext&&e(i.defines)}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(ks._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(ks._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(ks._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(ks._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(ks._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(ks._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(ks._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(ks._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(ks._MiscDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(ks._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(0!==this._scene.performancePriority){this.checkReadyOnlyOnce=!0;const e=this._scene.onScenePerformancePriorityChangedObservable.addOnce((()=>{this.checkReadyOnlyOnce=!1}));this.onDisposeObservable.add((()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)}))}}setPrePassRenderer(e){return!1}dispose(e,t,i){const s=this.getScene();if(s.stopAnimation(this),s.freeProcessedMaterials(),s.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){const e=this._parentContainer.materials.indexOf(this);e>-1&&this._parentContainer.materials.splice(e,1),this._parentContainer=null}if(!0!==i)if(this.meshMap)for(const e in this.meshMap){const t=this.meshMap[e];this._disposeMeshResources(t)}else{const e=s.meshes;for(const t of e)this._disposeMeshResources(t)}this._uniformBuffer.dispose(),this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}_disposeMeshResources(e){if(!e)return;const t=e.geometry,i=e._internalAbstractMeshDataInfo._materialForRenderPass;if(this._storeEffectOnSubMeshes){if(e.subMeshes&&i)for(const s of e.subMeshes){const e=s._drawWrappers;for(let r=0;r<e.length;r++){const n=e[r]?.effect;if(!n)continue;i[r]===this&&(t?._releaseVertexArrayObject(n),s._removeDrawWrapper(r,!0,!0))}}}else t?._releaseVertexArrayObject(this._drawWrapper.effect);e.material!==this||e.sourceMesh||(e.material=null)}serialize(){const e=de.Serialize(this);return e.stencil=this.stencil.serialize(),e.uniqueId=this.uniqueId,this._serializePlugins(e),e}_serializePlugins(e){if(e.plugins={},this.pluginManager)for(const t of this.pluginManager._plugins)t.doNotSerialize||(e.plugins[t.getClassName()]=t.serialize())}static Parse(e,t,i){if(e.customType){if("BABYLON.PBRMaterial"===e.customType&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return Ae.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else e.customType="BABYLON.StandardMaterial";const s=pi.Instantiate(e.customType).Parse(e,t,i);return s._loadedUniqueId=e.uniqueId,s}static _ParsePlugins(e,t,i,s){if(e.plugins)for(const r in e.plugins){const n=e.plugins[r];let a=t.pluginManager?.getPlugin(n.name);if(!a){const e=pi.Instantiate("BABYLON."+r);e&&(a=new e(t))}a?.parse(n,i,s)}}}ks.TriangleFillMode=Ve.MATERIAL_TriangleFillMode,ks.WireFrameFillMode=Ve.MATERIAL_WireFrameFillMode,ks.PointFillMode=Ve.MATERIAL_PointFillMode,ks.PointListDrawMode=Ve.MATERIAL_PointListDrawMode,ks.LineListDrawMode=Ve.MATERIAL_LineListDrawMode,ks.LineLoopDrawMode=Ve.MATERIAL_LineLoopDrawMode,ks.LineStripDrawMode=Ve.MATERIAL_LineStripDrawMode,ks.TriangleStripDrawMode=Ve.MATERIAL_TriangleStripDrawMode,ks.TriangleFanDrawMode=Ve.MATERIAL_TriangleFanDrawMode,ks.ClockWiseSideOrientation=Ve.MATERIAL_ClockWiseSideOrientation,ks.CounterClockWiseSideOrientation=Ve.MATERIAL_CounterClockWiseSideOrientation,ks.TextureDirtyFlag=Ve.MATERIAL_TextureDirtyFlag,ks.LightDirtyFlag=Ve.MATERIAL_LightDirtyFlag,ks.FresnelDirtyFlag=Ve.MATERIAL_FresnelDirtyFlag,ks.AttributesDirtyFlag=Ve.MATERIAL_AttributesDirtyFlag,ks.MiscDirtyFlag=Ve.MATERIAL_MiscDirtyFlag,ks.PrePassDirtyFlag=Ve.MATERIAL_PrePassDirtyFlag,ks.AllDirtyFlag=Ve.MATERIAL_AllDirtyFlag,ks.MATERIAL_OPAQUE=0,ks.MATERIAL_ALPHATEST=1,ks.MATERIAL_ALPHABLEND=2,ks.MATERIAL_ALPHATESTANDBLEND=3,ks.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,ks.MATERIAL_NORMALBLENDMETHOD_RNM=1,ks.OnEventObservable=new A,ks._AllDirtyCallBack=e=>e.markAllAsDirty(),ks._ImageProcessingDirtyCallBack=e=>e.markAsImageProcessingDirty(),ks._TextureDirtyCallBack=e=>e.markAsTexturesDirty(),ks._FresnelDirtyCallBack=e=>e.markAsFresnelDirty(),ks._MiscDirtyCallBack=e=>e.markAsMiscDirty(),ks._PrePassDirtyCallBack=e=>e.markAsPrePassDirty(),ks._LightsDirtyCallBack=e=>e.markAsLightDirty(),ks._AttributeDirtyCallBack=e=>e.markAsAttributesDirty(),ks._FresnelAndMiscDirtyCallBack=e=>{ks._FresnelDirtyCallBack(e),ks._MiscDirtyCallBack(e)},ks._TextureAndMiscDirtyCallBack=e=>{ks._TextureDirtyCallBack(e),ks._MiscDirtyCallBack(e)},ks._DirtyCallbackArray=[],ks._RunDirtyCallBacks=e=>{for(const t of ks._DirtyCallbackArray)t(e)},e([a()],ks.prototype,"id",void 0),e([a()],ks.prototype,"uniqueId",void 0),e([a()],ks.prototype,"name",void 0),e([a()],ks.prototype,"metadata",void 0),e([a()],ks.prototype,"checkReadyOnEveryCall",void 0),e([a()],ks.prototype,"checkReadyOnlyOnce",void 0),e([a()],ks.prototype,"state",void 0),e([a("alpha")],ks.prototype,"_alpha",void 0),e([a("backFaceCulling")],ks.prototype,"_backFaceCulling",void 0),e([a("cullBackFaces")],ks.prototype,"_cullBackFaces",void 0),e([a()],ks.prototype,"sideOrientation",void 0),e([a("alphaMode")],ks.prototype,"_alphaMode",void 0),e([a()],ks.prototype,"_needDepthPrePass",void 0),e([a()],ks.prototype,"disableDepthWrite",void 0),e([a()],ks.prototype,"disableColorWrite",void 0),e([a()],ks.prototype,"forceDepthWrite",void 0),e([a()],ks.prototype,"depthFunction",void 0),e([a()],ks.prototype,"separateCullingPass",void 0),e([a("fogEnabled")],ks.prototype,"_fogEnabled",void 0),e([a()],ks.prototype,"pointSize",void 0),e([a()],ks.prototype,"zOffset",void 0),e([a()],ks.prototype,"zOffsetUnits",void 0),e([a()],ks.prototype,"pointsCloud",null),e([a()],ks.prototype,"fillMode",null),e([a()],ks.prototype,"useLogarithmicDepth",null),e([a()],ks.prototype,"transparencyMode",null);class Vs extends ks{get subMaterials(){return this._subMaterials}set subMaterials(e){this._subMaterials=e,this._hookArray(e)}getChildren(){return this.subMaterials}constructor(e,t){super(e,t,!0),this._waitingSubMaterialsUniqueIds=[],this.getScene().addMultiMaterial(this),this.subMaterials=[],this._storeEffectOnSubMeshes=!0}_hookArray(e){const t=e.push;e.push=(...i)=>{const s=t.apply(e,i);return this._markAllSubMeshesAsTexturesDirty(),s};const i=e.splice;e.splice=(t,s)=>{const r=i.apply(e,[t,s]);return this._markAllSubMeshesAsTexturesDirty(),r}}getSubMaterial(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]}getActiveTextures(){return super.getActiveTextures().concat(...this.subMaterials.map((e=>e?e.getActiveTextures():[])))}hasTexture(e){if(super.hasTexture(e))return!0;for(let t=0;t<this.subMaterials.length;t++)if(this.subMaterials[t]?.hasTexture(e))return!0;return!1}getClassName(){return"MultiMaterial"}isReadyForSubMesh(e,t,i){for(let s=0;s<this.subMaterials.length;s++){const r=this.subMaterials[s];if(r){if(r._storeEffectOnSubMeshes){if(!r.isReadyForSubMesh(e,t,i))return!1;continue}if(!r.isReady(e))return!1}}return!0}clone(e,t){const i=new Vs(e,this.getScene());for(let s=0;s<this.subMaterials.length;s++){let r=null;const n=this.subMaterials[s];r=t&&n?n.clone(e+"-"+n.name):this.subMaterials[s],i.subMaterials.push(r)}return i}serialize(){const e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,se&&(e.tags=se.GetTags(this)),e.materialsUniqueIds=[],e.materials=[];for(let t=0;t<this.subMaterials.length;t++){const i=this.subMaterials[t];i?(e.materialsUniqueIds.push(i.uniqueId),e.materials.push(i.id)):(e.materialsUniqueIds.push(null),e.materials.push(null))}return e}dispose(e,t,i){const s=this.getScene();if(!s)return;if(i)for(let i=0;i<this.subMaterials.length;i++){const s=this.subMaterials[i];s&&s.dispose(e,t)}const r=s.multiMaterials.indexOf(this);r>=0&&s.multiMaterials.splice(r,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){const i=new Vs(e.name,t);return i.id=e.id,i._loadedUniqueId=e.uniqueId,se&&se.AddTagsTo(i,e.tags),e.materialsUniqueIds?i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach((e=>i.subMaterials.push(t.getLastMaterialById(e)))),i}}S("BABYLON.MultiMaterial",Vs);class zs{}zs.NAME_EFFECTLAYER="EffectLayer",zs.NAME_LAYER="Layer",zs.NAME_LENSFLARESYSTEM="LensFlareSystem",zs.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",zs.NAME_PARTICLESYSTEM="ParticleSystem",zs.NAME_GAMEPAD="Gamepad",zs.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",zs.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",zs.NAME_PREPASSRENDERER="PrePassRenderer",zs.NAME_DEPTHRENDERER="DepthRenderer",zs.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer",zs.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",zs.NAME_SPRITE="Sprite",zs.NAME_SUBSURFACE="SubSurface",zs.NAME_OUTLINERENDERER="Outline",zs.NAME_PROCEDURALTEXTURE="ProceduralTexture",zs.NAME_SHADOWGENERATOR="ShadowGenerator",zs.NAME_OCTREE="Octree",zs.NAME_PHYSICSENGINE="PhysicsEngine",zs.NAME_AUDIO="Audio",zs.NAME_FLUIDRENDERER="FluidRenderer",zs.NAME_IBLCDFGENERATOR="iblCDFGenerator",zs.STEP_ISREADYFORMESH_EFFECTLAYER=0,zs.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,zs.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,zs.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,zs.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,zs.STEP_BEFORECAMERADRAW_PREPASS=0,zs.STEP_BEFORECAMERADRAW_EFFECTLAYER=1,zs.STEP_BEFORECAMERADRAW_LAYER=2,zs.STEP_BEFORERENDERTARGETDRAW_PREPASS=0,zs.STEP_BEFORERENDERTARGETDRAW_LAYER=1,zs.STEP_BEFORERENDERINGMESH_PREPASS=0,zs.STEP_BEFORERENDERINGMESH_OUTLINE=1,zs.STEP_AFTERRENDERINGMESH_PREPASS=0,zs.STEP_AFTERRENDERINGMESH_OUTLINE=1,zs.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,zs.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,zs.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,zs.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,zs.STEP_BEFORECLEAR_PREPASS=1,zs.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0,zs.STEP_AFTERRENDERTARGETDRAW_PREPASS=0,zs.STEP_AFTERRENDERTARGETDRAW_LAYER=1,zs.STEP_AFTERCAMERADRAW_PREPASS=0,zs.STEP_AFTERCAMERADRAW_EFFECTLAYER=1,zs.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2,zs.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3,zs.STEP_AFTERCAMERADRAW_LAYER=4,zs.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5,zs.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0,zs.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0,zs.STEP_AFTERRENDER_AUDIO=0,zs.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,zs.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,zs.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,zs.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,zs.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,zs.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1,zs.STEP_POINTERMOVE_SPRITE=0,zs.STEP_POINTERDOWN_SPRITE=0,zs.STEP_POINTERUP_SPRITE=0;class Gs extends Array{constructor(e){super(...e)}static Create(){return Object.create(Gs.prototype)}registerStep(e,t,i){let s=0,r=Number.MAX_VALUE;for(;s<this.length;s++){if(r=this[s].index,e<r)break}this.splice(s,0,{index:e,component:t,action:i.bind(t)})}clear(){this.length=0}}class Hs{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class Ws{constructor(){this.visibleInstances={},this.batchCache=new Ks,this.batchCacheReplacementModeInFrozenMode=new Ks,this.instancesBufferSize=2048}}class Ks{constructor(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class Ys{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class Xs{constructor(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._useLODScreenCoverage=!1,this._effectiveMaterial=null,this._forcedInstanceCount=0,this._overrideRenderingFillMode=null}}class Qs extends ls{static _GetDefaultSideOrientation(e){return e||Qs.FRONTSIDE}get useLODScreenCoverage(){return this._internalMeshDataInfo._useLODScreenCoverage}set useLODScreenCoverage(e){this._internalMeshDataInfo._useLODScreenCoverage=e,this._sortLODLevels()}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(wi.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(wi.NormalKind,this._internalMeshDataInfo._sourceNormals,!0),this._internalMeshDataInfo._sourcePositions=null,this._internalMeshDataInfo._sourceNormals=null),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get onBeforeRenderObservable(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new A),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new A),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new A),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new A),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new A),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&e===Ve.MATERIAL_CounterClockWiseSideOrientation||!this._scene.useRightHandedSystem&&e===Ve.MATERIAL_ClockWiseSideOrientation}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&null===this.material.sideOrientation||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesData}get previousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesPreviousData}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,i=!0){const s=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),be.DeepCopy(e,this,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),this._internalMeshDataInfo._source=e,s.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){const t=e._ranges;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&this.createAnimationRange(e,t[e].from,t[e].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,se&&se.HasTags(e)&&se.AddTagsTo(this,se.GetTags(e,!0)),this.setEnabled(e.isEnabled(!1)),this.parent=e.parent,this.setPivotMatrix(e.getPivotMatrix(),this._postMultiplyPivotMatrix),this.id=this.name+"."+e.id,this.material=e.material,!t){const t=e.getDescendants(!0);for(let e=0;e<t.length;e++){const i=t[e];i.clone&&i.clone(this.name+"."+i.name,this)}}if(e.morphTargetManager&&(this.morphTargetManager=e.morphTargetManager),s.getPhysicsEngine){const t=s.getPhysicsEngine();if(i&&t)if(1===t.getPluginVersion()){const i=t.getImpostorForPhysicsObject(e);i&&(this.physicsImpostor=i.clone(this))}else 2===t.getPluginVersion()&&e.physicsBody&&e.physicsBody.clone(this)}for(let t=0;t<s.particleSystems.length;t++){const i=s.particleSystems[t];i.emitter===e&&i.clone(i.name,this)}this.skeleton=e.skeleton,this.refreshBoundingInfo(!0,!0),this.computeWorldMatrix(!0)}constructor(e,t=null,i=null,s=null,r,n=!0){super(e,t),this._internalMeshDataInfo=new Xs,this.delayLoadState=Ve.DELAYLOADSTATE_NONE,this.instances=[],this._creationDataStorage=null,this._geometry=null,this._instanceDataStorage=new Ws,this._thinInstanceDataStorage=new Ys,this._shouldGenerateFlatShading=!1,this._originalBuilderSideOrientation=Qs.DEFAULTSIDE,this.ignoreCameraMaxZ=!1,t=this.getScene(),this._scene.useRightHandedSystem?this.sideOrientation=Ve.MATERIAL_ClockWiseSideOrientation:this.sideOrientation=Ve.MATERIAL_CounterClockWiseSideOrientation,this._onBeforeDraw=(e,t,i)=>{e&&i&&(this._uniformBuffer?this.transferToEffect(t):i.bindOnlyWorldMatrix(t))},s&&this._copySource(s,r,n),null!==i&&(this.parent=i),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=e=>{e.unregisterOnNextCall=!0,this.isReady(!0)?this.onMeshReadyObservable.notifyObservers(this):this._internalMeshDataInfo._checkReadinessObserver||(this._internalMeshDataInfo._checkReadinessObserver=this._scene.onBeforeRenderObservable.add((()=>{this.isReady(!0)&&(this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),this._internalMeshDataInfo._checkReadinessObserver=null,this.onMeshReadyObservable.notifyObservers(this))})))},this.onMeshReadyObservable=new A(this._internalMeshDataInfo._onMeshReadyObserverAdded),s&&s.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,i){const s=0===this.getTotalVertices()||t&&t.doNotInstantiate&&(!0===t.doNotInstantiate||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));s.parent=e||this.parent,s.position=this.position.clone(),s.scaling=this.scaling.clone(),this.rotationQuaternion?s.rotationQuaternion=this.rotationQuaternion.clone():s.rotation=this.rotation.clone(),i&&i(this,s);for(const e of this.getChildTransformNodes(!0))"InstancedMesh"===e.getClassName()&&"Mesh"===s.getClassName()&&e.sourceMesh===this?e.instantiateHierarchy(s,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:s},i):e.instantiateHierarchy(s,t,i);return s}getClassName(){return"Mesh"}get _isMesh(){return!0}toString(e){let t=super.toString(e);if(t+=", n vertices: "+this.getTotalVertices(),t+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);if(e)if(this._geometry){const e=this.getIndices(),i=this.getVerticesData(wi.PositionKind);i&&e&&(t+=", flat shading: "+(i.length/3===e.length?"YES":"NO"))}else t+=", flat shading: UNKNOWN";return t}_unBindEffect(){super._unBindEffect();for(const e of this.instances)e._unBindEffect()}get hasLODLevels(){return this._internalMeshDataInfo._LODLevels.length>0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){const e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort(((t,i)=>t.distanceOrScreenCoverage<i.distanceOrScreenCoverage?e:t.distanceOrScreenCoverage>i.distanceOrScreenCoverage?-e:0))}addLODLevel(e,t){if(t&&t._masterMesh)return Ae.Warn("You cannot use a mesh as LOD level twice"),this;const i=new Hs(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++){const s=t._LODLevels[i];if(s.distanceOrScreenCoverage===e)return s.mesh}return null}removeLODLevel(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++)t._LODLevels[i].mesh===e&&(t._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this}getLOD(e,t){const i=this._internalMeshDataInfo;if(!i._LODLevels||0===i._LODLevels.length)return this;const s=t||this.getBoundingInfo().boundingSphere,r=e.mode===xi.ORTHOGRAPHIC_CAMERA?e.minZ:s.centerWorld.subtract(e.globalPosition).length();let n=r,a=1;if(i._useLODScreenCoverage){const t=e.screenArea;let i=s.radiusWorld*e.minZ/r;i=i*i*Math.PI,n=i/t,a=-1}if(a*i._LODLevels[i._LODLevels.length-1].distanceOrScreenCoverage>a*n)return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this;for(let e=0;e<i._LODLevels.length;e++){const t=i._LODLevels[e];if(a*t.distanceOrScreenCoverage<a*n){if(t.mesh){if(t.mesh.delayLoadState===Ve.DELAYLOADSTATE_NOTLOADED)return t.mesh._checkDelayState(),this;if(t.mesh.delayLoadState===Ve.DELAYLOADSTATE_LOADING)return this;t.mesh._preActivate(),t.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,t.mesh),t.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this}get geometry(){return this._geometry}getTotalVertices(){return null===this._geometry||void 0===this._geometry?0:this._geometry.getTotalVertices()}getVerticesData(e,t,i,s){if(!this._geometry)return null;let r=s?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e]?.getFloatData(this.instances.length+1,i||t&&1!==this._geometry.meshes.length);return r||(r=this._geometry.getVerticesData(e,t,i)),r}copyVerticesData(e,t){this._geometry&&this._geometry.copyVerticesData(e,t)}getVertexBuffer(e,t){return this._geometry?(t?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e])??this._geometry.getVertexBuffer(e):null}isVerticesDataPresent(e,t){return this._geometry?!t&&void 0!==this._userInstancedBuffersStorage?.vertexBuffers[e]||this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)}isVertexBufferUpdatable(e,t){if(!this._geometry)return!!this._delayInfo&&-1!==this._delayInfo.indexOf(e);if(!t){const t=this._userInstancedBuffersStorage?.vertexBuffers[e];if(t)return t.isUpdatable()}return this._geometry.isVertexBufferUpdatable(e)}getVerticesDataKinds(e){if(!this._geometry){const e=[];return this._delayInfo&&this._delayInfo.forEach((function(t){e.push(t)})),e}const t=this._geometry.getVerticesDataKinds();if(!e&&this._userInstancedBuffersStorage)for(const e in this._userInstancedBuffersStorage.vertexBuffers)-1===t.indexOf(e)&&t.push(e);return t}getTotalIndices(){return this._geometry?this._geometry.getTotalIndices():0}getIndices(e,t){return this._geometry?this._geometry.getIndices(e,t):[]}get isBlocked(){return null!==this._masterMesh&&void 0!==this._masterMesh}isReady(e=!1,t=!1){if(this.delayLoadState===Ve.DELAYLOADSTATE_LOADING)return!1;if(!super.isReady(e))return!1;if(!this.subMeshes||0===this.subMeshes.length)return!0;if(!e)return!0;const i=this.getEngine(),s=this.getScene(),r=t||i.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();const n=this.material||s.defaultMaterial;if(n)if(n._storeEffectOnSubMeshes)for(const e of this.subMeshes){const t=e.getMaterial();if(t)if(t._storeEffectOnSubMeshes){if(!t.isReadyForSubMesh(this,e,r))return!1}else if(!t.isReady(this,r))return!1}else if(!n.isReady(this,r))return!1;const a=i.currentRenderPassId;for(const e of this.lightSources){const t=e.getShadowGenerators();if(!t)continue;const s=t.values();for(let e=s.next();!0!==e.done;e=s.next()){const t=e.value;if(t&&(!t.getShadowMap()?.renderList||t.getShadowMap()?.renderList&&-1!==t.getShadowMap()?.renderList?.indexOf(this))){const e=t.getShadowMap().renderPassIds??[i.currentRenderPassId];for(let s=0;s<e.length;++s){i.currentRenderPassId=e[s];for(const e of this.subMeshes)if(!t.isReady(e,r,e.getMaterial()?.needAlphaBlendingForMesh(this)??!1))return i.currentRenderPassId=a,!1}i.currentRenderPassId=a}}}for(const e of this._internalMeshDataInfo._LODLevels)if(e.mesh&&!e.mesh.isReady(r))return!1;return!0}get areNormalsFrozen(){return this._internalMeshDataInfo._areNormalsFrozen}freezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this}unfreezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this}set overridenInstanceCount(e){this._instanceDataStorage.overridenInstanceCount=e}_preActivate(){const e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t||(e._preActivateId=t,this._instanceDataStorage.visibleInstances=null),this}_preActivateForIntermediateRendering(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this}_registerInstanceForRenderId(e,t){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId}),this._instanceDataStorage.visibleInstances[t]||(void 0!==this._instanceDataStorage.previousRenderId&&this._instanceDataStorage.isFrozen&&(this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId]=null),this._instanceDataStorage.previousRenderId=t,this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.visibleInstances[t].push(e),this}_afterComputeWorldMatrix(){super._afterComputeWorldMatrix(),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))}_postActivate(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let i;i="object"==typeof e?e:{applySkeleton:e,applyMorph:t};const s=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getData(i,null,wi.PositionKind),s),this}_createGlobalSubMesh(e){const t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){const i=this.getIndices();if(!i)return null;const s=i.length;let r=!1;if(e)r=!0;else for(const e of this.subMeshes){if(e.indexStart+e.indexCount>s){r=!0;break}if(e.verticesStart+e.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new Xi(0,0,t,0,this.getTotalIndices(),this)}subdivide(e){if(e<1)return;const t=this.getTotalIndices();let i=t/e|0,s=0;for(;i%3!=0;)i++;this.releaseSubMeshes();for(let r=0;r<e&&!(s>=t);r++)Xi.CreateFromIndices(0,s,r===e-1?t-s:i,this,void 0,!1),s+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,i=!1,s){if(this._geometry)this._geometry.setVerticesData(e,t,i,s);else{const s=new qi;s.set(t,e);const r=this.getScene();new Zi(Zi.RandomId(),r,s,i,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){const i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0){return this._geometry||(this._geometry=Zi.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this}updateVerticesData(e,t,i,s){return this._geometry?(s?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this}updateMeshPositions(e,t=!0){const i=this.getVerticesData(wi.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(wi.PositionKind,i,!1,!1),t){const e=this.getIndices(),t=this.getVerticesData(wi.NormalKind);if(!t)return this;qi.ComputeNormals(i,e,t),this.updateVerticesData(wi.NormalKind,t,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;const e=this._geometry,t=this._geometry.copy(Zi.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i){let s=this._geometry;s||(s=new Zi(Zi.RandomId(),this.getScene(),void 0,void 0,this)),s.setIndexBuffer(e,t,i)}setIndices(e,t=null,i=!1,s=!1){if(this._geometry)this._geometry.setIndices(e,t,i,s);else{const t=new qi;t.indices=e;const s=this.getScene();new Zi(Zi.RandomId(),s,t,i,this)}return this}updateIndices(e,t,i=!1){return this._geometry?(this._geometry.updateIndices(e,t,i),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,i,s=!0){if(!this._geometry)return this;const r=this.getScene().getEngine();let n;if(this._unIndexed)if(this._getRenderingFillMode(i)===ks.WireFrameFillMode)n=e._getLinesIndexBuffer(this.getIndices(),r);else n=null;else switch(this._getRenderingFillMode(i)){case ks.PointFillMode:n=null;break;case ks.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case ks.TriangleFillMode:n=this._geometry.getIndexBuffer()}return this._bindDirect(t,n,s)}_bindDirect(e,t,i=!0){return this._geometry?(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),i&&this._userInstancedBuffersStorage&&!this.hasThinInstances?this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects):this._geometry._bind(e,t),this):this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);const s=this.getScene().getEngine();return this._unIndexed&&t!==ks.WireFrameFillMode||t==ks.PointFillMode?s.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==ks.WireFrameFillMode?s.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):s.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this}registerBeforeRender(e){return this.onBeforeRenderObservable.add(e),this}unregisterBeforeRender(e){return this.onBeforeRenderObservable.removeCallback(e),this}registerAfterRender(e){return this.onAfterRenderObservable.add(e),this}unregisterAfterRender(e){return this.onAfterRenderObservable.removeCallback(e),this}_getInstancesRenderList(e,t=!1){if(this._instanceDataStorage.isFrozen){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}const i=this.getScene(),s=i._isInIntermediateRendering(),r=s?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,n=this._instanceDataStorage.batchCache;if(n.mustReturn=!1,n.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,n.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){const t=this._instanceDataStorage.visibleInstances,r=i.getRenderId(),a=s?t.intermediateDefaultRenderId:t.defaultRenderId;n.visibleInstances[e]=t[r],!n.visibleInstances[e]&&a&&(n.visibleInstances[e]=t[a])}return n.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==n.visibleInstances[e]&&void 0!==n.visibleInstances[e],this._instanceDataStorage.previousBatch=n,n}_renderWithInstances(e,t,i,s,r){const n=i.visibleInstances[e._id],a=n?n.length:0,o=this._instanceDataStorage,h=o.instancesBufferSize;let l=o.instancesBuffer,c=o.instancesPreviousBuffer;const u=16*(a+1)*4;for(;o.instancesBufferSize<u;)o.instancesBufferSize*=2;o.instancesData&&h==o.instancesBufferSize||(o.instancesData=new Float32Array(o.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!o.instancesPreviousData||h!=o.instancesBufferSize)&&(o.instancesPreviousData=new Float32Array(o.instancesBufferSize/4));let d=0,_=0;const f=i.renderSelf[e._id],p=!l||h!==o.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!o.instancesPreviousBuffer;if(this._instanceDataStorage.manualUpdate||o.isFrozen&&!p)_=(f?1:0)+a;else{const t=this.getWorldMatrix();if(f&&(this._scene.needsPreviousWorldMatrices&&(o.masterMeshPreviousWorldMatrix?(o.masterMeshPreviousWorldMatrix.copyToArray(o.instancesPreviousData,d),o.masterMeshPreviousWorldMatrix.copyFrom(t)):(o.masterMeshPreviousWorldMatrix=t.clone(),o.masterMeshPreviousWorldMatrix.copyToArray(o.instancesPreviousData,d))),t.copyToArray(o.instancesData,d),d+=16,_++),n){if(Qs.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const e=this._scene.activeCamera.globalPosition;for(let t=0;t<n.length;t++){const i=n[t];i._distanceToCamera=X.Distance(i.getBoundingInfo().boundingSphere.centerWorld,e)}n.sort(((e,t)=>e._distanceToCamera>t._distanceToCamera?-1:e._distanceToCamera<t._distanceToCamera?1:0))}for(let e=0;e<n.length;e++){const t=n[e],i=t.getWorldMatrix();i.copyToArray(o.instancesData,d),this._scene.needsPreviousWorldMatrices&&(t._previousWorldMatrix?(t._previousWorldMatrix.copyToArray(o.instancesPreviousData,d),t._previousWorldMatrix.copyFrom(i)):(t._previousWorldMatrix=i.clone(),t._previousWorldMatrix.copyToArray(o.instancesPreviousData,d))),d+=16,_++}}}return p?(l&&l.dispose(),c&&c.dispose(),l=new Fi(r,o.instancesData,!0,16,!1,!0),o.instancesBuffer=l,this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this._userInstancedBuffersStorage.vertexBuffers.world0=l.createVertexBuffer("world0",0,4),this._userInstancedBuffersStorage.vertexBuffers.world1=l.createVertexBuffer("world1",4,4),this._userInstancedBuffersStorage.vertexBuffers.world2=l.createVertexBuffer("world2",8,4),this._userInstancedBuffersStorage.vertexBuffers.world3=l.createVertexBuffer("world3",12,4),this._scene.needsPreviousWorldMatrices&&(c=new Fi(r,o.instancesPreviousData,!0,16,!1,!0),o.instancesPreviousBuffer=c,this._userInstancedBuffersStorage.vertexBuffers.previousWorld0=c.createVertexBuffer("previousWorld0",0,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld1=c.createVertexBuffer("previousWorld1",4,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld2=c.createVertexBuffer("previousWorld2",8,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld3=c.createVertexBuffer("previousWorld3",12,4)),this._invalidateInstanceVertexArrayObject()):this._instanceDataStorage.isFrozen&&!this._instanceDataStorage.forceMatrixUpdates||(l.updateDirectly(o.instancesData,0,_),!this._scene.needsPreviousWorldMatrices||this._instanceDataStorage.manualUpdate&&!this._instanceDataStorage.previousManualUpdate||c.updateDirectly(o.instancesPreviousData,0,_)),this._processInstancedBuffers(n,f),this.getScene()._activeIndices.addCount(e.indexCount*_,!1),r._currentDrawContext&&(r._currentDrawContext.useInstancing=!0),this._bind(e,s,t),this._draw(e,t,_),!this._scene.needsPreviousWorldMatrices||p||!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.isFrozen&&!this._instanceDataStorage.forceMatrixUpdates||this._instanceDataStorage.previousManualUpdate||c.updateDirectly(o.instancesData,0,_),r.unbindInstanceAttributes(),this}_renderWithThinInstances(e,t,i,s){const r=this._thinInstanceDataStorage?.instancesCount??0;this.getScene()._activeIndices.addCount(e.indexCount*r,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,i,t),this._draw(e,t,r),this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&this._thinInstanceDataStorage.matrixData&&(this._thinInstanceDataStorage.previousMatrixBuffer?this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,r):this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",this._thinInstanceDataStorage.matrixData,!1)),s.unbindInstanceAttributes()}_processInstancedBuffers(e,t){}_processRendering(e,t,i,s,r,n,a,o){const h=this.getScene(),l=h.getEngine();if(s=this._getRenderingFillMode(s),n&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,s,i,l),this;if(n)this._renderWithInstances(t,s,r,i,l);else{l._currentDrawContext&&(l._currentDrawContext.useInstancing=!1);let i=0;r.renderSelf[t._id]&&(a&&a(!1,e.getWorldMatrix(),o),i++,this._draw(t,s,this._instanceDataStorage.overridenInstanceCount));const n=r.visibleInstances[t._id];if(n){const e=n.length;i+=e;for(let i=0;i<e;i++){const e=n[i].getWorldMatrix();a&&a(!0,e,o),this._draw(t,s)}}h._activeIndices.addCount(t.indexCount*i,!1)}return this}_rebuild(e=!1){if(this._instanceDataStorage.instancesBuffer&&(e&&this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null),this._userInstancedBuffersStorage){for(const t in this._userInstancedBuffersStorage.vertexBuffers){const i=this._userInstancedBuffersStorage.vertexBuffers[t];i&&(e&&i.dispose(),this._userInstancedBuffersStorage.vertexBuffers[t]=null)}this._userInstancedBuffersStorage.vertexArrayObjects&&(this._userInstancedBuffersStorage.vertexArrayObjects={})}this._internalMeshDataInfo._effectiveMaterial=null,super._rebuild(e)}_freeze(){if(this.subMeshes){for(let e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._internalMeshDataInfo._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}}_unFreeze(){this._instanceDataStorage.isFrozen=!1,this._instanceDataStorage.previousBatch=null}renderWithRenderPassId(e,t,i,s,r=!0){const n=this._scene.getEngine(),a=n.currentRenderPassId;if(void 0!==e&&(n.currentRenderPassId=e),s)(!r||r&&s.isInFrustum(this._scene._frustumPlanes))&&this.render(s,!!t,i);else for(let e=0;e<this.subMeshes.length;e++){const s=this.subMeshes[e];(!r||r&&s.isInFrustum(this._scene._frustumPlanes))&&this.render(s,!!t,i)}return void 0!==e&&(n.currentRenderPassId=a),this}directRender(){if(!this.subMeshes)return this;for(const e of this.subMeshes)this.render(e,!1);return this}render(e,t,i){const s=this.getScene();this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1;const r=s.activeCameras?.length??0;if((r>1&&s.activeCamera===s.activeCameras[0]||r<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;const n=this._getInstancesRenderList(e._id,!!i);if(n.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const a=s.getEngine();let o=0,h=null;this.ignoreCameraMaxZ&&s.activeCamera&&!s._isInIntermediateRendering()&&(o=s.activeCamera.maxZ,h=s.activeCamera,s.activeCamera.maxZ=0,s.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);const l=e.getRenderingMesh(),c=n.hardwareInstancedRendering[e._id]||l.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,u=this._instanceDataStorage,d=e.getMaterial();if(!d)return h&&(h.maxZ=o,s.updateTransformMatrix(!0)),this;if(u.isFrozen&&this._internalMeshDataInfo._effectiveMaterial&&this._internalMeshDataInfo._effectiveMaterial===d){if(d._storeEffectOnSubMeshes&&!e._drawWrapper?._wasPreviouslyReady||!d._storeEffectOnSubMeshes&&!d._getDrawWrapper()._wasPreviouslyReady)return h&&(h.maxZ=o,s.updateTransformMatrix(!0)),this}else{if(d._storeEffectOnSubMeshes){if(!d.isReadyForSubMesh(this,e,c))return h&&(h.maxZ=o,s.updateTransformMatrix(!0)),this}else if(!d.isReady(this,c))return h&&(h.maxZ=o,s.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=d}let _;t&&a.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode),_=this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?e._drawWrapper:this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const f=_?.effect??null;for(const t of s._beforeRenderingMeshStage)t.action(this,e,n,f);if(!_||!f)return h&&(h.maxZ=o,s.updateTransformMatrix(!0)),this;const p=i||this;let g;if(u.isFrozen||!this._internalMeshDataInfo._effectiveMaterial.backFaceCulling&&null===this._internalMeshDataInfo._effectiveMaterial.sideOrientation&&!this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)g=u.sideOrientation;else{const e=p._getWorldMatrixDeterminant();g=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),e<0&&(g=g===ks.ClockWiseSideOrientation?ks.CounterClockWiseSideOrientation:ks.ClockWiseSideOrientation),u.sideOrientation=g}const m=this._internalMeshDataInfo._effectiveMaterial._preBind(_,g);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&a.setDepthWrite(!0);const T=this._internalMeshDataInfo._effectiveMaterial,A=T.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),c||this._bind(e,f,A,!1);const E=p.getWorldMatrix();T._storeEffectOnSubMeshes?T.bindForSubMesh(E,this,e):T.bind(E,this),!T.backFaceCulling&&T.separateCullingPass&&(a.setState(!0,T.zOffset,!1,!m,T.cullBackFaces,T.stencil,T.zOffsetUnits),this._processRendering(this,e,f,A,n,c,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),a.setState(!0,T.zOffset,!1,m,T.cullBackFaces,T.stencil,T.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,f,A,n,c,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const t of s._afterRenderingMeshStage)t.action(this,e,n,f);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),h&&(h.maxZ=o,s.updateTransformMatrix(!0)),2!==s.performancePriority||u.isFrozen||this._freeze(),this}cleanMatrixWeights(){this.isVerticesDataPresent(wi.MatricesWeightsKind)&&(this.isVerticesDataPresent(wi.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(wi.MatricesWeightsKind),t=e.length;for(let i=0;i<t;i+=4){const t=e[i]+e[i+1]+e[i+2]+e[i+3];if(0===t)e[i]=1;else{const s=1/t;e[i]*=s,e[i+1]*=s,e[i+2]*=s,e[i+3]*=s}}this.setVerticesData(wi.MatricesWeightsKind,e)}_normalizeSkinWeightsAndExtra(){const e=this.getVerticesData(wi.MatricesWeightsExtraKind),t=this.getVerticesData(wi.MatricesWeightsKind),i=t.length;for(let s=0;s<i;s+=4){let i=t[s]+t[s+1]+t[s+2]+t[s+3];if(i+=e[s]+e[s+1]+e[s+2]+e[s+3],0===i)t[s]=1;else{const r=1/i;t[s]*=r,t[s+1]*=r,t[s+2]*=r,t[s+3]*=r,e[s]*=r,e[s+1]*=r,e[s+2]*=r,e[s+3]*=r}}this.setVerticesData(wi.MatricesWeightsKind,t),this.setVerticesData(wi.MatricesWeightsKind,e)}validateSkinning(){const e=this.getVerticesData(wi.MatricesWeightsExtraKind),t=this.getVerticesData(wi.MatricesWeightsKind);if(null===t||null==this.skeleton)return{skinned:!1,valid:!0,report:"not skinned"};const i=t.length;let s=0,r=0,n=0,a=0;const o=null===e?4:8,h=[];for(let e=0;e<=o;e++)h[e]=0;for(let l=0;l<i;l+=4){let i=t[l],c=i,u=0===c?0:1;for(let r=1;r<o;r++){const n=r<4?t[l+r]:e[l+r-4];n>i&&s++,0!==n&&u++,c+=n,i=n}if(h[u]++,u>n&&(n=u),0===c)r++;else{const i=1/c;let s=0;for(let r=0;r<o;r++)s+=r<4?Math.abs(t[l+r]-t[l+r]*i):Math.abs(e[l+r-4]-e[l+r-4]*i);s>.001&&a++}}const l=this.skeleton.bones.length,c=this.getVerticesData(wi.MatricesIndicesKind),u=this.getVerticesData(wi.MatricesIndicesExtraKind);let d=0;for(let e=0;e<i;e+=4)for(let t=0;t<o;t++){const i=t<4?c[e+t]:u[e+t-4];(i>=l||i<0)&&d++}return{skinned:!0,valid:0===r&&0===a&&0===d,report:"Number of Weights = "+i/4+"\nMaximum influences = "+n+"\nMissing Weights = "+r+"\nNot Sorted = "+s+"\nNot Normalized = "+a+"\nWeightCounts = ["+h+"]\nNumber of bones = "+l+"\nBad Bone Indices = "+d}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===Ve.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=Ve.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return pi.LoadFile(this.delayLoadingFile,(t=>{t instanceof ArrayBuffer?this._delayLoadingFunction(t,this):this._delayLoadingFunction(JSON.parse(t),this),this.instances.forEach((e=>{e.refreshBoundingInfo(),e._syncSubMeshes()})),this.delayLoadState=Ve.DELAYLOADSTATE_LOADED,e.removePendingData(this)}),(()=>{}),e.offlineProvider,t),this}isInFrustum(e){return this.delayLoadState!==Ve.DELAYLOADSTATE_LOADING&&(!!super.isInFrustum(e)&&(this._checkDelayState(),!0))}setMaterialById(e){const t=this.getScene().materials;let i;for(i=t.length-1;i>-1;i--)if(t[i].id===e)return this.material=t[i],this;const s=this.getScene().multiMaterials;for(i=s.length-1;i>-1;i--)if(s[i].id===e)return this.material=s[i],this;return this}getAnimatables(){const e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(wi.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(wi.PositionKind);const s=X.Zero();let r;for(r=0;r<i.length;r+=3)X.TransformCoordinatesFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).toArray(i,r);if(this.setVerticesData(wi.PositionKind,i,this.getVertexBuffer(wi.PositionKind).isUpdatable()),this.isVerticesDataPresent(wi.NormalKind)){for(i=this.getVerticesData(wi.NormalKind),r=0;r<i.length;r+=3)X.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(wi.NormalKind,i,this.getVertexBuffer(wi.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(wi.TangentKind)){for(i=this.getVerticesData(wi.TangentKind),r=0;r<i.length;r+=4)X.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(wi.TangentKind,i,this.getVertexBuffer(wi.TangentKind).isUpdatable())}return e.determinant()<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this}bakeCurrentTransformIntoVertices(e=!0){return this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this}get _positions(){return this._internalAbstractMeshDataInfo._positions||this._geometry&&this._geometry._positions||null}_resetPointsArrayCache(){return this._geometry&&this._geometry._resetPointsArrayCache(),this}_generatePointsArray(){return!!this._geometry&&this._geometry._generatePointsArray()}clone(e="",t=null,i,s=!0){return new Qs(e,this.getScene(),t,this,i,s)}dispose(e,t=!1){this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);const i=this._internalMeshDataInfo;if(i._onBeforeDrawObservable&&i._onBeforeDrawObservable.clear(),i._onBeforeBindObservable&&i._onBeforeBindObservable.clear(),i._onBeforeRenderObservable&&i._onBeforeRenderObservable.clear(),i._onAfterRenderObservable&&i._onAfterRenderObservable.clear(),i._onBetweenPassObservable&&i._onBetweenPassObservable.clear(),this._scene.useClonedMeshMap){if(i.meshMap)for(const e in i.meshMap){const t=i.meshMap[e];t&&(t._internalMeshDataInfo._source=null,i.meshMap[e]=void 0)}i._source&&i._source._internalMeshDataInfo.meshMap&&(i._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else{const e=this.getScene().meshes;for(const t of e){const e=t;e._internalMeshDataInfo&&e._internalMeshDataInfo._source&&e._internalMeshDataInfo._source===this&&(e._internalMeshDataInfo._source=null)}}i._source=null,this._instanceDataStorage.visibleInstances={},this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),this._internalMeshDataInfo._checkReadinessObserver&&this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),super.dispose(e,t)}_disposeInstanceSpecificData(){}_disposeThinInstanceSpecificData(){}_invalidateInstanceVertexArrayObject(){}applyDisplacementMap(e,t,i,s,r,n,a=!1,o){const h=this.getScene();return pi.LoadImage(e,(e=>{const o=e.width,h=e.height,l=this.getEngine().createCanvas(o,h).getContext("2d");l.drawImage(e,0,0);const c=l.getImageData(0,0,o,h).data;this.applyDisplacementMapFromBuffer(c,o,h,t,i,r,n,a),s&&s(this)}),o||(()=>{}),h.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,s,r,n,a,o=!1){if(!this.isVerticesDataPresent(wi.PositionKind)||!this.isVerticesDataPresent(wi.NormalKind)||!this.isVerticesDataPresent(wi.UVKind))return Ae.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const h=this.getVerticesData(wi.PositionKind,!0,!0),l=this.getVerticesData(wi.NormalKind),c=this.getVerticesData(wi.UVKind);let u=X.Zero();const d=X.Zero(),_=Y.Zero();n=n||Y.Zero(),a=a||new Y(1,1);for(let o=0;o<h.length;o+=3){X.FromArrayToRef(h,o,u),X.FromArrayToRef(l,o,d),Y.FromArrayToRef(c,o/3*2,_);const f=4*((Math.abs(_.x*a.x+n.x%1)*(t-1)%t|0)+(Math.abs(_.y*a.y+n.y%1)*(i-1)%i|0)*t),p=.3*(e[f]/255)+.59*(e[f+1]/255)+.11*(e[f+2]/255);d.normalize(),d.scaleInPlace(s+(r-s)*p),u=u.add(d),u.toArray(h,o)}return qi.ComputeNormals(h,this.getIndices(),l),o?(this.setVerticesData(wi.PositionKind,h),this.setVerticesData(wi.NormalKind,l),this.setVerticesData(wi.UVKind,c)):(this.updateVerticesData(wi.PositionKind,h),this.updateVerticesData(wi.NormalKind,l)),this}_getFlattenedNormals(e,t){const i=new Float32Array(3*e.length);let s=0;const r=this.sideOrientation===(this._scene.useRightHandedSystem?Ve.MATERIAL_CounterClockWiseSideOrientation:Ve.MATERIAL_ClockWiseSideOrientation);for(let n=0;n<e.length;n+=3){const a=X.FromArray(t,3*e[n]),o=X.FromArray(t,3*e[n+1]),h=X.FromArray(t,3*e[n+2]),l=a.subtract(o),c=h.subtract(o),u=X.Normalize(X.Cross(l,c));r&&u.scaleInPlace(-1);for(let e=0;e<3;e++)i[s++]=u.x,i[s++]=u.y,i[s++]=u.z}return i}_convertToUnIndexedMesh(e=!1){const t=this.getVerticesDataKinds().filter((e=>!this.getVertexBuffer(e)?.getIsInstanced())),i=this.getIndices(),s={},r=(e,t)=>{const s=new Float32Array(i.length*t);let r=0;for(let n=0;n<i.length;n++)for(let a=0;a<t;a++)s[r++]=e[i[n]*t+a];return s},n=this.getBoundingInfo(),a=this.geometry?this.subMeshes.slice(0):[];for(const e of t)s[e]=this.getVerticesData(e);for(const n of t){const t=this.getVertexBuffer(n),a=t.getSize();if(e&&n===wi.NormalKind){const e=this._getFlattenedNormals(i,s[wi.PositionKind]);this.setVerticesData(wi.NormalKind,e,t.isUpdatable(),a)}else this.setVerticesData(n,r(s[n],a),t.isUpdatable(),a)}if(this.morphTargetManager){for(let t=0;t<this.morphTargetManager.numTargets;t++){const s=this.morphTargetManager.getTarget(t),n=s.getPositions();s.setPositions(r(n,3));const a=s.getNormals();a&&s.setNormals(e?this._getFlattenedNormals(i,n):r(a,3));const o=s.getTangents();o&&s.setTangents(r(o,3));const h=s.getUVs();h&&s.setUVs(r(h,2))}this.morphTargetManager.synchronize()}for(let e=0;e<i.length;e++)i[e]=e;this.setIndices(i),this._unIndexed=!0,this.releaseSubMeshes();for(const e of a){const t=e.getBoundingInfo();Xi.AddToMesh(e.materialIndex,e.indexStart,e.indexCount,e.indexStart,e.indexCount,this).setBoundingInfo(t)}return this.setBoundingInfo(n),this.synchronizeInstances(),this}convertToFlatShadedMesh(){return this._convertToUnIndexedMesh(!0)}convertToUnIndexedMesh(){return this._convertToUnIndexedMesh()}flipFaces(e=!1){const t=qi.ExtractFromMesh(this);let i;if(e&&this.isVerticesDataPresent(wi.NormalKind)&&t.normals){for(i=0;i<t.normals.length;i++)t.normals[i]*=-1;this.setVerticesData(wi.NormalKind,t.normals,this.isVertexBufferUpdatable(wi.NormalKind))}if(t.indices){let e;for(i=0;i<t.indices.length;i+=3)e=t.indices[i+1],t.indices[i+1]=t.indices[i+2],t.indices[i+2]=e;this.setIndices(t.indices,null,this.isVertexBufferUpdatable(wi.PositionKind),!0)}return this}increaseVertices(e=1){const t=qi.ExtractFromMesh(this),i=t.indices&&!Array.isArray(t.indices)&&Array.from?Array.from(t.indices):t.indices,s=t.positions&&!Array.isArray(t.positions)&&Array.from?Array.from(t.positions):t.positions,r=t.uvs&&!Array.isArray(t.uvs)&&Array.from?Array.from(t.uvs):t.uvs,n=t.normals&&!Array.isArray(t.normals)&&Array.from?Array.from(t.normals):t.normals;if(i&&s){t.indices=i,t.positions=s,r&&(t.uvs=r),n&&(t.normals=n);const a=e+1,o=new Array;for(let e=0;e<a+1;e++)o[e]=new Array;let h,l;const c=new X(0,0,0),u=new X(0,0,0),d=new Y(0,0),_=new Array,f=new Array,p=new Array;let g,m,T,A=s.length;r&&(m=r.length),n&&(T=n.length);for(let e=0;e<i.length;e+=3){f[0]=i[e],f[1]=i[e+1],f[2]=i[e+2];for(let e=0;e<3;e++)if(h=f[e],l=f[(e+1)%3],void 0===p[h]&&void 0===p[l]?(p[h]=new Array,p[l]=new Array):(void 0===p[h]&&(p[h]=new Array),void 0===p[l]&&(p[l]=new Array)),void 0===p[h][l]&&void 0===p[l][h]){p[h][l]=[],c.x=(s[3*l]-s[3*h])/a,c.y=(s[3*l+1]-s[3*h+1])/a,c.z=(s[3*l+2]-s[3*h+2])/a,n&&(u.x=(n[3*l]-n[3*h])/a,u.y=(n[3*l+1]-n[3*h+1])/a,u.z=(n[3*l+2]-n[3*h+2])/a),r&&(d.x=(r[2*l]-r[2*h])/a,d.y=(r[2*l+1]-r[2*h+1])/a),p[h][l].push(h);for(let e=1;e<a;e++)p[h][l].push(s.length/3),s[A++]=s[3*h]+e*c.x,s[A++]=s[3*h+1]+e*c.y,s[A++]=s[3*h+2]+e*c.z,n&&(n[T++]=n[3*h]+e*u.x,n[T++]=n[3*h+1]+e*u.y,n[T++]=n[3*h+2]+e*u.z),r&&(r[m++]=r[2*h]+e*d.x,r[m++]=r[2*h+1]+e*d.y);p[h][l].push(l),p[l][h]=new Array,g=p[h][l].length;for(let e=0;e<g;e++)p[l][h][e]=p[h][l][g-1-e]}o[0][0]=i[e],o[1][0]=p[i[e]][i[e+1]][1],o[1][1]=p[i[e]][i[e+2]][1];for(let t=2;t<a;t++){o[t][0]=p[i[e]][i[e+1]][t],o[t][t]=p[i[e]][i[e+2]][t],c.x=(s[3*o[t][t]]-s[3*o[t][0]])/t,c.y=(s[3*o[t][t]+1]-s[3*o[t][0]+1])/t,c.z=(s[3*o[t][t]+2]-s[3*o[t][0]+2])/t,n&&(u.x=(n[3*o[t][t]]-n[3*o[t][0]])/t,u.y=(n[3*o[t][t]+1]-n[3*o[t][0]+1])/t,u.z=(n[3*o[t][t]+2]-n[3*o[t][0]+2])/t),r&&(d.x=(r[2*o[t][t]]-r[2*o[t][0]])/t,d.y=(r[2*o[t][t]+1]-r[2*o[t][0]+1])/t);for(let e=1;e<t;e++)o[t][e]=s.length/3,s[A++]=s[3*o[t][0]]+e*c.x,s[A++]=s[3*o[t][0]+1]+e*c.y,s[A++]=s[3*o[t][0]+2]+e*c.z,n&&(n[T++]=n[3*o[t][0]]+e*u.x,n[T++]=n[3*o[t][0]+1]+e*u.y,n[T++]=n[3*o[t][0]+2]+e*u.z),r&&(r[m++]=r[2*o[t][0]]+e*d.x,r[m++]=r[2*o[t][0]+1]+e*d.y)}o[a]=p[i[e+1]][i[e+2]],_.push(o[0][0],o[1][0],o[1][1]);for(let e=1;e<a;e++){let t;for(t=0;t<e;t++)_.push(o[e][t],o[e+1][t],o[e+1][t+1]),_.push(o[e][t],o[e+1][t+1],o[e][t+1]);_.push(o[e][t],o[e+1][t],o[e+1][t+1])}}t.indices=_,t.applyToMesh(this,this.isVertexBufferUpdatable(wi.PositionKind))}else Ae.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions")}forceSharedVertices(){const e=qi.ExtractFromMesh(this),t=e.uvs,i=e.indices,s=e.positions,r=e.colors,n=e.matricesIndices,a=e.matricesWeights,o=e.matricesIndicesExtra,h=e.matricesWeightsExtra;if(void 0===i||void 0===s||null===i||null===s)Ae.Warn("VertexData contains empty entries");else{const l=new Array,c=new Array,u=new Array,d=new Array,_=new Array,f=new Array,p=new Array,g=new Array;let m=new Array,T=0;const A={};let E,b;for(let e=0;e<i.length;e+=3){b=[i[e],i[e+1],i[e+2]],m=[];for(let e=0;e<3;e++){m[e]="";for(let t=0;t<3;t++)Math.abs(s[3*b[e]+t])<1e-8&&(s[3*b[e]+t]=0),m[e]+=s[3*b[e]+t]+"|"}if(m[0]!=m[1]&&m[0]!=m[2]&&m[1]!=m[2])for(let e=0;e<3;e++){if(E=A[m[e]],void 0===E){A[m[e]]=T,E=T++;for(let t=0;t<3;t++)l.push(s[3*b[e]+t]);if(null!=r)for(let t=0;t<4;t++)d.push(r[4*b[e]+t]);if(null!=t)for(let i=0;i<2;i++)u.push(t[2*b[e]+i]);if(null!=n)for(let t=0;t<4;t++)_.push(n[4*b[e]+t]);if(null!=a)for(let t=0;t<4;t++)f.push(a[4*b[e]+t]);if(null!=o)for(let t=0;t<4;t++)p.push(o[4*b[e]+t]);if(null!=h)for(let t=0;t<4;t++)g.push(h[4*b[e]+t])}c.push(E)}}const R=new Array;qi.ComputeNormals(l,c,R),e.positions=l,e.indices=c,e.normals=R,null!=t&&(e.uvs=u),null!=r&&(e.colors=d),null!=n&&(e.matricesIndices=_),null!=a&&(e.matricesWeights=f),null!=o&&(e.matricesIndicesExtra=p),null!=a&&(e.matricesWeightsExtra=g),e.applyToMesh(this,this.isVertexBufferUpdatable(wi.PositionKind))}}static _instancedMeshFactory(e,t){throw te("InstancedMesh")}static _PhysicsImpostorParser(e,t,i){throw te("PhysicsImpostor")}createInstance(e){const t=Qs._instancedMeshFactory(e,this);return t.parent=this.parent,t}synchronizeInstances(){for(let e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this}optimizeIndices(e){const t=this.getIndices(),i=this.getVerticesData(wi.PositionKind);if(!i||!t)return this;const s=[];for(let e=0;e<i.length;e+=3)s.push(X.FromArray(i,e));const r=[];return gi.SyncAsyncForLoop(s.length,40,(e=>{const t=s.length-1-e,i=s[t];for(let e=0;e<t;++e){const n=s[e];if(i.equals(n)){r[t]=e;break}}}),(()=>{for(let e=0;e<t.length;++e)t[e]=r[t[e]]||t[e];const i=this.subMeshes.slice(0);this.setIndices(t),this.subMeshes=i,e&&e(this)})),this}serialize(e={}){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),se&&se.HasTags(this)&&(e.tags=se.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.alwaysSelectAsActiveMesh=this.alwaysSelectAsActiveMesh,e.checkCollisions=this.checkCollisions,e.ellipsoid=this.ellipsoid.asArray(),e.ellipsoidOffset=this.ellipsoidOffset.asArray(),e.doNotSyncBoundingInfo=this.doNotSyncBoundingInfo,e.isBlocker=this.isBlocker,e.sideOrientation=this.sideOrientation,this.parent&&this.parent._serializeAsParent(e),e.isUnIndexed=this.isUnIndexed;const t=this._geometry;if(t&&this.subMeshes){e.geometryUniqueId=t.uniqueId,e.geometryId=t.id,e.subMeshes=[];for(let t=0;t<this.subMeshes.length;t++){const i=this.subMeshes[t];e.subMeshes.push({materialIndex:i.materialIndex,verticesStart:i.verticesStart,verticesCount:i.verticesCount,indexStart:i.indexStart,indexCount:i.indexCount})}}if(this.material?this.material.doNotSerialize||(e.materialUniqueId=this.material.uniqueId,e.materialId=this.material.id):(this.material=null,e.materialUniqueId=this._scene.defaultMaterial.uniqueId,e.materialId=this._scene.defaultMaterial.id),this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(zs.NAME_PHYSICSENGINE)){const t=this.getPhysicsImpostor();t&&(e.physicsMass=t.getParam("mass"),e.physicsFriction=t.getParam("friction"),e.physicsRestitution=t.getParam("mass"),e.physicsImpostor=t.type)}this.metadata&&(e.metadata=this.metadata),e.instances=[];for(let t=0;t<this.instances.length;t++){const i=this.instances[t];if(i.doNotSerialize)continue;const s={name:i.name,id:i.id,isEnabled:i.isEnabled(!1),isVisible:i.isVisible,isPickable:i.isPickable,checkCollisions:i.checkCollisions,position:i.position.asArray(),scaling:i.scaling.asArray()};if(i.parent&&i.parent._serializeAsParent(s),i.rotationQuaternion?s.rotationQuaternion=i.rotationQuaternion.asArray():i.rotation&&(s.rotation=i.rotation.asArray()),this.getScene()._getComponent(zs.NAME_PHYSICSENGINE)){const e=i.getPhysicsImpostor();e&&(s.physicsMass=e.getParam("mass"),s.physicsFriction=e.getParam("friction"),s.physicsRestitution=e.getParam("mass"),s.physicsImpostor=e.type)}i.metadata&&(s.metadata=i.metadata),i.actionManager&&(s.actions=i.actionManager.serialize(i.name)),e.instances.push(s),de.AppendSerializedAnimations(i,s),s.ranges=i.serializeAnimationRanges()}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(e.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:Array.from(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize,enablePicking:this.thinInstanceEnablePicking},this._userThinInstanceBuffersStorage)){const t={data:{},sizes:{},strides:{}};for(const e in this._userThinInstanceBuffersStorage.data)t.data[e]=Array.from(this._userThinInstanceBuffersStorage.data[e]),t.sizes[e]=this._userThinInstanceBuffersStorage.sizes[e],t.strides[e]=this._userThinInstanceBuffersStorage.strides[e];e.thinInstances.userThinInstance=t}return de.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name)),e}_syncGeometryWithMorphTargetManager(){if(!this.geometry)return;this._markSubMeshesAsAttributesDirty();const e=this._internalAbstractMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices())return Ae.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);if(e.isUsingTextureForTargets)return;for(let t=0;t<e.numInfluencers;t++){const i=e.getActiveTarget(t),s=i.getPositions();if(!s)return void Ae.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(wi.PositionKind+t,s,!1,3);const r=i.getNormals();r&&this.geometry.setVerticesData(wi.NormalKind+t,r,!1,3);const n=i.getTangents();n&&this.geometry.setVerticesData(wi.TangentKind+t,n,!1,3);const a=i.getUVs();a&&this.geometry.setVerticesData(wi.UVKind+"_"+t,a,!1,2)}}else{let e=0;for(;this.geometry.isVerticesDataPresent(wi.PositionKind+e);)this.geometry.removeVerticesData(wi.PositionKind+e),this.geometry.isVerticesDataPresent(wi.NormalKind+e)&&this.geometry.removeVerticesData(wi.NormalKind+e),this.geometry.isVerticesDataPresent(wi.TangentKind+e)&&this.geometry.removeVerticesData(wi.TangentKind+e),this.geometry.isVerticesDataPresent(wi.UVKind+e)&&this.geometry.removeVerticesData(wi.UVKind+"_"+e),e++}}static Parse(e,t,i){let s;if(s=e.type&&"LinesMesh"===e.type?Qs._LinesMeshParser(e,t):e.type&&"GroundMesh"===e.type?Qs._GroundMeshParser(e,t):e.type&&"GoldbergMesh"===e.type?Qs._GoldbergMeshParser(e,t):e.type&&"GreasedLineMesh"===e.type?Qs._GreasedLineMeshParser(e,t):e.type&&"TrailMesh"===e.type?Qs._TrailMeshParser(e,t):new Qs(e.name,t),s.id=e.id,s._waitingParsedUniqueId=e.uniqueId,se&&se.AddTagsTo(s,e.tags),s.position=X.FromArray(e.position),void 0!==e.metadata&&(s.metadata=e.metadata),e.rotationQuaternion?s.rotationQuaternion=q.FromArray(e.rotationQuaternion):e.rotation&&(s.rotation=X.FromArray(e.rotation)),s.scaling=X.FromArray(e.scaling),e.localMatrix?s.setPreTransformMatrix(j.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(j.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s.isVisible=e.isVisible,s.infiniteDistance=e.infiniteDistance,s.alwaysSelectAsActiveMesh=!!e.alwaysSelectAsActiveMesh,s.showBoundingBox=e.showBoundingBox,s.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,void 0!==e.applyFog&&(s.applyFog=e.applyFog),void 0!==e.pickable&&(s.isPickable=e.pickable),void 0!==e.alphaIndex&&(s.alphaIndex=e.alphaIndex),s.receiveShadows=e.receiveShadows,void 0!==e.billboardMode&&(s.billboardMode=e.billboardMode),void 0!==e.visibility&&(s.visibility=e.visibility),s.checkCollisions=e.checkCollisions,s.doNotSyncBoundingInfo=!!e.doNotSyncBoundingInfo,e.ellipsoid&&(s.ellipsoid=X.FromArray(e.ellipsoid)),e.ellipsoidOffset&&(s.ellipsoidOffset=X.FromArray(e.ellipsoidOffset)),null!=e.overrideMaterialSideOrientation&&(s.sideOrientation=e.overrideMaterialSideOrientation),void 0!==e.sideOrientation&&(s.sideOrientation=e.sideOrientation),void 0!==e.isBlocker&&(s.isBlocker=e.isBlocker),s._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(s._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),void 0!==e.parentId&&(s._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),void 0!==e.actions&&(s._waitingData.actions=e.actions),void 0!==e.overlayAlpha&&(s.overlayAlpha=e.overlayAlpha),void 0!==e.overlayColor&&(s.overlayColor=he.FromArray(e.overlayColor)),void 0!==e.renderOverlay&&(s.renderOverlay=e.renderOverlay),s.isUnIndexed=!!e.isUnIndexed,s.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(s.delayLoadState=Ve.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=i+e.delayLoadingFile,s.buildBoundingInfo(X.FromArray(e.boundingBoxMinimum),X.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(s._binaryInfo=e._binaryInfo),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(wi.UVKind),e.hasUVs2&&s._delayInfo.push(wi.UV2Kind),e.hasUVs3&&s._delayInfo.push(wi.UV3Kind),e.hasUVs4&&s._delayInfo.push(wi.UV4Kind),e.hasUVs5&&s._delayInfo.push(wi.UV5Kind),e.hasUVs6&&s._delayInfo.push(wi.UV6Kind),e.hasColors&&s._delayInfo.push(wi.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(wi.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(wi.MatricesWeightsKind),s._delayLoadingFunction=Zi._ImportGeometry,ji.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):Zi._ImportGeometry(e,s),e.materialUniqueId?s._waitingMaterialId=e.materialUniqueId:e.materialId&&(s._waitingMaterialId=e.materialId),e.morphTargetManagerId>-1&&(s._waitingMorphTargetManagerId=e.morphTargetManagerId),void 0!==e.skeletonId&&null!==e.skeletonId&&(s.skeleton=t.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(s.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(let t=0;t<e.animations.length;t++){const i=e.animations[t],r=C("BABYLON.Animation");r&&s.animations.push(r.Parse(i))}fe.ParseAnimationRanges(s,e,t)}if(e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?s.layerMask=Math.abs(parseInt(e.layerMask)):s.layerMask=268435455,e.physicsImpostor&&(s.physicsImpostor=Qs._PhysicsImpostorParser(t,s,e)),e.lodMeshIds&&(s._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(let i=0;i<e.instances.length;i++){const r=e.instances[i],n=s.createInstance(r.name);if(r.id&&(n.id=r.id),se&&(r.tags?se.AddTagsTo(n,r.tags):se.AddTagsTo(n,e.tags)),n.position=X.FromArray(r.position),void 0!==r.metadata&&(n.metadata=r.metadata),void 0!==r.parentId&&(n._waitingParentId=r.parentId),void 0!==r.parentInstanceIndex&&(n._waitingParentInstanceIndex=r.parentInstanceIndex),void 0!==r.isEnabled&&null!==r.isEnabled&&n.setEnabled(r.isEnabled),void 0!==r.isVisible&&null!==r.isVisible&&(n.isVisible=r.isVisible),void 0!==r.isPickable&&null!==r.isPickable&&(n.isPickable=r.isPickable),r.rotationQuaternion?n.rotationQuaternion=q.FromArray(r.rotationQuaternion):r.rotation&&(n.rotation=X.FromArray(r.rotation)),n.scaling=X.FromArray(r.scaling),null!=r.checkCollisions&&null!=r.checkCollisions&&(n.checkCollisions=r.checkCollisions),null!=r.pickable&&null!=r.pickable&&(n.isPickable=r.pickable),null!=r.showBoundingBox&&null!=r.showBoundingBox&&(n.showBoundingBox=r.showBoundingBox),null!=r.showSubMeshesBoundingBox&&null!=r.showSubMeshesBoundingBox&&(n.showSubMeshesBoundingBox=r.showSubMeshesBoundingBox),null!=r.alphaIndex&&null!=r.showSubMeshesBoundingBox&&(n.alphaIndex=r.alphaIndex),r.physicsImpostor&&(n.physicsImpostor=Qs._PhysicsImpostorParser(t,n,r)),void 0!==r.actions&&(n._waitingData.actions=r.actions),r.animations){for(let e=0;e<r.animations.length;e++){const t=r.animations[e],i=C("BABYLON.Animation");i&&n.animations.push(i.Parse(t))}fe.ParseAnimationRanges(n,r,t),r.autoAnimate&&t.beginAnimation(n,r.autoAnimateFrom,r.autoAnimateTo,r.autoAnimateLoop,r.autoAnimateSpeed||1)}}if(e.thinInstances){const t=e.thinInstances;if(s.thinInstanceEnablePicking=!!t.enablePicking,t.matrixData?(s.thinInstanceSetBuffer("matrix",new Float32Array(t.matrixData),16,!1),s._thinInstanceDataStorage.matrixBufferSize=t.matrixBufferSize,s._thinInstanceDataStorage.instancesCount=t.instancesCount):s._thinInstanceDataStorage.matrixBufferSize=t.matrixBufferSize,e.thinInstances.userThinInstance){const t=e.thinInstances.userThinInstance;for(const e in t.data)s.thinInstanceSetBuffer(e,new Float32Array(t.data[e]),t.strides[e],!1),s._userThinInstanceBuffersStorage.sizes[e]=t.sizes[e]}}return s}setPositionsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourcePositions){const t=this.getVerticesData(wi.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(wi.PositionKind)||this.setVerticesData(wi.PositionKind,t,!0)}return e._sourcePositions}setNormalsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourceNormals){const t=this.getVerticesData(wi.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(wi.NormalKind)||this.setVerticesData(wi.NormalKind,t,!0)}return e._sourceNormals}applySkeleton(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(wi.PositionKind))return this;if(!this.isVerticesDataPresent(wi.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(wi.MatricesWeightsKind))return this;const t=this.isVerticesDataPresent(wi.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){const e=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=e}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();let s=this.getVerticesData(wi.PositionKind);if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s));let r=this.getVerticesData(wi.NormalKind);if(t){if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r))}const n=this.getVerticesData(wi.MatricesIndicesKind),a=this.getVerticesData(wi.MatricesWeightsKind);if(!a||!n)return this;const o=this.numBoneInfluencers>4,h=o?this.getVerticesData(wi.MatricesIndicesExtraKind):null,l=o?this.getVerticesData(wi.MatricesWeightsExtraKind):null,c=e.getTransformMatrices(this),u=X.Zero(),d=new j,_=new j;let f,p=0;for(let e=0;e<s.length;e+=3,p+=4){let g;for(f=0;f<4;f++)g=a[p+f],g>0&&(j.FromFloat32ArrayToRefScaled(c,Math.floor(16*n[p+f]),g,_),d.addToSelf(_));if(o)for(f=0;f<4;f++)g=l[p+f],g>0&&(j.FromFloat32ArrayToRefScaled(c,Math.floor(16*h[p+f]),g,_),d.addToSelf(_));X.TransformCoordinatesFromFloatsToRef(i._sourcePositions[e],i._sourcePositions[e+1],i._sourcePositions[e+2],d,u),u.toArray(s,e),t&&(X.TransformNormalFromFloatsToRef(i._sourceNormals[e],i._sourceNormals[e+1],i._sourceNormals[e+2],d,u),u.toArray(r,e)),d.reset()}return this.updateVerticesData(wi.PositionKind,s),t&&this.updateVerticesData(wi.NormalKind,r),this}static MinMax(e){let t=null,i=null;return e.forEach((function(e){const s=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(s.minimumWorld),i.maximizeInPlace(s.maximumWorld)):(t=s.minimumWorld,i=s.maximumWorld)})),t&&i?{min:t,max:i}:{min:X.Zero(),max:X.Zero()}}static Center(e){const t=e instanceof Array?Qs.MinMax(e):e;return X.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,s,r,n){return Ei(Qs._MergeMeshesCoroutine(e,t,i,s,r,n,!1))}static MergeMeshesAsync(e,t=!0,i,s,r,n){return bi(Qs._MergeMeshesCoroutine(e,t,i,s,r,n,!0),Ti())}static*_MergeMeshesCoroutine(e,t=!0,i,s,r,n,a){if(0===(e=e.filter(Boolean)).length)return null;let o;if(!i){let t=0;for(o=0;o<e.length;o++)if(t+=e[o].getTotalVertices(),t>=65536)return Ae.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}n&&(r=!1);const h=new Array,l=new Array,c=new Array,u=e[0].sideOrientation;for(o=0;o<e.length;o++){const t=e[o];if(t.isAnInstance)return Ae.Warn("Cannot merge instance meshes."),null;if(u!==t.sideOrientation)return Ae.Warn("Cannot merge meshes with different sideOrientation values."),null;if(r&&c.push(t.getTotalIndices()),n)if(t.material){const e=t.material;if(e instanceof Vs){for(let t=0;t<e.subMaterials.length;t++)h.indexOf(e.subMaterials[t])<0&&h.push(e.subMaterials[t]);for(let i=0;i<t.subMeshes.length;i++)l.push(h.indexOf(e.subMaterials[t.subMeshes[i].materialIndex])),c.push(t.subMeshes[i].indexCount)}else{h.indexOf(e)<0&&h.push(e);for(let i=0;i<t.subMeshes.length;i++)l.push(h.indexOf(e)),c.push(t.subMeshes[i].indexCount)}}else for(let e=0;e<t.subMeshes.length;e++)l.push(0),c.push(t.subMeshes[e].indexCount)}const d=e[0],_=e=>{const t=e.computeWorldMatrix(!0);return{vertexData:qi.ExtractFromMesh(e,!1,!1),transform:t}},{vertexData:f,transform:p}=_(d);a&&(yield);const g=new Array(e.length-1);for(let t=1;t<e.length;t++)g[t-1]=_(e[t]),a&&(yield);const m=f._mergeCoroutine(p,g,i,a,!t);let T=m.next();for(;!T.done;)a&&(yield),T=m.next();const A=T.value;s||(s=new Qs(d.name+"_merged",d.getScene()));const E=A._applyToCoroutine(s,void 0,a);let b=E.next();for(;!b.done;)a&&(yield),b=E.next();if(s.checkCollisions=d.checkCollisions,s.sideOrientation=d.sideOrientation,t)for(o=0;o<e.length;o++)e[o].dispose();if(r||n){s.releaseSubMeshes(),o=0;let e=0;for(;o<c.length;)Xi.CreateFromIndices(0,e,c[o],s,void 0,!1),e+=c[o],o++;for(const e of s.subMeshes)e.refreshBoundingInfo();s.computeWorldMatrix(!0)}if(n){const e=new Vs(d.name+"_merged",d.getScene());e.subMaterials=h;for(let e=0;e<s.subMeshes.length;e++)s.subMeshes[e].materialIndex=l[e];s.material=e}else s.material=d.material;return s}addInstance(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)}removeInstance(e){const t=e._indexInSourceMeshInstanceArray;if(-1!=t){if(t!==this.instances.length-1){const e=this.instances[this.instances.length-1];this.instances[t]=e,e._indexInSourceMeshInstanceArray=t}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}}_shouldConvertRHS(){return this._scene.useRightHandedSystem&&this.sideOrientation===ks.CounterClockWiseSideOrientation}_getRenderingFillMode(e){const t=this.getScene();return t.forcePointsCloud?ks.PointFillMode:t.forceWireframe?ks.WireFrameFillMode:this.overrideRenderingFillMode??e}setMaterialByID(e){return this.setMaterialById(e)}static CreateRibbon(e,t,i,s,r,n,a,o,h){throw new Error("Import MeshBuilder to populate this function")}static CreateDisc(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateBox(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateSphere(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateHemisphere(e,t,i,s){throw new Error("Import MeshBuilder to populate this function")}static CreateCylinder(e,t,i,s,r,n,a,o,h){throw new Error("Import MeshBuilder to populate this function")}static CreateTorus(e,t,i,s,r,n,a){throw new Error("Import MeshBuilder to populate this function")}static CreateTorusKnot(e,t,i,s,r,n,a,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateLines(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateDashedLines(e,t,i,s,r,n,a,o){throw new Error("Import MeshBuilder to populate this function")}static CreatePolygon(e,t,i,s,r,n,a){throw new Error("Import MeshBuilder to populate this function")}static ExtrudePolygon(e,t,i,s,r,n,a,o){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShape(e,t,i,s,r,n,a,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShapeCustom(e,t,i,s,r,n,a,o,h,l,c,u){throw new Error("Import MeshBuilder to populate this function")}static CreateLathe(e,t,i,s,r,n,a){throw new Error("Import MeshBuilder to populate this function")}static CreatePlane(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateGround(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateTiledGround(e,t,i,s,r,n,a,o,h){throw new Error("Import MeshBuilder to populate this function")}static CreateGroundFromHeightMap(e,t,i,s,r,n,a,o,h,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreateTube(e,t,i,s,r,n,a,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreatePolyhedron(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateIcoSphere(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateDecal(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateCapsule(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static ExtendToGoldberg(e){throw new Error("Import MeshBuilder to populate this function")}}Qs.FRONTSIDE=qi.FRONTSIDE,Qs.BACKSIDE=qi.BACKSIDE,Qs.DOUBLESIDE=qi.DOUBLESIDE,Qs.DEFAULTSIDE=qi.DEFAULTSIDE,Qs.NO_CAP=0,Qs.CAP_START=1,Qs.CAP_END=2,Qs.CAP_ALL=3,Qs.NO_FLIP=0,Qs.FLIP_TILE=1,Qs.ROTATE_TILE=2,Qs.FLIP_ROW=3,Qs.ROTATE_ROW=4,Qs.FLIP_N_ROTATE_TILE=5,Qs.FLIP_N_ROTATE_ROW=6,Qs.CENTER=0,Qs.LEFT=1,Qs.RIGHT=2,Qs.TOP=3,Qs.BOTTOM=4,Qs.INSTANCEDMESH_SORT_TRANSPARENT=!1,Qs._GroundMeshParser=(e,t)=>{throw te("GroundMesh")},Qs._GoldbergMeshParser=(e,t)=>{throw te("GoldbergMesh")},Qs._LinesMeshParser=(e,t)=>{throw te("LinesMesh")},Qs._GreasedLineMeshParser=(e,t)=>{throw te("GreasedLineMesh")},Qs._GreasedLineRibbonMeshParser=(e,t)=>{throw te("GreasedLineRibbonMesh")},Qs._TrailMeshParser=(e,t)=>{throw te("TrailMesh")},S("BABYLON.Mesh",Qs);class qs{}qs.POINTERDOWN=1,qs.POINTERUP=2,qs.POINTERMOVE=4,qs.POINTERWHEEL=8,qs.POINTERPICK=16,qs.POINTERTAP=32,qs.POINTERDOUBLETAP=64;class js{constructor(e,t){this.type=e,this.event=t}}class Zs extends js{constructor(e,t,i,s){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new Y(i,s)}}class Js extends js{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,i,s=null){super(e,t),this._pickInfo=i,this._inputManager=s}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}class $s{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add((e=>{e.type!==qs.POINTERDOWN?e.type===qs.POINTERUP&&(this._isPointerDown=!1):this._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{if(this._reachTargetAlpha())return;const e=Re.Now;let t=0;null!=this._lastFrameTime&&(t=e-this._lastFrameTime),this._lastFrameTime=e,this._applyUserInteraction();const i=e-this._lastInteractionTime-this._idleRotationWaitTime,s=Math.max(Math.min(i/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*s,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(t/1e3))}))}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null,this._lastFrameTime=null}resetLastInteractionTime(e){this._lastInteractionTime=e??Re.Now}_reachTargetAlpha(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)<R}_userIsZooming(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset}_shouldAnimationStopForInteraction(){if(!this._attachedCamera)return!1;let e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()}_applyUserInteraction(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=Re.Now)}_userIsMoving(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)}}var er;!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(er||(er={}));class tr{constructor(){this._easingMode=tr.EASINGMODE_EASEIN}setEasingMode(e){const t=Math.min(Math.max(e,0),2);this._easingMode=t}getEasingMode(){return this._easingMode}easeInCore(e){throw new Error("You must implement this method")}ease(e){switch(this._easingMode){case tr.EASINGMODE_EASEIN:return this.easeInCore(e);case tr.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?.5*(1-this.easeInCore(2*(1-e)))+.5:.5*this.easeInCore(2*e)}}tr.EASINGMODE_EASEIN=0,tr.EASINGMODE_EASEOUT=1,tr.EASINGMODE_EASEINOUT=2;class ir{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new ir(this.name,this.from,this.to)}}class sr{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=0|this.width;return e=397*e^this.height,e}copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new sr(this.width*e,this.height*t)}clone(){return new sr(this.width,this.height)}equals(e){return!!e&&(this.width===e.width&&this.height===e.height)}get surface(){return this.width*this.height}static Zero(){return new sr(0,0)}add(e){return new sr(this.width+e.width,this.height+e.height)}subtract(e){return new sr(this.width-e.width,this.height-e.height)}scale(e){return new sr(this.width*e,this.height*e)}static Lerp(e,t,i){const s=e.width+(t.width-e.width)*i,r=e.height+(t.height-e.height)*i;return new sr(s,r)}}const rr=Object.freeze(new q(0,0,0,0)),nr=Object.freeze(X.Zero()),ar=Object.freeze(Y.Zero()),or=Object.freeze(sr.Zero()),hr=Object.freeze(he.Black()),lr=Object.freeze(new le(0,0,0,0)),cr={key:0,repeatCount:0,loopMode:2};class ur{static _PrepareAnimation(e,t,i,s,r,n,a,o){let h;if(!isNaN(parseFloat(r))&&isFinite(r)?h=ur.ANIMATIONTYPE_FLOAT:r instanceof q?h=ur.ANIMATIONTYPE_QUATERNION:r instanceof X?h=ur.ANIMATIONTYPE_VECTOR3:r instanceof Y?h=ur.ANIMATIONTYPE_VECTOR2:r instanceof he?h=ur.ANIMATIONTYPE_COLOR3:r instanceof le?h=ur.ANIMATIONTYPE_COLOR4:r instanceof sr&&(h=ur.ANIMATIONTYPE_SIZE),null==h)return null;const l=new ur(e,t,i,h,a),c=[{frame:0,value:r},{frame:s,value:n}];return l.setKeys(c),void 0!==o&&l.setEasingFunction(o),l}static CreateAnimation(e,t,i,s){const r=new ur(e+"Animation",e,i,t,ur.ANIMATIONLOOPMODE_CONSTANT);return r.setEasingFunction(s),r}static CreateAndStartAnimation(e,t,i,s,r,n,a,o,h,l,c){const u=ur._PrepareAnimation(e,i,s,r,n,a,o,h);return u?(t.getScene&&(c=t.getScene()),c?c.beginDirectAnimation(t,[u],0,r,1===u.loopMode,1,l):null):null}static CreateAndStartHierarchyAnimation(e,t,i,s,r,n,a,o,h,l,c){const u=ur._PrepareAnimation(e,s,r,n,a,o,h,l);if(!u)return null;return t.getScene().beginDirectHierarchyAnimation(t,i,[u],0,n,1===u.loopMode,1,c)}static CreateMergeAndStartAnimation(e,t,i,s,r,n,a,o,h,l){const c=ur._PrepareAnimation(e,i,s,r,n,a,o,h);return c?(t.animations.push(c),t.getScene().beginAnimation(t,0,r,1===c.loopMode,1,l)):null}static MakeAnimationAdditive(e,t,i,s=!1,r){let n;n="object"==typeof t?t:{referenceFrame:t??0,range:i,cloneOriginalAnimation:s,clonedAnimationName:r};let a=e;if(n.cloneOriginalAnimation&&(a=e.clone(),a.name=n.clonedAnimationName||a.name),!a._keys.length)return a;const o=n.referenceFrame&&n.referenceFrame>=0?n.referenceFrame:0;let h=0;const l=a._keys[0];let c=a._keys.length-1;const u=a._keys[c],d={referenceValue:l.value,referencePosition:J.Vector3[0],referenceQuaternion:J.Quaternion[0],referenceScaling:J.Vector3[1],keyPosition:J.Vector3[2],keyQuaternion:J.Quaternion[1],keyScaling:J.Vector3[3]};let _=l.frame,f=u.frame;if(n.range){const e=a.getRange(n.range);e&&(_=e.from,f=e.to)}else _=n.fromFrame??_,f=n.toFrame??f;if(_!==l.frame&&(h=a.createKeyForFrame(_)),f!==u.frame&&(c=a.createKeyForFrame(f)),1===a._keys.length){const e=a._getKeyValue(a._keys[0]);d.referenceValue=e.clone?e.clone():e}else if(o<=l.frame){const e=a._getKeyValue(l.value);d.referenceValue=e.clone?e.clone():e}else if(o>=u.frame){const e=a._getKeyValue(u.value);d.referenceValue=e.clone?e.clone():e}else{cr.key=0;const e=a._interpolate(o,cr);d.referenceValue=e.clone?e.clone():e}a.dataType===ur.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():a.dataType===ur.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());let p=Number.MAX_VALUE;const g=n.clipKeys?[]:null;for(let e=h;e<=c;e++){let t=a._keys[e];if((g||n.cloneOriginalAnimation)&&(t={frame:t.frame,value:t.value.clone?t.value.clone():t.value,inTangent:t.inTangent,outTangent:t.outTangent,interpolation:t.interpolation,lockedTangent:t.lockedTangent},g&&(p===Number.MAX_VALUE&&(p=t.frame),t.frame-=p,g.push(t))),!e||a.dataType===ur.ANIMATIONTYPE_FLOAT||t.value!==l.value)switch(a.dataType){case ur.ANIMATIONTYPE_MATRIX:t.value.decompose(d.keyScaling,d.keyQuaternion,d.keyPosition),d.keyPosition.subtractInPlace(d.referencePosition),d.keyScaling.divideInPlace(d.referenceScaling),d.referenceQuaternion.multiplyToRef(d.keyQuaternion,d.keyQuaternion),j.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,t.value);break;case ur.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(t.value,t.value);break;case ur.ANIMATIONTYPE_VECTOR2:case ur.ANIMATIONTYPE_VECTOR3:case ur.ANIMATIONTYPE_COLOR3:case ur.ANIMATIONTYPE_COLOR4:t.value.subtractToRef(d.referenceValue,t.value);break;case ur.ANIMATIONTYPE_SIZE:t.value.width-=d.referenceValue.width,t.value.height-=d.referenceValue.height;break;default:t.value-=d.referenceValue}}return g&&a.setKeys(g,!0),a}static TransitionTo(e,t,i,s,r,n,a,o=null){if(a<=0)return i[e]=t,o&&o(),null;const h=r*(a/1e3);n.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:h,value:t}]),i.animations||(i.animations=[]),i.animations.push(n);const l=s.beginAnimation(i,0,h,!1);return l.onAnimationEnd=o,l}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(const e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,i,s,r,n){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=s,this.loopMode=r,this.enableBlending=n,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=s,this.loopMode=void 0===r?ur.ANIMATIONLOOPMODE_CYCLE:r,this.uniqueId=ur._UniqueIdGenerator++}toString(e){let t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";let e=!0;for(const i in this._ranges)e&&(t+=", ",e=!1),t+=i;t+="}"}return t}addEvent(e){this._events.push(e),this._events.sort(((e,t)=>e.frame-t.frame))}removeEvents(e){for(let t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)}getEvents(){return this._events}createRange(e,t,i){this._ranges[e]||(this._ranges[e]=new ir(e,t,i))}deleteRange(e,t=!0){const i=this._ranges[e];if(i){if(t){const e=i.from,t=i.to;for(let i=this._keys.length-1;i>=0;i--)this._keys[i].frame>=e&&this._keys[i].frame<=t&&this._keys.splice(i,1)}this._ranges[e]=null}}getRange(e){return this._ranges[e]}getKeys(){return this._keys}getHighestFrame(){let e=0;for(let t=0,i=this._keys.length;t<i;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e}getEasingFunction(){return this._easingFunction}setEasingFunction(e){this._easingFunction=e}floatInterpolateFunction(e,t,i){return F(e,t,i)}floatInterpolateFunctionWithTangents(e,t,i,s,r){return w(e,t,i,s,r)}quaternionInterpolateFunction(e,t,i){return q.Slerp(e,t,i)}quaternionInterpolateFunctionWithTangents(e,t,i,s,r){return q.Hermite(e,t,i,s,r).normalize()}vector3InterpolateFunction(e,t,i){return X.Lerp(e,t,i)}vector3InterpolateFunctionWithTangents(e,t,i,s,r){return X.Hermite(e,t,i,s,r)}vector2InterpolateFunction(e,t,i){return Y.Lerp(e,t,i)}vector2InterpolateFunctionWithTangents(e,t,i,s,r){return Y.Hermite(e,t,i,s,r)}sizeInterpolateFunction(e,t,i){return sr.Lerp(e,t,i)}color3InterpolateFunction(e,t,i){return he.Lerp(e,t,i)}color3InterpolateFunctionWithTangents(e,t,i,s,r){return he.Hermite(e,t,i,s,r)}color4InterpolateFunction(e,t,i){return le.Lerp(e,t,i)}color4InterpolateFunctionWithTangents(e,t,i,s,r){return le.Hermite(e,t,i,s,r)}_getKeyValue(e){return"function"==typeof e?e():e}evaluate(e){return cr.key=0,this._interpolate(e,cr)}_interpolate(e,t,i=!1){if(t.loopMode===ur.ANIMATIONLOOPMODE_CONSTANT&&t.repeatCount>0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const s=this._keys,r=s.length;let n=t.key;for(;n>=0&&e<s[n].frame;)--n;for(;n+1<=r-1&&e>=s[n+1].frame;)++n;if(t.key=n,n<0)return i?void 0:this._getKeyValue(s[0].value);if(n+1>r-1)return i?void 0:this._getKeyValue(s[r-1].value);const a=s[n],o=s[n+1];if(i&&(e===a.frame||e===o.frame))return;const h=this._getKeyValue(a.value),l=this._getKeyValue(o.value);if(1===a.interpolation)return o.frame>e?h:l;const c=void 0!==a.outTangent&&void 0!==o.inTangent,u=o.frame-a.frame;let d=(e-a.frame)/u;const _=a.easingFunction||this.getEasingFunction();switch(null!==_&&(d=_.ease(d)),this.dataType){case ur.ANIMATIONTYPE_FLOAT:{const e=c?this.floatInterpolateFunctionWithTangents(h,a.outTangent*u,l,o.inTangent*u,d):this.floatInterpolateFunction(h,l,d);switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return e;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(t.offsetValue??0)*t.repeatCount+e}break}case ur.ANIMATIONTYPE_QUATERNION:{const e=c?this.quaternionInterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),d):this.quaternionInterpolateFunction(h,l,d);switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return e;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.addInPlace((t.offsetValue||rr).scale(t.repeatCount))}return e}case ur.ANIMATIONTYPE_VECTOR3:{const e=c?this.vector3InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),d):this.vector3InterpolateFunction(h,l,d);switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return e;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||nr).scale(t.repeatCount))}break}case ur.ANIMATIONTYPE_VECTOR2:{const e=c?this.vector2InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),d):this.vector2InterpolateFunction(h,l,d);switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return e;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||ar).scale(t.repeatCount))}break}case ur.ANIMATIONTYPE_SIZE:switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(h,l,d);case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(h,l,d).add((t.offsetValue||or).scale(t.repeatCount))}break;case ur.ANIMATIONTYPE_COLOR3:{const e=c?this.color3InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),d):this.color3InterpolateFunction(h,l,d);switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return e;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||hr).scale(t.repeatCount))}break}case ur.ANIMATIONTYPE_COLOR4:{const e=c?this.color4InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),d):this.color4InterpolateFunction(h,l,d);switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return e;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||lr).scale(t.repeatCount))}break}case ur.ANIMATIONTYPE_MATRIX:switch(t.loopMode){case ur.ANIMATIONLOOPMODE_CYCLE:case ur.ANIMATIONLOOPMODE_CONSTANT:case ur.ANIMATIONLOOPMODE_YOYO:return ur.AllowMatricesInterpolation?this.matrixInterpolateFunction(h,l,d,t.workValue):h;case ur.ANIMATIONLOOPMODE_RELATIVE:case ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return h}}return 0}matrixInterpolateFunction(e,t,i,s){return ur.AllowMatrixDecomposeForInterpolation?s?(j.DecomposeLerpToRef(e,t,i,s),s):j.DecomposeLerp(e,t,i):s?(j.LerpToRef(e,t,i,s),s):j.Lerp(e,t,i)}clone(){const e=new ur(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(const t in this._ranges){const i=this._ranges[t];i&&(e._ranges[t]=i.clone())}}return e}setKeys(e,t=!1){this._keys=t?e:e.slice(0)}createKeyForFrame(e){cr.key=0;const t=this._interpolate(e,cr,!0);if(!t)return this._keys[cr.key].frame===e?cr.key:cr.key+1;const i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(cr.key+1,0,i),cr.key+1}serialize(){const e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;const t=this.dataType;e.keys=[];const i=this.getKeys();for(let s=0;s<i.length;s++){const r=i[s],n={};switch(n.frame=r.frame,t){case ur.ANIMATIONTYPE_FLOAT:n.values=[r.value],void 0!==r.inTangent&&n.values.push(r.inTangent),void 0!==r.outTangent&&(void 0===r.inTangent&&n.values.push(void 0),n.values.push(r.outTangent)),void 0!==r.interpolation&&(void 0===r.inTangent&&n.values.push(void 0),void 0===r.outTangent&&n.values.push(void 0),n.values.push(r.interpolation));break;case ur.ANIMATIONTYPE_QUATERNION:case ur.ANIMATIONTYPE_MATRIX:case ur.ANIMATIONTYPE_VECTOR3:case ur.ANIMATIONTYPE_COLOR3:case ur.ANIMATIONTYPE_COLOR4:n.values=r.value.asArray(),null!=r.inTangent&&n.values.push(r.inTangent.asArray()),null!=r.outTangent&&(void 0===r.inTangent&&n.values.push(void 0),n.values.push(r.outTangent.asArray())),void 0!==r.interpolation&&(void 0===r.inTangent&&n.values.push(void 0),void 0===r.outTangent&&n.values.push(void 0),n.values.push(r.interpolation))}e.keys.push(n)}e.ranges=[];for(const t in this._ranges){const i=this._ranges[t];if(!i)continue;const s={};s.name=t,s.from=i.from,s.to=i.to,e.ranges.push(s)}return e}static _UniversalLerp(e,t,i){const s=e.constructor;return s.Lerp?s.Lerp(e,t,i):s.Slerp?s.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t}static Parse(e){const t=new ur(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior),i=e.dataType,s=[];let r,n;for(e.enableBlending&&(t.enableBlending=e.enableBlending),e.blendingSpeed&&(t.blendingSpeed=e.blendingSpeed),n=0;n<e.keys.length;n++){const t=e.keys[n];let a,o,h;switch(i){case ur.ANIMATIONTYPE_FLOAT:r=t.values[0],t.values.length>=2&&(a=t.values[1]),t.values.length>=3&&(o=t.values[2]),t.values.length>=4&&(h=t.values[3]);break;case ur.ANIMATIONTYPE_QUATERNION:if(r=q.FromArray(t.values),t.values.length>=8){const e=q.FromArray(t.values.slice(4,8));e.equals(q.Zero())||(a=e)}if(t.values.length>=12){const e=q.FromArray(t.values.slice(8,12));e.equals(q.Zero())||(o=e)}t.values.length>=13&&(h=t.values[12]);break;case ur.ANIMATIONTYPE_MATRIX:r=j.FromArray(t.values),t.values.length>=17&&(h=t.values[16]);break;case ur.ANIMATIONTYPE_COLOR3:r=he.FromArray(t.values),t.values[3]&&(a=he.FromArray(t.values[3])),t.values[4]&&(o=he.FromArray(t.values[4])),t.values[5]&&(h=t.values[5]);break;case ur.ANIMATIONTYPE_COLOR4:r=le.FromArray(t.values),t.values[4]&&(a=le.FromArray(t.values[4])),t.values[5]&&(o=le.FromArray(t.values[5])),t.values[6]&&(h=le.FromArray(t.values[6]));break;case ur.ANIMATIONTYPE_VECTOR3:default:r=X.FromArray(t.values),t.values[3]&&(a=X.FromArray(t.values[3])),t.values[4]&&(o=X.FromArray(t.values[4])),t.values[5]&&(h=t.values[5])}const l={};l.frame=t.frame,l.value=r,null!=a&&(l.inTangent=a),null!=o&&(l.outTangent=o),null!=h&&(l.interpolation=h),s.push(l)}if(t.setKeys(s),e.ranges)for(n=0;n<e.ranges.length;n++)r=e.ranges[n],t.createRange(r.name,r.from,r.to);return t}static AppendSerializedAnimations(e,t){de.AppendSerializedAnimations(e,t)}static ParseFromFileAsync(e,t){return new Promise(((i,s)=>{const r=new ye;r.addEventListener("readystatechange",(()=>{if(4==r.readyState)if(200==r.status){let t=JSON.parse(r.responseText);if(t.animations&&(t=t.animations),t.length){const e=[];for(const i of t)e.push(this.Parse(i));i(e)}else{const s=this.Parse(t);e&&(s.name=e),i(s)}}else s("Unable to load the animation")})),r.open("GET",t),r.send()}))}static ParseFromSnippetAsync(e){return new Promise(((t,i)=>{const s=new ye;s.addEventListener("readystatechange",(()=>{if(4==s.readyState)if(200==s.status){const i=JSON.parse(JSON.parse(s.responseText).jsonPayload);if(i.animations){const s=JSON.parse(i.animations),r=[];for(const t of s.animations){const i=this.Parse(t);i.snippetId=e,r.push(i)}t(r)}else{const s=JSON.parse(i.animation),r=this.Parse(s);r.snippetId=e,t(r)}}else i("Unable to load the snippet "+e)})),s.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),s.send()}))}}ur._UniqueIdGenerator=0,ur.AllowMatricesInterpolation=!1,ur.AllowMatrixDecomposeForInterpolation=!0,ur.SnippetUrl=Ve.SnippetUrl,ur.ANIMATIONTYPE_FLOAT=0,ur.ANIMATIONTYPE_VECTOR3=1,ur.ANIMATIONTYPE_QUATERNION=2,ur.ANIMATIONTYPE_MATRIX=3,ur.ANIMATIONTYPE_COLOR3=4,ur.ANIMATIONTYPE_COLOR4=7,ur.ANIMATIONTYPE_VECTOR2=5,ur.ANIMATIONTYPE_SIZE=6,ur.ANIMATIONLOOPMODE_RELATIVE=0,ur.ANIMATIONLOOPMODE_CYCLE=1,ur.ANIMATIONLOOPMODE_CONSTANT=2,ur.ANIMATIONLOOPMODE_YOYO=4,ur.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5,ur.CreateFromSnippetAsync=ur.ParseFromSnippetAsync,S("BABYLON.Animation",ur),fe._AnimationRangeFactory=(e,t,i)=>new ir(e,t,i);class dr{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;const t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((e=>{if(e&&(e.computeWorldMatrix(!0),e.getBoundingInfo)){const t=e.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=.05*t,this.upperRadiusTransitionRange=.05*t}})):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))}))}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||(dr.EasingFunction.setEasingMode(dr.EasingMode),this._radiusBounceTransition=ur.CreateAnimation("radius",ur.ANIMATIONTYPE_FLOAT,60,dr.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=ur.TransitionTo("radius",this._attachedCamera.radius+e,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(()=>this._clearAnimationLocks()));t&&this._animatables.push(t)}_clearAnimationLocks(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()}}dr.EasingFunction=new class extends tr{constructor(e=1){super(),this.amplitude=e}easeInCore(e){const t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}}(.3),dr.EasingMode=tr.EASINGMODE_EASEOUT;class _r{constructor(){this.onTargetFramingAnimationEndObservable=new A,this._mode=_r.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();_r.EasingFunction.setEasingMode(_r.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add((e=>{e.type!==qs.POINTERDOWN?e.type===qs.POINTERUP&&(this._isPointerDown=!1):this._isPointerDown=!0})),this._onMeshTargetChangedObserver=e.onMeshTargetChangedObservable.add((e=>{e&&e.getBoundingInfo&&this.zoomOnMesh(e,void 0,(()=>{this.onTargetFramingAnimationEndObservable.notifyObservers()}))})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{this._applyUserInteraction(),this._maintainCameraAboveGround()}))}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}zoomOnMesh(e,t=!1,i=null){e.computeWorldMatrix(!0);const s=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(s.minimumWorld,s.maximumWorld,t,i)}zoomOnMeshHierarchy(e,t=!1,i=null){e.computeWorldMatrix(!0);const s=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(s.min,s.max,t,i)}zoomOnMeshesHierarchy(e,t=!1,i=null){const s=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new X(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let t=0;t<e.length;t++){const i=e[t].getHierarchyBoundingVectors(!0);X.CheckExtends(i.min,s,r),X.CheckExtends(i.max,s,r)}this.zoomOnBoundingInfo(s,r,t,i)}zoomOnBoundingInfo(e,t,i=!1,s=null){let r;if(!this._attachedCamera)return!1;const n=e.y,a=n+(t.y-n)*this._positionScale,o=t.subtract(e).scale(.5);if(i)r=new X(0,a,0);else{const t=e.add(o);r=new X(t.x,a,t.z)}this._vectorTransition||(this._vectorTransition=ur.CreateAnimation("target",ur.ANIMATIONTYPE_VECTOR3,60,_r.EasingFunction)),this._betaIsAnimating=!0;let h=ur.TransitionTo("target",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);h&&this._animatables.push(h);let l=0;if(this._mode===_r.FitFrustumSidesMode){const i=this._calculateLowerRadiusFromModelBoundingSphere(e,t);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=o.length()+this._attachedCamera.minZ),l=i}else this._mode===_r.IgnoreBoundsSizeMode&&(l=this._calculateLowerRadiusFromModelBoundingSphere(e,t),this.autoCorrectCameraLimitsAndSensibility&&null===this._attachedCamera.lowerRadiusLimit&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){const i=t.subtract(e).length();this._attachedCamera.panningSensibility=5e3/i,this._attachedCamera.wheelPrecision=100/l}return this._radiusTransition||(this._radiusTransition=ur.CreateAnimation("radius",ur.ANIMATIONTYPE_FLOAT,60,_r.EasingFunction)),h=ur.TransitionTo("radius",l,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,(()=>{this.stopAllAnimations(),s&&s(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()})),h&&this._animatables.push(h),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){const i=this._attachedCamera;if(!i)return 0;let s=i._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return i.lowerRadiusLimit&&this._mode===_r.IgnoreBoundsSizeMode&&(s=s<i.lowerRadiusLimit?i.lowerRadiusLimit:s),i.upperRadiusLimit&&(s=s>i.upperRadiusLimit?i.upperRadiusLimit:s),s}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;const e=Re.Now-this._lastInteractionTime,t=.5*Math.PI-this._defaultElevation,i=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>i&&e>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=ur.CreateAnimation("beta",ur.ANIMATIONTYPE_FLOAT,60,_r.EasingFunction));const e=ur.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(()=>{this._clearAnimationLocks(),this.stopAllAnimations()}));e&&this._animatables.push(e)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=Re.Now,this.stopAllAnimations(),this._clearAnimationLocks())}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()}get isUserIsMoving(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)}}_r.EasingFunction=new class extends tr{constructor(e=2){super(),this.exponent=e}easeInCore(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)}},_r.EasingMode=tr.EASINGMODE_EASEINOUT,_r.IgnoreBoundsSizeMode=0,_r.FitFrustumSidesMode=1,fe.AddNodeConstructor("TargetCamera",((e,t)=>()=>new fr(e,X.Zero(),t)));class fr extends xi{constructor(e,t,i,s=!0){super(e,t,i,s),this._tmpUpVector=X.Zero(),this._tmpTargetVector=X.Zero(),this.cameraDirection=new X(0,0,0),this.cameraRotation=new Y(0,0),this.ignoreParentScaling=!1,this.updateUpVectorFromRotation=!1,this._tmpQuaternion=new q,this.rotation=new X(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this.lockedTarget=null,this._currentTarget=X.Zero(),this._initialFocalDistance=1,this._viewMatrix=j.Zero(),this._camMatrix=j.Zero(),this._cameraTransformMatrix=j.Zero(),this._cameraRotationMatrix=j.Zero(),this._referencePoint=new X(0,0,1),this._transformedReferencePoint=X.Zero(),this._deferredPositionUpdate=new X,this._deferredRotationQuaternionUpdate=new q,this._deferredRotationUpdate=new X,this._deferredUpdated=!1,this._deferOnly=!1,this._defaultUp=X.Up(),this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0}getFrontPosition(e){this.getWorldMatrix();const t=J.Vector3[0],i=J.Vector3[1];return i.set(0,0,this._scene.useRightHandedSystem?-1:1),this.getDirectionToRef(i,t),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){const e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return!!super._restoreStateValues()&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)}_initCache(){super._initCache(),this._cache.lockedTarget=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new q(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();const t=this._getLockedTargetPosition();t?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(t):this._cache.lockedTarget=t.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)}_isSynchronizedViewMatrix(){if(!super._isSynchronizedViewMatrix())return!1;const e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))}_computeLocalCameraSpeed(){const e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))}setTarget(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=R),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),j.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);const t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(J.Matrix[0]),X.TransformNormalToRef(this.cameraDirection,J.Matrix[0],J.Vector3[0]),this._deferredPositionUpdate.addInPlace(J.Vector3[0]),void(this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate));this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)}_checkInputs(){const e=this.invertRotation?-this.inverseRotationSpeed:1,t=this._decideIfNeedsToMove(),i=this.cameraRotation.x||this.cameraRotation.y;if(this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),t&&this._updatePosition(),i){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*e,this._deferredRotationUpdate.y+=this.cameraRotation.y*e,!this.noRotationConstraint){const e=1.570796;this._deferredRotationUpdate.x>e&&(this._deferredRotationUpdate.x=e),this._deferredRotationUpdate.x<-e&&(this._deferredRotationUpdate.x=-e)}if(this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion){this._deferredRotationUpdate.lengthSquared()&&(q.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate))}}t&&(Math.abs(this.cameraDirection.x)<this.speed*R&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*R&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*R&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*R&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*R&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),super._checkInputs()}_updateCameraRotationMatrix(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):j.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)}_rotateUpVectorWithCameraRotationMatrix(){return X.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this}_getViewMatrix(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!==this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),X.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?as.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(q.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),as.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix}_computeViewMatrix(e,t,i){if(this.ignoreParentScaling){if(this.parent){const s=this.parent.getWorldMatrix();X.TransformCoordinatesToRef(e,s,this._globalPosition),X.TransformCoordinatesToRef(t,s,this._tmpTargetVector),X.TransformNormalToRef(i,s,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(t),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?j.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):j.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix)}else if(this.getScene().useRightHandedSystem?j.LookAtRHToRef(e,t,i,this._viewMatrix):j.LookAtLHToRef(e,t,i,this._viewMatrix),this.parent){const e=this.parent.getWorldMatrix();this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(e,this._viewMatrix),this._viewMatrix.getTranslationToRef(this._globalPosition),this._viewMatrix.invert(),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e)}createRigCamera(e,t){if(this.cameraRigMode!==xi.RIG_MODE_NONE){const t=new fr(e,this.position.clone(),this.getScene());return t.isRigCamera=!0,t.rigParent=this,this.cameraRigMode===xi.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new q),t._cameraRigParams={},t.rotationQuaternion=new q),t.mode=this.mode,t.orthoLeft=this.orthoLeft,t.orthoRight=this.orthoRight,t.orthoTop=this.orthoTop,t.orthoBottom=this.orthoBottom,t}return null}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case xi.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case xi.RIG_MODE_STEREOSCOPIC_OVERUNDER:case xi.RIG_MODE_STEREOSCOPIC_INTERLACED:{const i=this.cameraRigMode===xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,s=this.cameraRigMode===xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,e),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*s,t);break}case xi.RIG_MODE_VR:e.rotationQuaternion?(e.rotationQuaternion.copyFrom(this.rotationQuaternion),t.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.rotation.copyFrom(this.rotation),t.rotation.copyFrom(this.rotation)),e.position.copyFrom(this.position),t.position.copyFrom(this.position)}super._updateRigCameras()}_getRigCamPositionAndTarget(e,t){this.getTarget().subtractToRef(this.position,fr._TargetFocalPoint),fr._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);const i=fr._TargetFocalPoint.addInPlace(this.position);j.TranslationToRef(-i.x,-i.y,-i.z,fr._TargetTransformMatrix),fr._TargetTransformMatrix.multiplyToRef(j.RotationAxis(t.upVector,e),fr._RigCamTransformMatrix),j.TranslationToRef(i.x,i.y,i.z,fr._TargetTransformMatrix),fr._RigCamTransformMatrix.multiplyToRef(fr._TargetTransformMatrix,fr._RigCamTransformMatrix),X.TransformCoordinatesToRef(this.position,fr._RigCamTransformMatrix,t.position),t.setTarget(i)}getClassName(){return"TargetCamera"}}fr._RigCamTransformMatrix=new j,fr._TargetTransformMatrix=new j,fr._TargetFocalPoint=new X,e([a()],fr.prototype,"ignoreParentScaling",void 0),e([a()],fr.prototype,"updateUpVectorFromRotation",void 0),e([u()],fr.prototype,"rotation",void 0),e([a()],fr.prototype,"speed",void 0),e([d("lockedTargetId")],fr.prototype,"lockedTarget",void 0);var pr,gr={};class mr{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){const t=e.getSimpleName();this.attached[t]?Ae.Warn("camera input of type "+t+" already exists on camera"):(this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault))}remove(e){for(const t in this.attached){const i=this.attached[t];if(i===e)return i.detachControl(),i.camera=null,delete this.attached[t],void this.rebuildInputCheck()}}removeByType(e){for(const t in this.attached){const i=this.attached[t];i.getClassName()===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){const t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=!xi.ForceAttachControlToAlwaysPreventDefault&&e,this.attachedToElement=!0,this.noPreventDefault=e;for(const t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(const t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(const e in this.attached){const t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}}clear(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=()=>{}}serialize(e){const t={};for(const e in this.attached){const i=this.attached[e],s=de.Serialize(i);t[i.getClassName()]=s}e.inputsmgr=t}parse(e){const t=e.inputsmgr;if(t){this.clear();for(const e in t){const i=gr[e];if(i){const s=t[e],r=de.Parse((()=>new i),s,null);this.add(r)}}}else for(const t in this.attached){const i=gr[this.attached[t].getClassName()];if(i){const s=de.Parse((()=>new i),e,null);this.remove(this.attached[t]),this.add(s)}}}}class Tr{constructor(){this._currentActiveButton=-1,this.buttons=[0,1,2]}attachControl(e){e=pi.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),i=t.getInputElement();let s=0,r=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=n=>{const a=n.event,o="touch"===a.pointerType;if(n.type!==qs.POINTERMOVE&&-1===this.buttons.indexOf(a.button))return;const h=a.target;if(this._altKey=a.altKey,this._ctrlKey=a.ctrlKey,this._metaKey=a.metaKey,this._shiftKey=a.shiftKey,this._buttonsPressed=a.buttons,t.isPointerLock){const e=a.movementX,t=a.movementY;this.onTouch(null,e,t),this._pointA=null,this._pointB=null}else{if(n.type!==qs.POINTERDOWN&&n.type!==qs.POINTERDOUBLETAP&&o&&this._pointA?.pointerId!==a.pointerId&&this._pointB?.pointerId!==a.pointerId)return;if(n.type!==qs.POINTERDOWN||-1!==this._currentActiveButton&&!o)if(n.type===qs.POINTERDOUBLETAP)this.onDoubleTap(a.pointerType);else if(n.type!==qs.POINTERUP||this._currentActiveButton!==a.button&&!o){if(n.type===qs.POINTERMOVE)if(e||a.preventDefault(),this._pointA&&null===this._pointB){const e=a.clientX-this._pointA.x,t=a.clientY-this._pointA.y;this._pointA.x=a.clientX,this._pointA.y=a.clientY,this.onTouch(this._pointA,e,t)}else if(this._pointA&&this._pointB){const e=this._pointA.pointerId===a.pointerId?this._pointA:this._pointB;e.x=a.clientX,e.y=a.clientY;const t=this._pointA.x-this._pointB.x,i=this._pointA.y-this._pointB.y,o=t*t+i*i,h={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:a.pointerId,type:n.type};this.onMultiTouch(this._pointA,this._pointB,s,o,r,h),r=h,s=o}}else{try{h?.releasePointerCapture(a.pointerId)}catch(e){}o||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==a.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==a.pointerId?this._pointB=null:this._pointA=this._pointB=null,(0!==s||r)&&(this.onMultiTouch(this._pointA,this._pointB,s,0,r,null),s=0,r=null),this._currentActiveButton=-1,this.onButtonUp(a),e||a.preventDefault()}else{try{h?.setPointerCapture(a.pointerId)}catch(e){}if(null===this._pointA)this._pointA={x:a.clientX,y:a.clientY,pointerId:a.pointerId,type:a.pointerType};else{if(null!==this._pointB)return;this._pointB={x:a.clientX,y:a.clientY,pointerId:a.pointerId,type:a.pointerType}}-1!==this._currentActiveButton||o||(this._currentActiveButton=a.button),this.onButtonDown(a),e||(a.preventDefault(),i&&i.focus())}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,qs.POINTERDOWN|qs.POINTERUP|qs.POINTERMOVE|qs.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,s=0,r=null,this.onLostFocus()},this._contextMenuBind=e=>this.onContextMenu(e),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);const n=this.camera.getScene().getEngine().getHostWindow();n&&pi.RegisterTopRootEvents(n,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&pi.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){const e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentActiveButton=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,i){}onMultiTouch(e,t,i,s,r,n){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}}e([a()],Tr.prototype,"buttons",void 0);class Ar extends Tr{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.pinchZoom=!0,this.panningSensibility=1e3,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this.pinchInwards=!0,this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(0!==this.panningSensibility&&e&&t){const i=t.x-e.x,s=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=s/this.panningSensibility}}_computePinchZoom(e,t){const i=this.camera.radius||Ar.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=i*Math.sqrt(e)/Math.sqrt(t):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(t-e)*i*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(t-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)}onTouch(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)}onDoubleTap(){this.camera.useInputToRestoreState&&this.camera.restoreState()}onMultiTouch(e,t,i,s,r,n){0===i&&null===r||0===s&&null===n||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,s),this._computeMultiTouchPanning(r,n)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(s)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance?(this._computePinchZoom(i,s),this._isPinching=!0):this._computeMultiTouchPanning(r,n)):this.multiTouchPanning?this._computeMultiTouchPanning(r,n):this.pinchZoom&&this._computePinchZoom(i,s))}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}}Ar.MinimumRadiusForPinch=.001,e([a()],Ar.prototype,"buttons",void 0),e([a()],Ar.prototype,"angularSensibilityX",void 0),e([a()],Ar.prototype,"angularSensibilityY",void 0),e([a()],Ar.prototype,"pinchPrecision",void 0),e([a()],Ar.prototype,"pinchDeltaPercentage",void 0),e([a()],Ar.prototype,"useNaturalPinchZoom",void 0),e([a()],Ar.prototype,"pinchZoom",void 0),e([a()],Ar.prototype,"panningSensibility",void 0),e([a()],Ar.prototype,"multiTouchPanning",void 0),e([a()],Ar.prototype,"multiTouchPanAndZoom",void 0),gr.ArcRotateCameraPointersInput=Ar;class Er{}Er.KEYDOWN=1,Er.KEYUP=2;class br{constructor(e,t){this.type=e,this.event=t}}class Rr extends br{get skipOnPointerObservable(){return this.skipOnKeyboardObservable}set skipOnPointerObservable(e){this.skipOnKeyboardObservable=e}constructor(e,t){super(e,t),this.type=e,this.event=t,this.skipOnKeyboardObservable=!1}}class yr{constructor(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}attachControl(e){e=pi.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((()=>{this._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((t=>{const i=t.event;if(!i.metaKey)if(t.type===Er.KEYDOWN){if(this._ctrlPressed=i.ctrlKey,this._altPressed=i.altKey,-1!==this.keysUp.indexOf(i.keyCode)||-1!==this.keysDown.indexOf(i.keyCode)||-1!==this.keysLeft.indexOf(i.keyCode)||-1!==this.keysRight.indexOf(i.keyCode)||-1!==this.keysReset.indexOf(i.keyCode)){-1===this._keys.indexOf(i.keyCode)&&this._keys.push(i.keyCode),i.preventDefault&&(e||i.preventDefault())}}else if(-1!==this.keysUp.indexOf(i.keyCode)||-1!==this.keysDown.indexOf(i.keyCode)||-1!==this.keysLeft.indexOf(i.keyCode)||-1!==this.keysRight.indexOf(i.keyCode)||-1!==this.keysReset.indexOf(i.keyCode)){const t=this._keys.indexOf(i.keyCode);t>=0&&this._keys.splice(t,1),i.preventDefault&&(e||i.preventDefault())}})))}detachControl(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0}checkInputs(){if(this._onKeyboardObserver){const e=this.camera;for(let t=0;t<this._keys.length;t++){const i=this._keys[t];-1!==this.keysLeft.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX-=1/this.panningSensibility:e.inertialAlphaOffset-=this.angularSpeed:-1!==this.keysUp.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:-1!==this.keysRight.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:-1!==this.keysDown.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:-1!==this.keysReset.indexOf(i)&&e.useInputToRestoreState&&e.restoreState()}}}getClassName(){return"ArcRotateCameraKeyboardMoveInput"}getSimpleName(){return"keyboard"}}e([a()],yr.prototype,"keysUp",void 0),e([a()],yr.prototype,"keysDown",void 0),e([a()],yr.prototype,"keysLeft",void 0),e([a()],yr.prototype,"keysRight",void 0),e([a()],yr.prototype,"keysReset",void 0),e([a()],yr.prototype,"panningSensibility",void 0),e([a()],yr.prototype,"zoomingSensibility",void 0),e([a()],yr.prototype,"useAltToZoom",void 0),e([a()],yr.prototype,"angularSpeed",void 0),gr.ArcRotateCameraKeyboardMoveInput=yr,function(e){e[e.PointerMove=0]="PointerMove",e[e.PointerDown=1]="PointerDown",e[e.PointerUp=2]="PointerUp"}(pr||(pr={}));class Ir{}Ir.DOM_DELTA_PIXEL=0,Ir.DOM_DELTA_LINE=1,Ir.DOM_DELTA_PAGE=2;class Mr{constructor(){this.wheelPrecision=3,this.zoomToMouseLocation=!1,this.wheelDeltaPercentage=0,this.customComputeDeltaFromMouseWheel=null,this._viewOffset=new X(0,0,0),this._globalOffset=new X(0,0,0),this._inertialPanning=X.Zero()}_computeDeltaFromMouseWheelLegacyEvent(e,t){let i=0;const s=.01*e*this.wheelDeltaPercentage*t;return i=e>0?s/(1+this.wheelDeltaPercentage):s*(1+this.wheelDeltaPercentage),i}attachControl(e){e=pi.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==qs.POINTERWHEEL)return;const i=t.event;let s=0;const r=i.deltaMode===Ir.DOM_DELTA_LINE?40:1,n=-i.deltaY*r;if(this.customComputeDeltaFromMouseWheel)s=this.customComputeDeltaFromMouseWheel(n,this,i);else if(this.wheelDeltaPercentage){if(s=this._computeDeltaFromMouseWheelLegacyEvent(n,this.camera.radius),s>0){let e=this.camera.radius,t=this.camera.inertialRadiusOffset+s;for(let i=0;i<20&&Math.abs(t)>.001;i++)e-=t,t*=this.camera.inertia;e=N(e,0,Number.MAX_VALUE),s=this._computeDeltaFromMouseWheelLegacyEvent(n,e)}}else s=n/(40*this.wheelPrecision);s&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(s)):this.camera.inertialRadiusOffset+=s),i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,qs.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)}checkInputs(){if(!this.zoomToMouseLocation)return;const e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}getClassName(){return"ArcRotateCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}_updateHitPlane(){const e=this.camera,t=e.target.subtract(e.position);this._hitPlane=Mi.FromPositionAndNormal(e.target,t)}_getPosition(){const e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,j.Identity(),e,!1);0===e.targetScreenOffset.x&&0===e.targetScreenOffset.y||(this._viewOffset.set(e.targetScreenOffset.x,e.targetScreenOffset.y,0),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),this._globalOffset=X.TransformNormal(this._viewOffset,e._cameraTransformMatrix),i.origin.addInPlace(this._globalOffset));let s=0;return this._hitPlane&&(s=i.intersectsPlane(this._hitPlane)??0),i.origin.addInPlace(i.direction.scaleInPlace(s))}_zoomToMouse(e){const t=this.camera,i=1-t.inertia;if(t.lowerRadiusLimit){const s=t.lowerRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/i<s&&(e=(t.radius-s)*i-t.inertialRadiusOffset)}if(t.upperRadiusLimit){const s=t.upperRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/i>s&&(e=(t.radius-s)*i-t.inertialRadiusOffset)}const s=e/i/t.radius,r=this._getPosition(),n=J.Vector3[6];r.subtractToRef(t.target,n),n.scaleInPlace(s),n.scaleInPlace(i),this._inertialPanning.addInPlace(n),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x)<R&&(e.x=0),Math.abs(e.y)<R&&(e.y=0),Math.abs(e.z)<R&&(e.z=0)}}e([a()],Mr.prototype,"wheelPrecision",void 0),e([a()],Mr.prototype,"zoomToMouseLocation",void 0),e([a()],Mr.prototype,"wheelDeltaPercentage",void 0),gr.ArcRotateCameraMouseWheelInput=Mr;class vr extends mr{constructor(e){super(e)}addMouseWheel(){return this.add(new Mr),this}addPointers(){return this.add(new Ar),this}addKeyboard(){return this.add(new yr),this}}fe.AddNodeConstructor("ArcRotateCamera",((e,t)=>()=>new xr(e,0,0,1,X.Zero(),t)));class xr extends fr{get target(){return this._target}set target(e){this.setTarget(e)}get targetHost(){return this._targetHost}set targetHost(e){e&&this.setTarget(e)}getTarget(){return this.target}get position(){return this._position}set position(e){this.setPosition(e)}set upVector(e){this._upToYMatrix||(this._yToUpMatrix=new j,this._upToYMatrix=new j,this._upVector=X.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){j.RotationAlignToRef(X.UpReadOnly,this._upVector,this._yToUpMatrix),j.RotationAlignToRef(this._upVector,X.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){const e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){const t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){const e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){const t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){const e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom}set useNaturalPinchZoom(e){const t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){const e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){const t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){const e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){const e=this.inputs.attached.mousewheel;return!!e&&e.zoomToMouseLocation}set zoomToMouseLocation(e){const t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){const e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return null!=this._bouncingBehavior}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new dr,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))}get framingBehavior(){return this._framingBehavior}get useFramingBehavior(){return null!=this._framingBehavior}set useFramingBehavior(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new _r,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))}get autoRotationBehavior(){return this._autoRotationBehavior}get useAutoRotationBehavior(){return null!=this._autoRotationBehavior}set useAutoRotationBehavior(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new $s,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,s,r,n,a=!0){super(e,X.Zero(),n,a),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=X.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=Y.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new j,this.panningAxis=new X(1,1,0),this._transformedDirection=new X,this.mapPanning=!1,this._progressiveRestore=!1,this.onMeshTargetChangedObservable=new A,this.checkCollisions=!1,this.collisionRadius=new X(.5,.5,.5),this._previousPosition=X.Zero(),this._collisionVelocity=X.Zero(),this._newPosition=X.Zero(),this._computationVector=X.Zero(),this._onCollisionPositionChange=(e,t,i=null)=>{i?(this.setPosition(t),this.onCollide&&this.onCollide(i)):this._previousPosition.copyFrom(this._position);const s=Math.cos(this.alpha),r=Math.sin(this.alpha),n=Math.cos(this.beta);let a=Math.sin(this.beta);0===a&&(a=1e-4);const o=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*s*a,this.radius*n,this.radius*r*a),o.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let h=this.upVector;this.allowUpsideDown&&this.beta<0&&(h=h.clone(),h=h.negate()),this._computeViewMatrix(this._position,o,h),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=X.Zero(),r&&this.setTarget(r),this.alpha=t,this.beta=i,this.radius=s,this.getViewMatrix(),this.inputs=new vr(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=Y.Zero()}_updateCache(e){e||super._updateCache(),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)}_getTargetPosition(){if(this._targetHost&&this._targetHost.getAbsolutePosition){const e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}const e=this._getLockedTargetPosition();return e||this._target}storeState(){return this._storedAlpha=this._goalAlpha=this.alpha,this._storedBeta=this._goalBeta=this.beta,this._storedRadius=this._goalRadius=this.radius,this._storedTarget=this._goalTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this._goalTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>R&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset,this.restoreStateInterpolationFactor),!0):!!super._restoreStateValues()&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)}interpolateTo(e=this.alpha,t=this.beta,i=this.radius,s=this.target,r=this.targetScreenOffset,n){this._progressiveRestore=!0,this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,null!=n?this._currentInterpolationFactor=n:0!==this.restoreStateInterpolationFactor?this._currentInterpolationFactor=this.restoreStateInterpolationFactor:this._currentInterpolationFactor=.1,e=N(e,this.lowerAlphaLimit??-1/0,this.upperAlphaLimit??1/0),t=N(t,this.lowerBetaLimit??-1/0,this.upperBetaLimit??1/0),i=N(i,this.lowerRadiusLimit??-1/0,this.upperRadiusLimit??1/0),this._goalAlpha=e,this._goalBeta=t,this._goalRadius=i,this._goalTarget=s,this._goalTargetScreenOffset=r}_isSynchronizedViewMatrix(){return!!super._isSynchronizedViewMatrix()&&(this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))}attachControl(e,t,i=!0,s=2){const r=arguments;t=pi.BackCompatCameraNoPreventDefault(r),this._useCtrlForPanning=i,this._panningMouseButton=s,"boolean"==typeof r[0]&&(r.length>1&&(this._useCtrlForPanning=r[1]),r.length>2&&(this._panningMouseButton=r[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),this._progressiveRestore){const e=this._scene.getEngine().getDeltaTime()/1e3,t=1-Math.pow(2,-e/this._currentInterpolationFactor);this.setTarget(X.Lerp(this.getTarget(),this._goalTarget,t)),q.RotationAlphaBetaGammaToRef(this._goalAlpha,this._goalBeta,0,J.Quaternion[0]),q.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,J.Quaternion[1]),q.SlerpToRef(J.Quaternion[1],J.Quaternion[0],t,J.Quaternion[2]),J.Quaternion[2].normalize(),J.Quaternion[2].toAlphaBetaGammaToRef(J.Vector3[0]),this.alpha=J.Vector3[0].x,this.beta=J.Vector3[0].y,this.radius+=(this._goalRadius-this.radius)*t,Y.LerpToRef(this.targetScreenOffset,this._goalTargetScreenOffset,t,this.targetScreenOffset),(X.DistanceSquared(this.getTarget(),this._goalTarget)<R&&J.Quaternion[2].equalsWithEpsilon(J.Quaternion[0])&&Math.pow(this._goalRadius-this.radius,2)<R&&Y.Distance(this.targetScreenOffset,this._goalTargetScreenOffset)<R||0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset||0!==this.inertialPanningX||0!==this.inertialPanningY)&&(this._progressiveRestore=!1)}if(0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){const e=this.invertRotation?-1:1,t=this._calculateHandednessMultiplier();let i=this.inertialAlphaOffset*t;this.beta<0&&(i*=-1),this.alpha+=i*e,this.beta+=this.inertialBetaOffset*e,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<R&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<R&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*R&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){const e=new X(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);if(this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.multiplyInPlace(this.panningAxis),X.TransformNormalToRef(e,this._cameraTransformMatrix,this._transformedDirection),this.mapPanning){const e=this.upVector,t=X.CrossToRef(this._transformedDirection,e,this._transformedDirection);X.CrossToRef(e,t,this._transformedDirection)}else this.panningAxis.y||(this._transformedDirection.y=0);if(!this._targetHost)if(this.panningDistanceLimit){this._transformedDirection.addInPlace(this._target);X.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection)}else{if(this.parent){const e=J.Matrix[0];this.parent.getWorldMatrix().getRotationMatrixToRef(e),e.transposeToRef(e),X.TransformCoordinatesToRef(this._transformedDirection,e,this._transformedDirection)}this._target.addInPlace(this._transformedDirection)}this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*R&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*R&&(this.inertialPanningY=0)}this._checkLimits(),super._checkInputs()}}_checkLimits(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),null!==this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),null!==this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||X.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);const e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);const t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,i=!1,s=!1){if(s=this.overrideCloneAlphaBetaRadius??s,e.computeWorldMatrix)t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{const t=e,s=this._getTargetPosition();if(s&&!i&&s.equals(t))return;this._targetHost=null,this._target=t,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}s||this.rebuildAnglesAndRadius()}_getViewMatrix(){const e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta);let s=Math.sin(this.beta);0===s&&(s=1e-4),0===this.radius&&(this.radius=1e-4);const r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*s,this.radius*i,this.radius*t*s),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||X.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){const e=this.getScene().collisionCoordinator;this._collider||(this._collider=e.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,e.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let e=this.upVector;this.allowUpsideDown&&s<0&&(e=e.negate()),this._computeViewMatrix(this._position,r,e),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=r,this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const i=Qs.MinMax(e);let s=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);s=Math.max(Math.min(s,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=s*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:s},t)}focusOn(e,t=!1){let i,s;if(void 0===e.min){const t=e||this.getScene().meshes;i=Qs.MinMax(t),s=X.Distance(i.min,i.max)}else{i=e,s=e.distance}this._target=Qs.Center(i),t||(this.maxZ=2*s)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case xi.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case xi.RIG_MODE_STEREOSCOPIC_OVERUNDER:case xi.RIG_MODE_STEREOSCOPIC_INTERLACED:case xi.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(0===t?1:-1);break;case xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(0===t?-1:1)}const s=new xr(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return s._cameraRigParams={},s.isRigCamera=!0,s.rigParent=this,s.upVector=this.upVector,s.mode=this.mode,s.orthoLeft=this.orthoLeft,s.orthoRight=this.orthoRight,s.orthoBottom=this.orthoBottom,s.orthoTop=this.orthoTop,s}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case xi.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case xi.RIG_MODE_STEREOSCOPIC_OVERUNDER:case xi.RIG_MODE_STEREOSCOPIC_INTERLACED:case xi.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case xi.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}super._updateRigCameras()}_calculateLowerRadiusFromModelBoundingSphere(e,t,i=1){const s=X.Distance(e,t),r=this.getScene().getEngine().getAspectRatio(this),n=Math.tan(this.fov/2),a=n*r,o=.5*s*i,h=o*Math.sqrt(1+1/(a*a)),l=o*Math.sqrt(1+1/(n*n));return Math.max(h,l)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}}e([a()],xr.prototype,"alpha",void 0),e([a()],xr.prototype,"beta",void 0),e([a()],xr.prototype,"radius",void 0),e([a()],xr.prototype,"overrideCloneAlphaBetaRadius",void 0),e([u("target")],xr.prototype,"_target",void 0),e([d("targetHost")],xr.prototype,"_targetHost",void 0),e([a()],xr.prototype,"inertialAlphaOffset",void 0),e([a()],xr.prototype,"inertialBetaOffset",void 0),e([a()],xr.prototype,"inertialRadiusOffset",void 0),e([a()],xr.prototype,"lowerAlphaLimit",void 0),e([a()],xr.prototype,"upperAlphaLimit",void 0),e([a()],xr.prototype,"lowerBetaLimit",void 0),e([a()],xr.prototype,"upperBetaLimit",void 0),e([a()],xr.prototype,"lowerRadiusLimit",void 0),e([a()],xr.prototype,"upperRadiusLimit",void 0),e([a()],xr.prototype,"inertialPanningX",void 0),e([a()],xr.prototype,"inertialPanningY",void 0),e([a()],xr.prototype,"pinchToPanMaxDistance",void 0),e([a()],xr.prototype,"panningDistanceLimit",void 0),e([u()],xr.prototype,"panningOriginTarget",void 0),e([a()],xr.prototype,"panningInertia",void 0),e([a()],xr.prototype,"zoomToMouseLocation",null),e([a()],xr.prototype,"zoomOnFactor",void 0),e([c()],xr.prototype,"targetScreenOffset",void 0),e([a()],xr.prototype,"allowUpsideDown",void 0),e([a()],xr.prototype,"useInputToRestoreState",void 0),e([a()],xr.prototype,"restoreStateInterpolationFactor",void 0),S("BABYLON.ArcRotateCamera",xr);class Sr extends fe{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t){super(e,t,!1),this.diffuse=new he(1,1,1),this.specular=new he(1,1,1),this.falloffType=Sr.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=Sr.INTENSITYMODE_AUTOMATIC,this._radius=1e-5,this.renderPriority=0,this._shadowEnabled=!0,this._excludeWithLayerMask=0,this._includeOnlyWithLayerMask=0,this._lightmapMode=0,this._shadowGenerators=null,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,this._isLight=!0,this.getScene().addLight(this),this._uniformBuffer=new rs(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,i,s,r=!0){const n=e.toString();let a=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+n),this._renderId!==t.getRenderId()||this._lastUseSpecular!==s||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=s;const e=this.getScaledIntensity();this.transferToEffect(i,n),this.diffuse.scaleToRef(e,ce.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",ce.Color3[0],this.range,n),s&&(this.specular.scaleToRef(e,ce.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",ce.Color3[1],this.radius,n)),a=!0}if(this.transferTexturesToEffect(i,n),t.shadowsEnabled&&this.shadowEnabled&&r){const e=this.getShadowGenerator(t.activeCamera)??this.getShadowGenerator();e&&(e.bindShadowLight(n,i),a=!0)}a?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t}_syncParentEnabledState(){super._syncParentEnabledState(),this.isDisposed()||this._resyncMeshes()}setEnabled(e){super.setEnabled(e),this._resyncMeshes()}getShadowGenerator(e=null){return null===this._shadowGenerators?null:this._shadowGenerators.get(e)??null}getShadowGenerators(){return this._shadowGenerators}getAbsolutePosition(){return X.Zero()}canAffectMesh(e){return!e||!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&(!!(0===this.includeOnlyWithLayerMask||this.includeOnlyWithLayerMask&e.layerMask)&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))}dispose(e,t=!1){if(this._shadowGenerators){const e=this._shadowGenerators.values();for(let t=e.next();!0!==t.done;t=e.next()){t.value.dispose()}this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){const e=this._parentContainer.lights.indexOf(this);e>-1&&this._parentContainer.lights.splice(e,1),this._parentContainer=null}for(const e of this.getScene().meshes)e._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),super.dispose(e,t)}getTypeID(){return 0}getScaledIntensity(){return this._photometricScale*this.intensity}clone(e,t=null){const i=Sr.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;const s=de.Clone(i,this);return e&&(s.name=e),t&&(s.parent=t),s.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(s),s}serialize(){const e=de.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((t=>{e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((t=>{e.includedOnlyMeshesIds.push(t.id)}))),de.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){const s=fe.Construct("Light_Type_"+e,t,i);return s||null}static Parse(e,t){const i=Sr.GetConstructorFromName(e.type,e.name,t);if(!i)return null;const s=de.Parse(i,e,t);if(e.excludedMeshesIds&&(s._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(s._includedOnlyMeshesIds=e.includedOnlyMeshesIds),void 0!==e.parentId&&(s._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),void 0!==e.falloffType&&(s.falloffType=e.falloffType),void 0!==e.lightmapMode&&(s.lightmapMode=e.lightmapMode),e.animations){for(let t=0;t<e.animations.length;t++){const i=e.animations[t],r=C("BABYLON.Animation");r&&s.animations.push(r.Parse(i))}fe.ParseAnimationRanges(s,e,t)}return e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),void 0!==e.isEnabled&&s.setEnabled(e.isEnabled),s}_hookArrayForExcluded(e){const t=e.push;e.push=(...i)=>{const s=t.apply(e,i);for(const e of i)e._resyncLightSource(this);return s};const i=e.splice;e.splice=(t,s)=>{const r=i.apply(e,[t,s]);for(const e of r)e._resyncLightSource(this);return r};for(const t of e)t._resyncLightSource(this)}_hookArrayForIncludedOnly(e){const t=e.push;e.push=(...i)=>{const s=t.apply(e,i);return this._resyncMeshes(),s};const i=e.splice;e.splice=(t,s)=>{const r=i.apply(e,[t,s]);return this._resyncMeshes(),r},this._resyncMeshes()}_resyncMeshes(){for(const e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(const e of this.getScene().meshes)-1!==e.lightSources.indexOf(this)&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0;const t=this.getTypeID();let i=this.intensityMode;switch(i===Sr.INTENSITYMODE_AUTOMATIC&&(i=t===Sr.LIGHTTYPEID_DIRECTIONALLIGHT?Sr.INTENSITYMODE_ILLUMINANCE:Sr.INTENSITYMODE_LUMINOUSINTENSITY),t){case Sr.LIGHTTYPEID_POINTLIGHT:case Sr.LIGHTTYPEID_SPOTLIGHT:switch(i){case Sr.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case Sr.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case Sr.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case Sr.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case Sr.INTENSITYMODE_ILLUMINANCE:e=1;break;case Sr.INTENSITYMODE_LUMINANCE:{let t=this.radius;t=Math.max(t,.001);e=2*Math.PI*(1-Math.cos(t));break}}break;case Sr.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e}_reorderLightsInScene(){const e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}}Sr.FALLOFF_DEFAULT=us.FALLOFF_DEFAULT,Sr.FALLOFF_PHYSICAL=us.FALLOFF_PHYSICAL,Sr.FALLOFF_GLTF=us.FALLOFF_GLTF,Sr.FALLOFF_STANDARD=us.FALLOFF_STANDARD,Sr.LIGHTMAP_DEFAULT=us.LIGHTMAP_DEFAULT,Sr.LIGHTMAP_SPECULAR=us.LIGHTMAP_SPECULAR,Sr.LIGHTMAP_SHADOWSONLY=us.LIGHTMAP_SHADOWSONLY,Sr.INTENSITYMODE_AUTOMATIC=us.INTENSITYMODE_AUTOMATIC,Sr.INTENSITYMODE_LUMINOUSPOWER=us.INTENSITYMODE_LUMINOUSPOWER,Sr.INTENSITYMODE_LUMINOUSINTENSITY=us.INTENSITYMODE_LUMINOUSINTENSITY,Sr.INTENSITYMODE_ILLUMINANCE=us.INTENSITYMODE_ILLUMINANCE,Sr.INTENSITYMODE_LUMINANCE=us.INTENSITYMODE_LUMINANCE,Sr.LIGHTTYPEID_POINTLIGHT=us.LIGHTTYPEID_POINTLIGHT,Sr.LIGHTTYPEID_DIRECTIONALLIGHT=us.LIGHTTYPEID_DIRECTIONALLIGHT,Sr.LIGHTTYPEID_SPOTLIGHT=us.LIGHTTYPEID_SPOTLIGHT,Sr.LIGHTTYPEID_HEMISPHERICLIGHT=us.LIGHTTYPEID_HEMISPHERICLIGHT,e([h()],Sr.prototype,"diffuse",void 0),e([h()],Sr.prototype,"specular",void 0),e([a()],Sr.prototype,"falloffType",void 0),e([a()],Sr.prototype,"intensity",void 0),e([a()],Sr.prototype,"range",null),e([a()],Sr.prototype,"intensityMode",null),e([a()],Sr.prototype,"radius",null),e([a()],Sr.prototype,"_renderPriority",void 0),e([n("_reorderLightsInScene")],Sr.prototype,"renderPriority",void 0),e([a("shadowEnabled")],Sr.prototype,"_shadowEnabled",void 0),e([a("excludeWithLayerMask")],Sr.prototype,"_excludeWithLayerMask",void 0),e([a("includeOnlyWithLayerMask")],Sr.prototype,"_includeOnlyWithLayerMask",void 0),e([a("lightmapMode")],Sr.prototype,"_lightmapMode",void 0),fe.AddNodeConstructor("Light_Type_3",((e,t)=>()=>new Cr(e,X.Zero(),t)));class Cr extends Sr{constructor(e,t,i){super(e,i),this.groundColor=new he(0,0,0),this.direction=t||X.Up()}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}getClassName(){return"HemisphericLight"}setDirectionToTarget(e){return this.direction=X.Normalize(e.subtract(X.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){const i=X.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",i.x,i.y,i.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this}transferToNodeMaterialEffect(e,t){const i=X.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=j.Identity()),this._worldMatrix}getTypeID(){return Sr.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}e([h()],Cr.prototype,"groundColor",void 0),e([u()],Cr.prototype,"direction",void 0),S("BABYLON.HemisphericLight",Cr);class Pr{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach(((e,t)=>this.add(e,t)))}get(e){const t=this._data[e];if(void 0!==t)return t}getOrAddWithFactory(e,t){let i=this.get(e);return void 0!==i||(i=t(e),i&&this.add(e,i)),i}getOrAdd(e,t){const i=this.get(e);return void 0!==i?i:(this.add(e,t),t)}contains(e){return void 0!==this._data[e]}add(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)}set(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)}getAndRemove(e){const t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null}remove(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)}clear(){this._data={},this._count=0}get count(){return this._count}forEach(e){for(const t in this._data){e(t,this._data[t])}}first(e){for(const t in this._data){const i=e(t,this._data[t]);if(i)return i}return null}}function Or(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class Dr{constructor(){this._dirty=!0,this._tempColor=new le(0,0,0,0),this._globalCurve=new le(0,0,0,0),this._highlightsCurve=new le(0,0,0,0),this._midtonesCurve=new le(0,0,0,0),this._shadowsCurve=new le(0,0,0,0),this._positiveCurve=new le(0,0,0,0),this._negativeCurve=new le(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}get globalHue(){return this._globalHue}set globalHue(e){this._globalHue=e,this._dirty=!0}get globalDensity(){return this._globalDensity}set globalDensity(e){this._globalDensity=e,this._dirty=!0}get globalSaturation(){return this._globalSaturation}set globalSaturation(e){this._globalSaturation=e,this._dirty=!0}get globalExposure(){return this._globalExposure}set globalExposure(e){this._globalExposure=e,this._dirty=!0}get highlightsHue(){return this._highlightsHue}set highlightsHue(e){this._highlightsHue=e,this._dirty=!0}get highlightsDensity(){return this._highlightsDensity}set highlightsDensity(e){this._highlightsDensity=e,this._dirty=!0}get highlightsSaturation(){return this._highlightsSaturation}set highlightsSaturation(e){this._highlightsSaturation=e,this._dirty=!0}get highlightsExposure(){return this._highlightsExposure}set highlightsExposure(e){this._highlightsExposure=e,this._dirty=!0}get midtonesHue(){return this._midtonesHue}set midtonesHue(e){this._midtonesHue=e,this._dirty=!0}get midtonesDensity(){return this._midtonesDensity}set midtonesDensity(e){this._midtonesDensity=e,this._dirty=!0}get midtonesSaturation(){return this._midtonesSaturation}set midtonesSaturation(e){this._midtonesSaturation=e,this._dirty=!0}get midtonesExposure(){return this._midtonesExposure}set midtonesExposure(e){this._midtonesExposure=e,this._dirty=!0}get shadowsHue(){return this._shadowsHue}set shadowsHue(e){this._shadowsHue=e,this._dirty=!0}get shadowsDensity(){return this._shadowsDensity}set shadowsDensity(e){this._shadowsDensity=e,this._dirty=!0}get shadowsSaturation(){return this._shadowsSaturation}set shadowsSaturation(e){this._shadowsSaturation=e,this._dirty=!0}get shadowsExposure(){return this._shadowsExposure}set shadowsExposure(e){this._shadowsExposure=e,this._dirty=!0}getClassName(){return"ColorCurves"}static Bind(e,t,i="vCameraColorCurvePositive",s="vCameraColorCurveNeutral",r="vCameraColorCurveNegative"){e._dirty&&(e._dirty=!1,e._getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e._getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e._getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e._getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(s,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,s,r){null!=e&&(e=Dr._Clamp(e,0,360),t=Dr._Clamp(t,-100,100),i=Dr._Clamp(i,-100,100),s=Dr._Clamp(s,-100,100),t=Dr._ApplyColorGradingSliderNonlinear(t),t*=.5,s=Dr._ApplyColorGradingSliderNonlinear(s),t<0&&(t*=-1,e=(e+180)%360),Dr._FromHSBToRef(e,t,50+.25*s,r),r.scaleToRef(2,r),r.a=1+.01*i)}static _ApplyColorGradingSliderNonlinear(e){e/=100;let t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100,t}static _FromHSBToRef(e,t,i,s){let r=Dr._Clamp(e,0,360);const n=Dr._Clamp(t/100,0,1),a=Dr._Clamp(i/100,0,1);if(0===n)s.r=a,s.g=a,s.b=a;else{r/=60;const e=Math.floor(r),t=r-e,i=a*(1-n),o=a*(1-n*t),h=a*(1-n*(1-t));switch(e){case 0:s.r=a,s.g=h,s.b=i;break;case 1:s.r=o,s.g=a,s.b=i;break;case 2:s.r=i,s.g=a,s.b=h;break;case 3:s.r=i,s.g=o,s.b=a;break;case 4:s.r=h,s.g=i,s.b=a;break;default:s.r=a,s.g=i,s.b=o}}s.a=1}static _Clamp(e,t,i){return Math.min(Math.max(e,t),i)}clone(){return de.Clone((()=>new Dr),this)}serialize(){return de.Serialize(this)}static Parse(e){return de.Parse((()=>new Dr),e,null,null)}}Dr.PrepareUniforms=Or,e([a()],Dr.prototype,"_globalHue",void 0),e([a()],Dr.prototype,"_globalDensity",void 0),e([a()],Dr.prototype,"_globalSaturation",void 0),e([a()],Dr.prototype,"_globalExposure",void 0),e([a()],Dr.prototype,"_highlightsHue",void 0),e([a()],Dr.prototype,"_highlightsDensity",void 0),e([a()],Dr.prototype,"_highlightsSaturation",void 0),e([a()],Dr.prototype,"_highlightsExposure",void 0),e([a()],Dr.prototype,"_midtonesHue",void 0),e([a()],Dr.prototype,"_midtonesDensity",void 0),e([a()],Dr.prototype,"_midtonesSaturation",void 0),e([a()],Dr.prototype,"_midtonesExposure",void 0),de._ColorCurvesParser=Dr.Parse;class Lr{constructor(){this.colorCurves=new Dr,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=Lr.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new le(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=Lr.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new A}get colorCurvesEnabled(){return this._colorCurvesEnabled}set colorCurvesEnabled(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())}get colorGradingTexture(){return this._colorGradingTexture}set colorGradingTexture(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())}get colorGradingEnabled(){return this._colorGradingEnabled}set colorGradingEnabled(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())}get colorGradingWithGreenDepth(){return this._colorGradingWithGreenDepth}set colorGradingWithGreenDepth(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())}get colorGradingBGR(){return this._colorGradingBGR}set colorGradingBGR(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())}get exposure(){return this._exposure}set exposure(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())}get toneMappingEnabled(){return this._toneMappingEnabled}set toneMappingEnabled(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())}get toneMappingType(){return this._toneMappingType}set toneMappingType(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())}get contrast(){return this._contrast}set contrast(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())}get vignetteCentreY(){return this.vignetteCenterY}set vignetteCentreY(e){this.vignetteCenterY=e}get vignetteCentreX(){return this.vignetteCenterX}set vignetteCentreX(e){this.vignetteCenterX=e}get vignetteBlendMode(){return this._vignetteBlendMode}set vignetteBlendMode(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())}get vignetteEnabled(){return this._vignetteEnabled}set vignetteEnabled(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())}get ditheringEnabled(){return this._ditheringEnabled}set ditheringEnabled(e){this._ditheringEnabled!==e&&(this._ditheringEnabled=e,this._updateParameters())}get ditheringIntensity(){return this._ditheringIntensity}set ditheringIntensity(e){this._ditheringIntensity!==e&&(this._ditheringIntensity=e,this._updateParameters())}get skipFinalColorClamp(){return this._skipFinalColorClamp}set skipFinalColorClamp(e){this._skipFinalColorClamp!==e&&(this._skipFinalColorClamp=e,this._updateParameters())}get applyByPostProcess(){return this._applyByPostProcess}set applyByPostProcess(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())}_updateParameters(){this.onUpdateParameters.notifyObservers(this)}getClassName(){return"ImageProcessingConfiguration"}prepareDefines(e,t=!1){if(t!==this.applyByPostProcess||!this._isEnabled)return e.VIGNETTE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.DITHER=!1,e.IMAGEPROCESSING=!1,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,void(e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);if(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===Lr._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,this._toneMappingEnabled)switch(this._toneMappingType){case Lr.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case Lr.TONEMAPPING_ACES:e.TONEMAPPING=2;break;default:e.TONEMAPPING=1}else e.TONEMAPPING=0;e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.DITHER=this._ditheringEnabled,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSING=e.VIGNETTE||!!e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING||e.DITHER}isReady(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()}bind(e,t){if(this._colorCurvesEnabled&&this.colorCurves&&Dr.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){const i=1/e.getEngine().getRenderWidth(),s=1/e.getEngine().getRenderHeight();if(e.setFloat2("vInverseScreenSize",i,s),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){const r=null!=t?t:s/i;let n=Math.tan(.5*this.vignetteCameraFov),a=n*r;const o=Math.sqrt(a*n);a=ci(a,o,this.vignetteStretch),n=ci(n,o,this.vignetteStretch),e.setFloat4("vignetteSettings1",a,n,-a*this.vignetteCenterX,-n*this.vignetteCenterY);const h=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,h)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);const t=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(t-1)/t,.5/t,t,this.colorGradingTexture.level)}}clone(){return de.Clone((()=>new Lr),this)}serialize(){return de.Serialize(this)}static Parse(e){const t=de.Parse((()=>new Lr),e,null,null);return void 0!==e.vignetteCentreX&&(t.vignetteCenterX=e.vignetteCentreX),void 0!==e.vignetteCentreY&&(t.vignetteCenterY=e.vignetteCentreY),t}static get VIGNETTEMODE_MULTIPLY(){return this._VIGNETTEMODE_MULTIPLY}static get VIGNETTEMODE_OPAQUE(){return this._VIGNETTEMODE_OPAQUE}}Lr.TONEMAPPING_STANDARD=0,Lr.TONEMAPPING_ACES=1,Lr.TONEMAPPING_KHR_PBR_NEUTRAL=2,Lr.PrepareUniforms=function(e,t){t.EXPOSURE&&e.push("exposureLinear"),t.CONTRAST&&e.push("contrast"),t.COLORGRADING&&e.push("colorTransformSettings"),(t.VIGNETTE||t.DITHER)&&e.push("vInverseScreenSize"),t.VIGNETTE&&(e.push("vignetteSettings1"),e.push("vignetteSettings2")),t.COLORCURVES&&Or(e),t.DITHER&&e.push("ditherIntensity")},Lr.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},Lr._VIGNETTEMODE_MULTIPLY=0,Lr._VIGNETTEMODE_OPAQUE=1,e([function(e){return r(7,e)}()],Lr.prototype,"colorCurves",void 0),e([a()],Lr.prototype,"_colorCurvesEnabled",void 0),e([o("colorGradingTexture")],Lr.prototype,"_colorGradingTexture",void 0),e([a()],Lr.prototype,"_colorGradingEnabled",void 0),e([a()],Lr.prototype,"_colorGradingWithGreenDepth",void 0),e([a()],Lr.prototype,"_colorGradingBGR",void 0),e([a()],Lr.prototype,"_exposure",void 0),e([a()],Lr.prototype,"_toneMappingEnabled",void 0),e([a()],Lr.prototype,"_toneMappingType",void 0),e([a()],Lr.prototype,"_contrast",void 0),e([a()],Lr.prototype,"vignetteStretch",void 0),e([a()],Lr.prototype,"vignetteCenterX",void 0),e([a()],Lr.prototype,"vignetteCenterY",void 0),e([a()],Lr.prototype,"vignetteWeight",void 0),e([_()],Lr.prototype,"vignetteColor",void 0),e([a()],Lr.prototype,"vignetteCameraFov",void 0),e([a()],Lr.prototype,"_vignetteBlendMode",void 0),e([a()],Lr.prototype,"_vignetteEnabled",void 0),e([a()],Lr.prototype,"_ditheringEnabled",void 0),e([a()],Lr.prototype,"_ditheringIntensity",void 0),e([a()],Lr.prototype,"_skipFinalColorClamp",void 0),e([a()],Lr.prototype,"_applyByPostProcess",void 0),e([a()],Lr.prototype,"_isEnabled",void 0),de._ImageProcessingConfigurationParser=Lr.Parse,S("BABYLON.ImageProcessingConfiguration",Lr);class Fr{constructor(e,t,i,s,r,n){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=s,this.sourceEvent=r,this.additionalData=n}static CreateNew(e,t,i){const s=e.getScene();return new Fr(e,s.pointerX,s.pointerY,s.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,s){return new Fr(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,s)}static CreateNewFromScene(e,t){return new Fr(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,s){return new Fr(e,t.x,t.y,null,i,s)}}class wr{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new A,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[wi.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[wi.PositionKind]=new wi(this._scene.getEngine(),e,wi.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){const e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}_rebuild(){const e=this._vertexBuffers[wi.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())}_prepareFrame(e=null,t=null){const i=this._scene.activeCamera;return!!i&&(!(!(t=t||i._postProcesses.filter((e=>null!=e)))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!=t),!0))}directRender(e,t=null,i=!1,s=0,r=0,n=!1){const a=this._scene.getEngine();for(let o=0;o<e.length;o++){o<e.length-1?e[o+1].activate(this._scene.activeCamera||this._scene,t?.texture):(t?a.bindFramebuffer(t,s,void 0,void 0,i,r):n||a.restoreDefaultFramebuffer(),a._debugInsertMarker?.(`post process ${e[o].name} output`));const h=e[o],l=h.apply();l&&(h.onBeforeRenderObservable.notifyObservers(l),this._prepareBuffers(),a.bindBuffers(this._vertexBuffers,this._indexBuffer,l),a.drawElementsType(Ve.MATERIAL_TriangleFillMode,0,6),h.onAfterRenderObservable.notifyObservers(l))}a.setDepthBuffer(!0),a.setDepthWrite(!0)}_finalizeFrame(e,t,i,s,r=!1){const n=this._scene.activeCamera;if(!n)return;if(this.onBeforeRenderObservable.notifyObservers(this),0===(s=s||n._postProcesses.filter((e=>null!=e))).length||!this._scene.postProcessesEnabled)return;const a=this._scene.getEngine();for(let o=0,h=s.length;o<h;o++){const l=s[o];if(o<h-1?l._outputTexture=s[o+1].activate(n,t?.texture):(t?(a.bindFramebuffer(t,i,void 0,void 0,r),l._outputTexture=t):(a.restoreDefaultFramebuffer(),l._outputTexture=null),a._debugInsertMarker?.(`post process ${s[o].name} output`)),e)break;const c=l.apply();c&&(l.onBeforeRenderObservable.notifyObservers(c),this._prepareBuffers(),a.bindBuffers(this._vertexBuffers,this._indexBuffer,c),a.drawElementsType(Ve.MATERIAL_TriangleFillMode,0,6),l.onAfterRenderObservable.notifyObservers(c))}a.setDepthBuffer(!0),a.setDepthWrite(!0),a.setAlphaMode(Ve.ALPHA_DISABLE)}dispose(){const e=this._vertexBuffers[wi.PositionKind];e&&(e.dispose(),this._vertexBuffers[wi.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)}}class Nr{set opaqueSortCompareFn(e){this._opaqueSortCompareFn=e||Nr.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){this._alphaTestSortCompareFn=e||Nr.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){this._transparentSortCompareFn=e||Nr.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,s=null,r=null){this.index=e,this._opaqueSubMeshes=new Ri(256),this._transparentSubMeshes=new Ri(256),this._alphaTestSubMeshes=new Ri(256),this._depthOnlySubMeshes=new Ri(256),this._particleSystems=new Ri(256),this._spriteManagers=new Ri(256),this._empty=!0,this._edgesRenderers=new yi(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=s,this.transparentSortCompareFn=r}render(e,t,i,s){if(e)return void e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);const r=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);const n=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(s),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length||this._scene.useOrderIndependentTransparency){if(r.setStencilBuffer(n),this._scene.useOrderIndependentTransparency){const e=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);e.length&&this._renderTransparent(e)}else this._renderTransparent(this._transparentSubMeshes);r.setAlphaMode(Ve.ALPHA_DISABLE)}if(r.setStencilBuffer(!1),this._edgesRenderers.length){for(let e=0;e<this._edgesRenderers.length;e++)this._edgesRenderers.data[e].render();r.setAlphaMode(Ve.ALPHA_DISABLE)}r.setStencilBuffer(n)}_renderOpaqueSorted(e){Nr._RenderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1)}_renderAlphaTestSorted(e){Nr._RenderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)}_renderTransparentSorted(e){Nr._RenderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0)}static _RenderSorted(e,t,i,s){let r,n=0;const a=i?i.globalPosition:Nr._ZeroVector;if(s)for(;n<e.length;n++)r=e.data[n],r._alphaIndex=r.getMesh().alphaIndex,r._distanceToCamera=X.Distance(r.getBoundingInfo().boundingSphere.centerWorld,a);const o=e.length===e.data.length?e.data:e.data.slice(0,e.length);t&&o.sort(t);const h=o[0].getMesh().getScene();for(n=0;n<o.length;n++)if(r=o[n],!h._activeMeshesFrozenButKeepClipping||r.isInFrustum(h._frustumPlanes)){if(s){const e=r.getMaterial();if(e&&e.needDepthPrePass){const t=e.getScene().getEngine();t.setColorWrite(!1),t.setAlphaMode(Ve.ALPHA_DISABLE),r.render(!1),t.setColorWrite(!0)}}r.render(s)}}static defaultTransparentSortCompare(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:Nr.backToFrontSortCompare(e,t)}static backToFrontSortCompare(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0}static PainterSortCompare(e,t){const i=e.getMesh(),s=t.getMesh();return i.material&&s.material?i.material.uniqueId-s.material.uniqueId:i.uniqueId-s.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(0===this._particleSystems.length)return;const t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let i=0;i<this._particleSystems.length;i++){const s=this._particleSystems.data[i];if(0===(t&&t.layerMask&s.layerMask))continue;const r=s.emitter;r.position&&e&&-1===e.indexOf(r)||this._scene._activeParticles.addCount(s.render(),!1)}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}_renderSprites(){if(!this._scene.spritesEnabled||0===this._spriteManagers.length)return;const e=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(let t=0;t<this._spriteManagers.length;t++){const i=this._spriteManagers.data[t];0!==(e&&e.layerMask&i.layerMask)&&i.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}}Nr._ZeroVector=X.Zero();class Br{}class Ur{get maintainStateBetweenFrames(){return this._maintainStateBetweenFrames}set maintainStateBetweenFrames(e){e!==this._maintainStateBetweenFrames&&(this._maintainStateBetweenFrames=e,this._maintainStateBetweenFrames||this.restoreDispachedFlags())}restoreDispachedFlags(){for(const e of this._scene.meshes)if(e.subMeshes)for(const t of e.subMeshes)t._wasDispatched=!1;if(this._scene.spriteManagers)for(const e of this._scene.spriteManagers)e._wasDispatched=!1;for(const e of this._scene.particleSystems)e._wasDispatched=!1}constructor(e){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new Br,this._maintainStateBetweenFrames=!1,this._scene=e;for(let e=Ur.MIN_RENDERINGGROUPS;e<Ur.MAX_RENDERINGGROUPS;e++)this._autoClearDepthStencil[e]={autoClear:!0,depth:!0,stencil:!0}}getRenderingGroup(e){const t=e||0;return this._prepareRenderingGroup(t),this._renderingGroups[t]}_clearDepthStencilBuffer(e=!0,t=!0){this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,e,t),this._depthStencilBufferAlreadyCleaned=!0)}render(e,t,i,s){const r=this._renderingGroupInfo;if(r.scene=this._scene,r.camera=this._scene.activeCamera,this._scene.spriteManagers&&s)for(let e=0;e<this._scene.spriteManagers.length;e++){const t=this._scene.spriteManagers[e];this.dispatchSprites(t)}for(let n=Ur.MIN_RENDERINGGROUPS;n<Ur.MAX_RENDERINGGROUPS;n++){this._depthStencilBufferAlreadyCleaned=n===Ur.MIN_RENDERINGGROUPS;const a=this._renderingGroups[n];if(!a||a._empty)continue;const o=1<<n;if(r.renderingGroupId=n,this._scene.onBeforeRenderingGroupObservable.notifyObservers(r,o),Ur.AUTOCLEAR){const e=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(n):this._autoClearDepthStencil[n];e&&e.autoClear&&this._clearDepthStencilBuffer(e.depth,e.stencil)}for(const e of this._scene._beforeRenderingGroupDrawStage)e.action(n);a.render(e,s,i,t);for(const e of this._scene._afterRenderingGroupDrawStage)e.action(n);this._scene.onAfterRenderingGroupObservable.notifyObservers(r,o)}}reset(){if(!this.maintainStateBetweenFrames)for(let e=Ur.MIN_RENDERINGGROUPS;e<Ur.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepare()}}resetSprites(){if(!this.maintainStateBetweenFrames)for(let e=Ur.MIN_RENDERINGGROUPS;e<Ur.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepareSprites()}}dispose(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null}freeRenderingGroups(){for(let e=Ur.MIN_RENDERINGGROUPS;e<Ur.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.dispose()}}_prepareRenderingGroup(e){void 0===this._renderingGroups[e]&&(this._renderingGroups[e]=new Nr(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))}dispatchSprites(e){this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(e.renderingGroupId).dispatchSprites(e))}dispatchParticles(e){this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(e.renderingGroupId).dispatchParticles(e))}dispatch(e,t,i){void 0===t&&(t=e.getMesh()),this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(t.renderingGroupId).dispatch(e,t,i))}setRenderingOrder(e,t=null,i=null,s=null){if(this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=s,this._renderingGroups[e]){const t=this._renderingGroups[e];t.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],t.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],t.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:s}}getAutoClearDepthStencilSetup(e){return this._autoClearDepthStencil[e]}}Ur.MAX_RENDERINGGROUPS=4,Ur.MIN_RENDERINGGROUPS=0,Ur.AUTOCLEAR=!0;class kr{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in kr.Triggers)if(Object.prototype.hasOwnProperty.call(kr.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in kr.Triggers)if(Object.prototype.hasOwnProperty.call(kr.Triggers,e)){const t=parseInt(e);if(t>=Ve.ACTION_OnPickTrigger&&t<=Ve.ACTION_OnPickUpTrigger)return!0}return!1}static HasSpecificTrigger(e){for(const t in kr.Triggers)if(Object.prototype.hasOwnProperty.call(kr.Triggers,t)){if(parseInt(t)===e)return!0}return!1}}var Vr,zr,Gr,Hr,Wr,Kr,Yr;kr.Triggers={},function(e){e[e.Generic=0]="Generic",e[e.Keyboard=1]="Keyboard",e[e.Mouse=2]="Mouse",e[e.Touch=3]="Touch",e[e.DualShock=4]="DualShock",e[e.Xbox=5]="Xbox",e[e.Switch=6]="Switch",e[e.DualSense=7]="DualSense"}(Vr||(Vr={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.Move=12]="Move"}(zr||(zr={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.DeltaHorizontal=10]="DeltaHorizontal",e[e.DeltaVertical=11]="DeltaVertical"}(Gr||(Gr={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(Hr||(Hr={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Create=8]="Create",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(Wr||(Wr={})),function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.LT=6]="LT",e[e.RT=7]="RT",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.LStickXAxis=17]="LStickXAxis",e[e.LStickYAxis=18]="LStickYAxis",e[e.RStickXAxis=19]="RStickXAxis",e[e.RStickYAxis=20]="RStickYAxis"}(Kr||(Kr={})),function(e){e[e.B=0]="B",e[e.A=1]="A",e[e.Y=2]="Y",e[e.X=3]="X",e[e.L=4]="L",e[e.R=5]="R",e[e.ZL=6]="ZL",e[e.ZR=7]="ZR",e[e.Minus=8]="Minus",e[e.Plus=9]="Plus",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.Capture=17]="Capture",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(Yr||(Yr={}));class Xr{static CreateDeviceEvent(e,t,i,s,r,n,a){switch(e){case Vr.Keyboard:return this._CreateKeyboardEvent(i,s,r,n);case Vr.Mouse:if(i===zr.MouseWheelX||i===zr.MouseWheelY||i===zr.MouseWheelZ)return this._CreateWheelEvent(e,t,i,s,r,n);case Vr.Touch:return this._CreatePointerEvent(e,t,i,s,r,n,a);default:throw`Unable to generate event for device ${Vr[e]}`}}static _CreatePointerEvent(e,t,i,s,r,n,a){const o=this._CreateMouseEvent(e,t,i,s,r,n);e===Vr.Mouse?(o.deviceType=Vr.Mouse,o.pointerId=1,o.pointerType="mouse"):(o.deviceType=Vr.Touch,o.pointerId=a??t,o.pointerType="touch");let h=0;return h+=r.pollInput(e,t,zr.LeftClick),h+=2*r.pollInput(e,t,zr.RightClick),h+=4*r.pollInput(e,t,zr.MiddleClick),o.buttons=h,i===zr.Move?o.type="pointermove":i>=zr.LeftClick&&i<=zr.RightClick&&(o.type=1===s?"pointerdown":"pointerup",o.button=i-2),o}static _CreateWheelEvent(e,t,i,s,r,n){const a=this._CreateMouseEvent(e,t,i,s,r,n);switch(a.pointerId=1,a.type="wheel",a.deltaMode=Ir.DOM_DELTA_PIXEL,a.deltaX=0,a.deltaY=0,a.deltaZ=0,i){case zr.MouseWheelX:a.deltaX=s;break;case zr.MouseWheelY:a.deltaY=s;break;case zr.MouseWheelZ:a.deltaZ=s}return a}static _CreateMouseEvent(e,t,i,s,r,n){const a=this._CreateEvent(n),o=r.pollInput(e,t,zr.Horizontal),h=r.pollInput(e,t,zr.Vertical);return n?(a.movementX=0,a.movementY=0,a.offsetX=a.movementX-n.getBoundingClientRect().x,a.offsetY=a.movementY-n.getBoundingClientRect().y):(a.movementX=r.pollInput(e,t,10),a.movementY=r.pollInput(e,t,11),a.offsetX=0,a.offsetY=0),this._CheckNonCharacterKeys(a,r),a.clientX=o,a.clientY=h,a.x=o,a.y=h,a.deviceType=e,a.deviceSlot=t,a.inputIndex=i,a}static _CreateKeyboardEvent(e,t,i,s){const r=this._CreateEvent(s);return this._CheckNonCharacterKeys(r,i),r.deviceType=Vr.Keyboard,r.deviceSlot=0,r.inputIndex=e,r.type=1===t?"keydown":"keyup",r.key=String.fromCharCode(e),r.keyCode=e,r}static _CheckNonCharacterKeys(e,t){const i=t.isDeviceAvailable(Vr.Keyboard),s=i&&1===t.pollInput(Vr.Keyboard,0,Ve.INPUT_ALT_KEY),r=i&&1===t.pollInput(Vr.Keyboard,0,Ve.INPUT_CTRL_KEY),n=i&&(1===t.pollInput(Vr.Keyboard,0,Ve.INPUT_META_KEY1)||1===t.pollInput(Vr.Keyboard,0,Ve.INPUT_META_KEY2)||1===t.pollInput(Vr.Keyboard,0,Ve.INPUT_META_KEY3)),a=i&&1===t.pollInput(Vr.Keyboard,0,Ve.INPUT_SHIFT_KEY);e.altKey=s,e.ctrlKey=r,e.metaKey=n,e.shiftKey=a}static _CreateEvent(e){const t={preventDefault:()=>{}};return t.target=e,t}}class Qr{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,((e,t,s,r)=>{const n=Xr.CreateDeviceEvent(e,t,s,r,this);i(e,t,n)})):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===Vr.Mouse||e===Vr.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const qr=Object.keys(zr).length/2;class jr{constructor(e,t,i,s){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=pi.IsSafari(),this._usingMacOS=ge()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=e=>{},this._keyboardUpEvent=e=>{},this._keyboardBlurEvent=e=>{},this._pointerMoveEvent=e=>{},this._pointerDownEvent=e=>{},this._pointerUpEvent=e=>{},this._pointerCancelEvent=e=>{},this._pointerWheelEvent=e=>{},this._pointerBlurEvent=e=>{},this._pointerMacOSChromeOutEvent=e=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=ge()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Firefox"),this._isUsingChromium=ge()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Chrome"),this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=e=>{},this._gamepadDisconnectedEvent=e=>{},this._eventPrefix=pi.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=i,this._onInputChanged=s,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOS&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,i){const s=this._inputs[e][t];if(!s)throw`Unable to find device ${Vr[e]}`;e>=Vr.DualShock&&e<=Vr.DualSense&&this._updateDevice(e,t,i);const r=s[i];if(void 0===r)throw`Unable to find input ${i} for device ${Vr[e]} in slot ${t}`;return i===zr.Move&&pi.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),r}isDeviceAvailable(e){return void 0!==this._inputs[e]}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){const e=this?._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs)for(const e of this._inputs)if(e)for(const t in e){const i=e[+t];if(i)for(let e=0;e<i.length;e++)i[e]=0}this._elementToAttachTo=e,this._elementToAttachTo.tabIndex=-1!==this._elementToAttachTo.tabIndex?this._elementToAttachTo.tabIndex:this._engine.canvasTabIndex,this._handleKeyActions(),this._handlePointerActions(),this._handleGamepadActions(),this._eventsAttached=!0,this._checkForConnectedDevices()}}_disableEvents(){this._elementToAttachTo&&(this._elementToAttachTo.removeEventListener("blur",this._keyboardBlurEvent),this._elementToAttachTo.removeEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.removeEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.removeEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.removeEventListener(this._wheelEventName,this._pointerWheelEvent),this._usingMacOS&&this._isUsingChromium&&this._elementToAttachTo.removeEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent),window.removeEventListener("gamepadconnected",this._gamepadConnectedEvent),window.removeEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)),this._pointerInputClearObserver&&this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver),this._eventsAttached=!1}_checkForConnectedDevices(){if(navigator.getGamepads){const e=navigator.getGamepads();for(const t of e)t&&this._addGamePad(t)}"function"==typeof matchMedia&&matchMedia("(pointer:fine)").matches&&this._addPointerDevice(Vr.Mouse,0,0,0)}_addGamePad(e){const t=this._getGamepadDeviceType(e.id),i=e.index;this._gamepads=this._gamepads||new Array(e.index+1),this._registerDevice(t,i,e.buttons.length+e.axes.length),this._gamepads[i]=t}_addPointerDevice(e,t,i,s){this._pointerActive||(this._pointerActive=!0),this._registerDevice(e,t,qr);const r=this._inputs[e][t];r[0]=i,r[1]=s}_registerDevice(e,t,i){if(void 0===t)throw`Unable to register device ${Vr[e]} to undefined slot.`;if(this._inputs[e]||(this._inputs[e]={}),!this._inputs[e][t]){const s=new Array(i);s.fill(0),this._inputs[e][t]=s,this._onDeviceConnected(e,t)}}_unregisterDevice(e,t){this._inputs[e][t]&&(delete this._inputs[e][t],this._onDeviceDisconnected(e,t))}_handleKeyActions(){this._keyboardDownEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Vr.Keyboard,0,255));const t=this._inputs[Vr.Keyboard][0];if(t){t[e.keyCode]=1;const i=e;i.inputIndex=e.keyCode,this._usingMacOS&&e.metaKey&&"Meta"!==e.key&&(this._metaKeys.includes(e.keyCode)||this._metaKeys.push(e.keyCode)),this._onInputChanged(Vr.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Vr.Keyboard,0,255));const t=this._inputs[Vr.Keyboard][0];if(t){t[e.keyCode]=0;const i=e;if(i.inputIndex=e.keyCode,this._usingMacOS&&"Meta"===e.key&&this._metaKeys.length>0){for(const e of this._metaKeys){const i=Xr.CreateDeviceEvent(Vr.Keyboard,0,e,0,this,this._elementToAttachTo);t[e]=0,this._onInputChanged(Vr.Keyboard,0,i)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(Vr.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[Vr.Keyboard][0];for(let t=0;t<e.length;t++)if(0!==e[t]){e[t]=0;const i=Xr.CreateDeviceEvent(Vr.Keyboard,0,t,0,this,this._elementToAttachTo);this._onInputChanged(Vr.Keyboard,0,i)}this._usingMacOS&&this._metaKeys.splice(0,this._metaKeys.length)}},this._elementToAttachTo.addEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.addEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.addEventListener("blur",this._keyboardBlurEvent)}_handlePointerActions(){this._maxTouchPoints=ge()&&navigator.maxTouchPoints||2,this._activeTouchIds||(this._activeTouchIds=new Array(this._maxTouchPoints));for(let e=0;e<this._maxTouchPoints;e++)this._activeTouchIds[e]=-1;this._pointerMoveEvent=e=>{const t=this._getPointerType(e);let i=t===Vr.Mouse?0:this._activeTouchIds.indexOf(e.pointerId);if(t===Vr.Touch&&-1===i){const s=this._activeTouchIds.indexOf(-1);if(!(s>=0))return void pi.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);i=s,this._activeTouchIds[s]=e.pointerId,this._onDeviceConnected(t,i)}this._inputs[t]||(this._inputs[t]={}),this._inputs[t][i]||this._addPointerDevice(t,i,e.clientX,e.clientY);const s=this._inputs[t][i];if(s){const r=e;r.inputIndex=zr.Move,s[zr.Horizontal]=e.clientX,s[zr.Vertical]=e.clientY,t===Vr.Touch&&0===s[zr.LeftClick]&&(s[zr.LeftClick]=1),void 0===e.pointerId&&(e.pointerId=this._mouseId),this._onInputChanged(t,i,r),this._usingSafari||-1===e.button||(r.inputIndex=e.button+2,s[e.button+2]=s[e.button+2]?0:1,this._onInputChanged(t,i,r))}},this._pointerDownEvent=e=>{const t=this._getPointerType(e);let i=t===Vr.Mouse?0:e.pointerId;if(t===Vr.Touch){let t=this._activeTouchIds.indexOf(e.pointerId);if(-1===t&&(t=this._activeTouchIds.indexOf(-1)),!(t>=0))return void pi.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);i=t,this._activeTouchIds[t]=e.pointerId}this._inputs[t]||(this._inputs[t]={}),this._inputs[t][i]?t===Vr.Touch&&this._onDeviceConnected(t,i):this._addPointerDevice(t,i,e.clientX,e.clientY);const s=this._inputs[t][i];if(s){const r=s[zr.Horizontal],n=s[zr.Vertical];if(t===Vr.Mouse){if(void 0===e.pointerId&&(e.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch(e){}}else if(e.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(e.pointerId)}catch(e){}s[zr.Horizontal]=e.clientX,s[zr.Vertical]=e.clientY,s[e.button+2]=1;const a=e;a.inputIndex=e.button+2,this._onInputChanged(t,i,a),r===e.clientX&&n===e.clientY||(a.inputIndex=zr.Move,this._onInputChanged(t,i,a))}},this._pointerUpEvent=e=>{const t=this._getPointerType(e),i=t===Vr.Mouse?0:this._activeTouchIds.indexOf(e.pointerId);if(t===Vr.Touch){if(-1===i)return;this._activeTouchIds[i]=-1}const s=this._inputs[t]?.[i];if(s&&0!==s[e.button+2]){const r=s[zr.Horizontal],n=s[zr.Vertical];s[zr.Horizontal]=e.clientX,s[zr.Vertical]=e.clientY,s[e.button+2]=0;const a=e;void 0===e.pointerId&&(e.pointerId=this._mouseId),r===e.clientX&&n===e.clientY||(a.inputIndex=zr.Move,this._onInputChanged(t,i,a)),a.inputIndex=e.button+2,t===Vr.Mouse&&this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)?this._elementToAttachTo.releasePointerCapture(this._mouseId):e.pointerId&&this._elementToAttachTo.hasPointerCapture?.(e.pointerId)&&this._elementToAttachTo.releasePointerCapture(e.pointerId),this._onInputChanged(t,i,a),t===Vr.Touch&&this._onDeviceDisconnected(t,i)}},this._pointerCancelEvent=e=>{if("mouse"===e.pointerType){const e=this._inputs[Vr.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let t=zr.LeftClick;t<=zr.BrowserForward;t++)if(1===e[t]){e[t]=0;const i=Xr.CreateDeviceEvent(Vr.Mouse,0,t,0,this,this._elementToAttachTo);this._onInputChanged(Vr.Mouse,0,i)}}else{const t=this._activeTouchIds.indexOf(e.pointerId);if(-1===t)return;this._elementToAttachTo.hasPointerCapture?.(e.pointerId)&&this._elementToAttachTo.releasePointerCapture(e.pointerId),this._inputs[Vr.Touch][t][zr.LeftClick]=0;const i=Xr.CreateDeviceEvent(Vr.Touch,t,zr.LeftClick,0,this,this._elementToAttachTo,e.pointerId);this._onInputChanged(Vr.Touch,t,i),this._activeTouchIds[t]=-1,this._onDeviceDisconnected(Vr.Touch,t)}},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";let e=!1;const t=function(){};try{const i=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,i),this._elementToAttachTo.removeEventListener("test",t,i)}catch(e){}this._pointerBlurEvent=()=>{if(this.isDeviceAvailable(Vr.Mouse)){const e=this._inputs[Vr.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let t=zr.LeftClick;t<=zr.BrowserForward;t++)if(1===e[t]){e[t]=0;const i=Xr.CreateDeviceEvent(Vr.Mouse,0,t,0,this,this._elementToAttachTo);this._onInputChanged(Vr.Mouse,0,i)}}if(this.isDeviceAvailable(Vr.Touch)){const e=this._inputs[Vr.Touch];for(let t=0;t<this._activeTouchIds.length;t++){const i=this._activeTouchIds[t];if(this._elementToAttachTo.hasPointerCapture?.(i)&&this._elementToAttachTo.releasePointerCapture(i),-1!==i&&1===e[t]?.[zr.LeftClick]){e[t][zr.LeftClick]=0;const s=Xr.CreateDeviceEvent(Vr.Touch,t,zr.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(Vr.Touch,t,s),this._activeTouchIds[t]=-1,this._onDeviceDisconnected(Vr.Touch,t)}}}},this._pointerWheelEvent=e=>{const t=Vr.Mouse;this._inputs[t]||(this._inputs[t]=[]),this._inputs[t][0]||(this._pointerActive=!0,this._registerDevice(t,0,qr));const i=this._inputs[t][0];if(i){i[zr.MouseWheelX]=e.deltaX||0,i[zr.MouseWheelY]=e.deltaY||e.wheelDelta||0,i[zr.MouseWheelZ]=e.deltaZ||0;const s=e;void 0===e.pointerId&&(e.pointerId=this._mouseId),0!==i[zr.MouseWheelX]&&(s.inputIndex=zr.MouseWheelX,this._onInputChanged(t,0,s)),0!==i[zr.MouseWheelY]&&(s.inputIndex=zr.MouseWheelY,this._onInputChanged(t,0,s)),0!==i[zr.MouseWheelZ]&&(s.inputIndex=zr.MouseWheelZ,this._onInputChanged(t,0,s))}},this._usingMacOS&&this._isUsingChromium&&(this._pointerMacOSChromeOutEvent=e=>{e.buttons>1&&this._pointerCancelEvent(e)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,!!e&&{passive:!1}),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add((()=>{if(this.isDeviceAvailable(Vr.Mouse)){const e=this._inputs[Vr.Mouse][0];e[zr.MouseWheelX]=0,e[zr.MouseWheelY]=0,e[zr.MouseWheelZ]=0}}))}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){const t=this._getGamepadDeviceType(e.gamepad.id),i=e.gamepad.index;this._unregisterDevice(t,i),delete this._gamepads[i]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)}_updateDevice(e,t,i){const s=navigator.getGamepads()[t];if(s&&e===this._gamepads[t]){const r=this._inputs[e][t];i>=s.buttons.length?r[i]=s.axes[i-s.buttons.length].valueOf():r[i]=s.buttons[i].value}}_getGamepadDeviceType(e){return-1!==e.indexOf("054c")?-1!==e.indexOf("0ce6")?Vr.DualSense:Vr.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?Vr.Xbox:-1!==e.indexOf("057e")?Vr.Switch:Vr.Generic}_getPointerType(e){let t=Vr.Mouse;return("touch"===e.pointerType||"pen"===e.pointerType||e.touches)&&(t=Vr.Touch),t}}class Zr{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new A,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}class Jr{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=e=>{for(let t=0;t<this._devices.length;t++){const i=this._devices[t];for(const s in i){const i=+s;e._addDevice(new Zr(this._deviceInputSystem,t,i))}}this._registeredManagers.push(e)},this.unregisterManager=e=>{const t=this._registeredManagers.indexOf(e);t>-1&&this._registeredManagers.splice(t,1)};const t=Object.keys(Vr).length/2;this._devices=new Array(t);const i=(e,t)=>{this._devices[e]||(this._devices[e]=new Array),this._devices[e][t]||(this._devices[e][t]=t);for(const i of this._registeredManagers){const s=new Zr(this._deviceInputSystem,e,t);i._addDevice(s)}},s=(e,t)=>{this._devices[e]?.[t]&&delete this._devices[e][t];for(const i of this._registeredManagers)i._removeDevice(e,t)},r=(e,t,i)=>{if(i)for(const s of this._registeredManagers)s._onInputChanged(e,t,i)};"undefined"!=typeof _native?this._deviceInputSystem=new Qr(i,s,r):this._deviceInputSystem=new jr(e,i,s,r)}dispose(){this._deviceInputSystem.dispose()}}class $r{getDeviceSource(e,t){if(void 0===t){if(void 0===this._firstDevice[e])return null;t=this._firstDevice[e]}return this._devices[e]&&void 0!==this._devices[e][t]?this._devices[e][t]:null}getDeviceSources(e){return this._devices[e]?this._devices[e].filter((e=>!!e)):[]}constructor(e){const t=Object.keys(Vr).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new Jr(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new A((e=>{for(const t of this._devices)if(t)for(const i of t)i&&this.onDeviceConnectedObservable.notifyObserver(e,i)})),this.onDeviceDisconnectedObservable=new A,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add((()=>{this.dispose()}))}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=new Array),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){const i=this._devices[e]?.[t];this.onDeviceDisconnectedObservable.notifyObservers(i),this._devices[e]?.[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){this._devices[e]?.[t]?.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case Vr.Keyboard:case Vr.Mouse:this._firstDevice[e]=0;break;case Vr.Touch:case Vr.DualSense:case Vr.DualShock:case Vr.Xbox:case Vr.Switch:case Vr.Generic:{delete this._firstDevice[e];const t=this._devices[e];if(t)for(let i=0;i<t.length;i++)if(t[i]){this._firstDevice[e]=i;break}break}}}}class en{}en._IsPickingAvailable=!1;class tn{constructor(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}get singleClick(){return this._singleClick}get doubleClick(){return this._doubleClick}get hasSwiped(){return this._hasSwiped}get ignore(){return this._ignore}set singleClick(e){this._singleClick=e}set doubleClick(e){this._doubleClick=e}set hasSwiped(e){this._hasSwiped=e}set ignore(e){this._ignore=e}}class sn{constructor(e){this._alreadyAttached=!1,this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._activePointerIds=new Array,this._activePointerIdsCount=0,this._doubleClickOccured=!1,this._isSwiping=!1,this._swipeButtonPressed=-1,this._skipPointerTap=!1,this._isMultiTouchGesture=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new Y(0,0),this._previousStartingPointerPosition=new Y(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId={},this._movePointerInfo=null,this._cameraObserverCount=0,this._delayedClicks=[null,null,null,null,null],this._deviceSourceManager=null,this._scene=e||O.LastCreatedScene,this._scene}get meshUnderPointer(){return this._movePointerInfo&&(this._movePointerInfo._generatePickInfo(),this._movePointerInfo=null),this._pointerOverMesh}getMeshUnderPointerByPointerId(e){return this._meshUnderPointerId[e]||null}get unTranslatedPointer(){return new Y(this._unTranslatedPointerX,this._unTranslatedPointerY)}get pointerX(){return this._pointerX}set pointerX(e){this._pointerX=e}get pointerY(){return this._pointerY}set pointerY(e){this._pointerY=e}_updatePointerPosition(e){const t=this._scene.getEngine().getInputElementClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)}_processPointerMove(e,t){const i=this._scene,s=i.getEngine(),r=s.getInputElement();r&&(r.tabIndex=s.canvasTabIndex,i.doNotHandleCursors||(r.style.cursor=i.defaultCursor)),this._setCursorAndPointerOverMesh(e,t,i);for(const s of i._pointerMoveStage){e=e||this._pickMove(t);const i=!!e?.pickedMesh;e=s.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,i,r)}const n=t.inputIndex>=zr.MouseWheelX&&t.inputIndex<=zr.MouseWheelZ?qs.POINTERWHEEL:qs.POINTERMOVE;let a;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,n)),e?(a=new Js(n,t,e),this._setRayOnPointerInfo(e,t)):(a=new Js(n,t,null,this),this._movePointerInfo=a),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(a,n)}_setRayOnPointerInfo(e,t){const i=this._scene;e&&en._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,j.Identity(),i.activeCamera)))}_addCameraPointerObserver(e,t){return this._cameraObserverCount++,this._scene.onPointerObservable.add(e,t)}_removeCameraPointerObserver(e){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(e)}_checkForPicking(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)}_checkPrePointerObservable(e,t,i){const s=this._scene,r=new Zs(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.originalPickingInfo=e,r.ray=e.ray,"xr-near"===t.pointerType&&e.originMesh&&(r.nearInteractionPickingInfo=e)),s.onPrePointerObservable.notifyObservers(r,i),!!r.skipOnPointerObservable}_pickMove(e){const t=this._scene,i=t.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,t.pointerMovePredicate,t.pointerMoveFastCheck,t.cameraToUseForPointers,t.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(i,e,t),i}_setCursorAndPointerOverMesh(e,t,i){const s=i.getEngine().getInputElement();if(e?.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&s&&this._pointerOverMesh){const e=this._pointerOverMesh._getActionManagerForTrigger();e&&e.hasPointerTriggers&&(s.style.cursor=e.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){const i=new PointerEvent("pointermove",t);i.inputIndex=zr.Move,this._checkPrePointerObservable(e,i,qs.POINTERMOVE)||this._processPointerMove(e,i)}simulatePointerDown(e,t){const i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,this._checkPrePointerObservable(e,i,qs.POINTERDOWN)||this._processPointerDown(e,i)}_processPointerDown(e,t){const i=this._scene;if(e?.pickedMesh){this._pickedDownMesh=e.pickedMesh;const s=e.pickedMesh._getActionManagerForTrigger();if(s){if(s.hasPickTriggers)switch(s.processTrigger(Ve.ACTION_OnPickDownTrigger,Fr.CreateNew(e.pickedMesh,t,e)),t.button){case 0:s.processTrigger(Ve.ACTION_OnLeftPickTrigger,Fr.CreateNew(e.pickedMesh,t,e));break;case 1:s.processTrigger(Ve.ACTION_OnCenterPickTrigger,Fr.CreateNew(e.pickedMesh,t,e));break;case 2:s.processTrigger(Ve.ACTION_OnRightPickTrigger,Fr.CreateNew(e.pickedMesh,t,e))}s.hasSpecificTrigger(Ve.ACTION_OnLongPressTrigger)&&window.setTimeout((()=>{const e=i.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,(e=>e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(Ve.ACTION_OnLongPressTrigger)&&e===this._pickedDownMesh),!1,i.cameraToUseForPointers);e?.pickedMesh&&s&&0!==this._activePointerIdsCount&&Date.now()-this._startingPointerTime>sn.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,s.processTrigger(Ve.ACTION_OnLongPressTrigger,Fr.CreateNew(e.pickedMesh,t)))}),sn.LongPressDelay)}}else for(const s of i._pointerDownStage)e=s.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let s;const r=qs.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,r),s=new Js(r,t,e),this._setRayOnPointerInfo(e,t)):s=new Js(r,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(s,r)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){const s=new PointerEvent("pointerup",t);s.inputIndex=zr.Move;const r=new tn;i?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,s,qs.POINTERUP)||this._processPointerUp(e,s,r)}_processPointerUp(e,t,i){const s=this._scene;if(e?.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(s.onPointerPick&&s.onPointerPick(t,e),i.singleClick&&!i.ignore&&s.onPointerObservable.observers.length>this._cameraObserverCount)){const i=qs.POINTERPICK,r=new Js(i,t,e);this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(r,i)}const r=e.pickedMesh._getActionManagerForTrigger();if(r&&!i.ignore){r.processTrigger(Ve.ACTION_OnPickUpTrigger,Fr.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&r.processTrigger(Ve.ACTION_OnPickTrigger,Fr.CreateNew(e.pickedMesh,t,e));const s=e.pickedMesh._getActionManagerForTrigger(Ve.ACTION_OnDoublePickTrigger);i.doubleClick&&s&&s.processTrigger(Ve.ACTION_OnDoublePickTrigger,Fr.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(const r of s._pointerUpStage)e=r.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){const e=this._pickedDownMesh._getActionManagerForTrigger(Ve.ACTION_OnPickOutTrigger);e&&e.processTrigger(Ve.ACTION_OnPickOutTrigger,Fr.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){const r=new Js(qs.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(r,qs.POINTERUP),s.onPointerUp&&s.onPointerUp(t,e,qs.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let r=0;if(i.singleClick?r=qs.POINTERTAP:i.doubleClick&&(r=qs.POINTERDOUBLETAP),r){const i=new Js(r,t,e);s.onPointerObservable.hasObservers()&&s.onPointerObservable.hasSpecificMask(r)&&s.onPointerObservable.notifyObservers(i,r)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,i=!0,s=null){const r=this._scene,n=r.getEngine();s||(s=n.getInputElement()),this._alreadyAttached&&this.detachControl(),s&&(this._alreadyAttachedTo=s),this._deviceSourceManager=new $r(n),this._initActionManager=e=>{if(!this._meshPickProceed){const t=r.skipPointerUpPicking||0===r._registeredActions&&!this._checkForPicking()&&!r.onPointerUp?null:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerUpPredicate,r.pointerUpFastCheck,r.cameraToUseForPointers,r.pointerUpTrianglePredicate);this._currentPickResult=t,t&&(e=t.hit&&t.pickedMesh?t.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return e},this._delayedSimpleClick=(e,t,i)=>{if((Date.now()-this._previousStartingPointerTime>sn.DoubleClickDelay&&!this._doubleClickOccured||e!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,this._delayedClicks[e])){const t=this._delayedClicks[e].evt,i=qs.POINTERTAP,s=new Js(i,t,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(i)&&r.onPointerObservable.notifyObservers(s,i),this._delayedClicks[e]=null}},this._initClickEvent=(e,t,i,s)=>{const r=new tn;this._currentPickResult=null;let n=null,a=e.hasSpecificMask(qs.POINTERPICK)||t.hasSpecificMask(qs.POINTERPICK)||e.hasSpecificMask(qs.POINTERTAP)||t.hasSpecificMask(qs.POINTERTAP)||e.hasSpecificMask(qs.POINTERDOUBLETAP)||t.hasSpecificMask(qs.POINTERDOUBLETAP);!a&&kr&&(n=this._initActionManager(n,r),n&&(a=n.hasPickTriggers));let o=!1;if(a=a&&!this._isMultiTouchGesture,a){const a=i.button;if(r.hasSwiped=this._isPointerSwiping(),!r.hasSwiped){let h=!sn.ExclusiveDoubleClickMode;if(h||(h=!e.hasSpecificMask(qs.POINTERDOUBLETAP)&&!t.hasSpecificMask(qs.POINTERDOUBLETAP),h&&!kr.HasSpecificTrigger(Ve.ACTION_OnDoublePickTrigger)&&(n=this._initActionManager(n,r),n&&(h=!n.hasSpecificTrigger(Ve.ACTION_OnDoublePickTrigger)))),h)(Date.now()-this._previousStartingPointerTime>sn.DoubleClickDelay||a!==this._previousButtonPressed)&&(r.singleClick=!0,s(r,this._currentPickResult),o=!0);else{const e={evt:i,clickInfo:r,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,a,r,s),sn.DoubleClickDelay)};this._delayedClicks[a]=e}let l=e.hasSpecificMask(qs.POINTERDOUBLETAP)||t.hasSpecificMask(qs.POINTERDOUBLETAP);!l&&kr.HasSpecificTrigger(Ve.ACTION_OnDoublePickTrigger)&&(n=this._initActionManager(n,r),n&&(l=n.hasSpecificTrigger(Ve.ACTION_OnDoublePickTrigger))),l&&(a===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime<sn.DoubleClickDelay&&!this._doubleClickOccured?(r.hasSwiped||this._isPointerSwiping()?(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=a,sn.ExclusiveDoubleClickMode?(this._delayedClicks[a]&&(clearTimeout(this._delayedClicks[a]?.timeoutId),this._delayedClicks[a]=null),s(r,this._previousPickResult)):s(r,this._currentPickResult)):(this._previousStartingPointerTime=0,this._doubleClickOccured=!0,r.doubleClick=!0,r.ignore=!1,sn.ExclusiveDoubleClickMode&&this._delayedClicks[a]&&(clearTimeout(this._delayedClicks[a]?.timeoutId),this._delayedClicks[a]=null),s(r,this._currentPickResult)),o=!0):(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=a))}}o||s(r,this._currentPickResult)},this._onPointerMove=e=>{if(this._updatePointerPosition(e),this._isSwiping||-1===this._swipeButtonPressed||(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>sn.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>sn.DragMovementThreshold),n.isPointerLock&&n._verifyPointerLock(),this._checkPrePointerObservable(null,e,e.inputIndex>=zr.MouseWheelX&&e.inputIndex<=zr.MouseWheelZ?qs.POINTERWHEEL:qs.POINTERMOVE))return;if(!r.cameraToUseForPointers&&!r.activeCamera)return;if(r.skipPointerMovePicking)return void this._processPointerMove(new ss,e);r.pointerMovePredicate||(r.pointerMovePredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||r.constantlyUpdateMeshUnderPointer||null!==e._getActionManagerForTrigger())&&(!r.cameraToUseForPointers||!!(r.cameraToUseForPointers.layerMask&e.layerMask)));const t=r._registeredActions>0||r.constantlyUpdateMeshUnderPointer?this._pickMove(e):null;this._processPointerMove(t,e)},this._onPointerDown=e=>{const t=this._activePointerIds.indexOf(-1);if(-1===t?this._activePointerIds.push(e.pointerId):this._activePointerIds[t]=e.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,sn.ExclusiveDoubleClickMode)for(let t=0;t<this._delayedClicks.length;t++)if(this._delayedClicks[t])if(e.button===t)clearTimeout(this._delayedClicks[t]?.timeoutId);else{const e=this._delayedClicks[t].clickInfo;this._doubleClickOccured=!1,e.singleClick=!0,e.ignore=!1;const i=this._delayedClicks[t].evt,s=qs.POINTERTAP,n=new Js(s,i,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(s)&&r.onPointerObservable.notifyObservers(n,s),this._delayedClicks[t]=null}if(this._updatePointerPosition(e),-1===this._swipeButtonPressed&&(this._swipeButtonPressed=e.button),r.preventDefaultOnPointerDown&&s&&(e.preventDefault(),s.focus()),this._startingPointerPosition.x=this._pointerX,this._startingPointerPosition.y=this._pointerY,this._startingPointerTime=Date.now(),this._checkPrePointerObservable(null,e,qs.POINTERDOWN))return;if(!r.cameraToUseForPointers&&!r.activeCamera)return;let i;this._pointerCaptures[e.pointerId]=!0,r.pointerDownPredicate||(r.pointerDownPredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!r.cameraToUseForPointers||!!(r.cameraToUseForPointers.layerMask&e.layerMask))),this._pickedDownMesh=null,i=r.skipPointerDownPicking||0===r._registeredActions&&!this._checkForPicking()&&!r.onPointerDown?new ss:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerDownPredicate,r.pointerDownFastCheck,r.cameraToUseForPointers,r.pointerDownTrianglePredicate),this._processPointerDown(i,e)},this._onPointerUp=e=>{const t=this._activePointerIds.indexOf(e.pointerId);-1!==t&&(this._activePointerIds[t]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(e),r.preventDefaultOnPointerUp&&s&&(e.preventDefault(),s.focus()),this._initClickEvent(r.onPrePointerObservable,r.onPointerObservable,e,((t,i)=>{if(r.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!t.ignore)){if(this._checkPrePointerObservable(null,e,qs.POINTERUP))return this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),void(0===e.buttons&&(this._pointerCaptures[e.pointerId]=!1));t.hasSwiped||(t.singleClick&&r.onPrePointerObservable.hasSpecificMask(qs.POINTERTAP)&&this._checkPrePointerObservable(null,e,qs.POINTERTAP)&&(this._skipPointerTap=!0),t.doubleClick&&r.onPrePointerObservable.hasSpecificMask(qs.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,e,qs.POINTERDOUBLETAP)&&(this._skipPointerTap=!0))}this._pointerCaptures[e.pointerId]?(0===e.buttons&&(this._pointerCaptures[e.pointerId]=!1),(r.cameraToUseForPointers||r.activeCamera)&&(r.pointerUpPredicate||(r.pointerUpPredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!r.cameraToUseForPointers||!!(r.cameraToUseForPointers.layerMask&e.layerMask))),!this._meshPickProceed&&(kr&&kr.HasTriggers||this._checkForPicking()||r.onPointerUp)&&this._initActionManager(null,t),i||(i=this._currentPickResult),this._processPointerUp(i,e,t),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))):this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1)})))},this._onKeyDown=e=>{const t=Er.KEYDOWN;if(r.onPreKeyboardObservable.hasObservers()){const i=new Rr(t,e);if(r.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const i=new br(t,e);r.onKeyboardObservable.notifyObservers(i,t)}r.actionManager&&r.actionManager.processTrigger(Ve.ACTION_OnKeyDownTrigger,Fr.CreateNewFromScene(r,e))},this._onKeyUp=e=>{const t=Er.KEYUP;if(r.onPreKeyboardObservable.hasObservers()){const i=new Rr(t,e);if(r.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const i=new br(t,e);r.onKeyboardObservable.notifyObservers(i,t)}r.actionManager&&r.actionManager.processTrigger(Ve.ACTION_OnKeyUpTrigger,Fr.CreateNewFromScene(r,e))},this._deviceSourceManager.onDeviceConnectedObservable.add((s=>{s.deviceType===Vr.Mouse?s.onInputChangedObservable.add((r=>{this._originMouseEvent=r,r.inputIndex===zr.LeftClick||r.inputIndex===zr.MiddleClick||r.inputIndex===zr.RightClick||r.inputIndex===zr.BrowserBack||r.inputIndex===zr.BrowserForward?t&&1===s.getInput(r.inputIndex)?this._onPointerDown(r):e&&0===s.getInput(r.inputIndex)&&this._onPointerUp(r):i&&(r.inputIndex===zr.Move?this._onPointerMove(r):r.inputIndex!==zr.MouseWheelX&&r.inputIndex!==zr.MouseWheelY&&r.inputIndex!==zr.MouseWheelZ||this._onPointerMove(r))})):s.deviceType===Vr.Touch?s.onInputChangedObservable.add((r=>{r.inputIndex===zr.LeftClick&&(t&&1===s.getInput(r.inputIndex)?(this._onPointerDown(r),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&0===s.getInput(r.inputIndex)&&(this._onPointerUp(r),0===this._activePointerIdsCount&&(this._isMultiTouchGesture=!1))),i&&r.inputIndex===zr.Move&&this._onPointerMove(r)})):s.deviceType===Vr.Keyboard&&s.onInputChangedObservable.add((e=>{"keydown"===e.type?this._onKeyDown(e):"keyup"===e.type&&this._onKeyUp(e)}))})),this._alreadyAttached=!0}detachControl(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)}setPointerOverMesh(e,t=0,i,s){if(!(this._meshUnderPointerId[t]!==e||e&&e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;const r=this._meshUnderPointerId[t];let n;r&&(n=r._getActionManagerForTrigger(Ve.ACTION_OnPointerOutTrigger),n&&n.processTrigger(Ve.ACTION_OnPointerOutTrigger,Fr.CreateNew(r,s,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,n=e._getActionManagerForTrigger(Ve.ACTION_OnPointerOverTrigger),n&&n.processTrigger(Ve.ACTION_OnPointerOverTrigger,Fr.CreateNew(e,s,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null),this._scene.onMeshUnderPointerUpdatedObservable.hasObservers()&&this._scene.onMeshUnderPointerUpdatedObservable.notifyObservers({mesh:e,pointerId:t})}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(const t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}}sn.DragMovementThreshold=10,sn.LongPressDelay=500,sn.DoubleClickDelay=300,sn.ExclusiveDoubleClickMode=!1;class rn{get min(){return this._min}get max(){return this._max}get average(){return this._average}get lastSecAverage(){return this._lastSecAverage}get current(){return this._current}get total(){return this._totalAccumulated}get count(){return this._totalValueCount}constructor(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}fetchNewFrame(){this._totalValueCount++,this._current=0,this._lastSecValueCount++}addCount(e,t){rn.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){rn.Enabled&&(this._startMonitoringTime=Re.Now)}endMonitoring(e=!0){if(!rn.Enabled)return;e&&this.fetchNewFrame();const t=Re.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()}endFrame(){this._fetchResult()}_fetchResult(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;const e=Re.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}rn.Enabled=!0;class nn{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}nn._UniqueIdCounter=1;class an{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}var on,hn;!function(e){e[e.BackwardCompatible=0]="BackwardCompatible",e[e.Intermediate=1]="Intermediate",e[e.Aggressive=2]="Aggressive"}(on||(on={}));class ln{static DefaultMaterialFactory(e){throw te("StandardMaterial")}static CollisionCoordinatorFactory(){throw te("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_MiscDirtyFlag))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_MiscDirtyFlag))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.onEnvironmentTextureChangedObservable.notifyObservers(e),this.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}getNodes(){let e=[];return e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes),this.skeletons.forEach((t=>e=e.concat(t.bones))),e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return sn.DragMovementThreshold}static set DragMovementThreshold(e){sn.DragMovementThreshold=e}static get LongPressDelay(){return sn.LongPressDelay}static set LongPressDelay(e){sn.LongPressDelay=e}static get DoubleClickDelay(){return sn.DoubleClickDelay}static set DoubleClickDelay(e){sn.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return sn.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){sn.ExclusiveDoubleClickMode=e}bindEyePosition(e,t="vEyePosition",i=!1){const s=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera?.globalPosition??X.ZeroReadOnly,r=this.useRightHandedSystem===(null!=this._mirroredCameraPosition);return J.Vector4[0].set(s.x,s.y,s.z,r?-1:1),e&&(i?e.setFloat3(t,J.Vector4[0].x,J.Vector4[0].y,J.Vector4[0].z):e.setVector4(t,J.Vector4[0])),J.Vector4[0]}finalizeSceneUbo(){const e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null);return e.updateFloat4("vEyePosition",t.x,t.y,t.z,t.w),e.update(),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_MiscDirtyFlag))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_MiscDirtyFlag))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_LightDirtyFlag))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_LightDirtyFlag))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=v(e,(()=>{this.onActiveCamerasChanged.notifyObservers(this)}))),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=ln.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph)return this._frameGraph=e,void(e||(this.customRenderFunction=this._currentCustomRenderFunction));this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(Ve.MATERIAL_AttributesDirtyFlag))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=ln.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(const e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);const t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(const t of this._components)if(t.name===e)return t;return null}constructor(e,t){this._inputManager=new sn(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new le(.2,.2,.3,1),this.onClearColorChangedObservable=new A,this.ambientColor=new he(0,0,0),this.environmentIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new A,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new A,this._onDisposeObserver=null,this.onBeforeRenderObservable=new A,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new A,this.onAfterRenderCameraObservable=new A,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new A,this.onAfterAnimationsObservable=new A,this.onBeforeDrawPhaseObservable=new A,this.onAfterDrawPhaseObservable=new A,this.onReadyObservable=new A,this.onBeforeCameraRenderObservable=new A,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new A,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new A,this.onAfterActiveMeshesEvaluationObservable=new A,this.onBeforeParticlesRenderingObservable=new A,this.onAfterParticlesRenderingObservable=new A,this.onDataLoadedObservable=new A,this.onNewCameraAddedObservable=new A,this.onCameraRemovedObservable=new A,this.onNewLightAddedObservable=new A,this.onLightRemovedObservable=new A,this.onNewGeometryAddedObservable=new A,this.onGeometryRemovedObservable=new A,this.onNewTransformNodeAddedObservable=new A,this.onTransformNodeRemovedObservable=new A,this.onNewMeshAddedObservable=new A,this.onMeshRemovedObservable=new A,this.onNewSkeletonAddedObservable=new A,this.onSkeletonRemovedObservable=new A,this.onNewMaterialAddedObservable=new A,this.onNewMultiMaterialAddedObservable=new A,this.onMaterialRemovedObservable=new A,this.onMultiMaterialRemovedObservable=new A,this.onNewTextureAddedObservable=new A,this.onTextureRemovedObservable=new A,this.onBeforeRenderTargetsRenderObservable=new A,this.onAfterRenderTargetsRenderObservable=new A,this.onBeforeStepObservable=new A,this.onAfterStepObservable=new A,this.onActiveCameraChanged=new A,this.onActiveCamerasChanged=new A,this.onBeforeRenderingGroupObservable=new A,this.onAfterRenderingGroupObservable=new A,this.onMeshImportedObservable=new A,this.onAnimationFileImportedObservable=new A,this.onEnvironmentTextureChangedObservable=new A,this.onMeshUnderPointerUpdatedObservable=new A,this._registeredForLateAnimationBindings=new yi(256),this._pointerPickingConfiguration=new an,this.onPrePointerObservable=new A,this.onPointerObservable=new A,this.onPreKeyboardObservable=new A,this.onKeyboardObservable=new A,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=ln.FOGMODE_NONE,this.fogColor=new he(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new X(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new yi(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new rn,this._activeIndices=new rn,this._activeParticles=new rn,this._activeBones=new rn,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=new Array,this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new Ri(256),this._processedMaterials=new Ri(256),this._renderTargets=new yi(256),this._materialsRenderTargets=new yi(256),this._activeParticleSystems=new Ri(256),this._activeSkeletons=new yi(32),this._softwareSkinnedMeshes=new yi(32),this._activeAnimatables=new Array,this._transformMatrix=j.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=Gs.Create(),this._beforeClearStage=Gs.Create(),this._beforeRenderTargetClearStage=Gs.Create(),this._gatherRenderTargetsStage=Gs.Create(),this._gatherActiveCameraRenderTargetsStage=Gs.Create(),this._isReadyForMeshStage=Gs.Create(),this._beforeEvaluateActiveMeshStage=Gs.Create(),this._evaluateSubMeshStage=Gs.Create(),this._preActiveMeshStage=Gs.Create(),this._cameraDrawRenderTargetStage=Gs.Create(),this._beforeCameraDrawStage=Gs.Create(),this._beforeRenderTargetDrawStage=Gs.Create(),this._beforeRenderingGroupDrawStage=Gs.Create(),this._beforeRenderingMeshStage=Gs.Create(),this._afterRenderingMeshStage=Gs.Create(),this._afterRenderingGroupDrawStage=Gs.Create(),this._afterCameraDrawStage=Gs.Create(),this._afterCameraPostProcessStage=Gs.Create(),this._afterRenderTargetDrawStage=Gs.Create(),this._afterRenderTargetPostProcessStage=Gs.Create(),this._afterRenderStage=Gs.Create(),this._pointerMoveStage=Gs.Create(),this._pointerDownStage=Gs.Create(),this._pointerUpStage=Gs.Create(),this._geometriesByUniqueId=null,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[];const i={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,...t};e=this._engine=e||O.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(O._LastCreatedScene=this,e.scenes.push(this)),this._uid=null,this._renderingManager=new Ur(this),wr&&(this.postProcessManager=new wr(this)),pe()&&this.attachControl(),this._createUbo(),Lr&&(this._imageProcessingConfiguration=new Lr),this.setDefaultCandidateProviders(),i.useGeometryUniqueIdsMap&&(this._geometriesByUniqueId={}),this.useMaterialMeshMap=i.useMaterialMeshMap,this.useClonedMeshMap=i.useClonedMeshMap,t&&t.virtual||e.onNewSceneAddedObservable.notifyObservers(this)}getClassName(){return"Scene"}_getDefaultMeshCandidates(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates}_getDefaultSubMeshCandidates(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates}setDefaultCandidateProviders(){this.getActiveMeshCandidates=()=>this._getDefaultMeshCandidates(),this.getActiveSubMeshCandidates=e=>this._getDefaultSubMeshCandidates(e),this.getIntersectingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e),this.getCollidingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e)}get meshUnderPointer(){return this._inputManager.meshUnderPointer}get pointerX(){return this._inputManager.pointerX}set pointerX(e){this._inputManager.pointerX=e}get pointerY(){return this._inputManager.pointerY}set pointerY(e){this._inputManager.pointerY=e}getCachedMaterial(){return this._cachedMaterial}getCachedEffect(){return this._cachedEffect}getCachedVisibility(){return this._cachedVisibility}isCachedMaterialInvalid(e,t,i=1){return this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i}getEngine(){return this._engine}getTotalVertices(){return this._totalVertices.current}get totalVerticesPerfCounter(){return this._totalVertices}getActiveIndices(){return this._activeIndices.current}get totalActiveIndicesPerfCounter(){return this._activeIndices}getActiveParticles(){return this._activeParticles.current}get activeParticlesPerfCounter(){return this._activeParticles}getActiveBones(){return this._activeBones.current}get activeBonesPerfCounter(){return this._activeBones}getActiveMeshes(){return this._activeMeshes}getAnimationRatio(){return void 0!==this._animationRatio?this._animationRatio:1}getRenderId(){return this._renderId}getFrameId(){return this._frameId}incrementRenderId(){this._renderId++}_createUbo(){this.setSceneUniformBuffer(this.createSceneUniformBuffer())}simulatePointerMove(e,t){return this._inputManager.simulatePointerMove(e,t),this}simulatePointerDown(e,t){return this._inputManager.simulatePointerDown(e,t),this}simulatePointerUp(e,t,i){return this._inputManager.simulatePointerUp(e,t,i),this}isPointerCaptured(e=0){return this._inputManager.isPointerCaptured(e)}attachControl(e=!0,t=!0,i=!0){this._inputManager.attachControl(e,t,i)}detachControl(){this._inputManager.detachControl()}isReady(e=!0){if(this._isDisposed)return!1;let t;const i=this.getEngine(),s=i.currentRenderPassId;i.currentRenderPassId=this.activeCamera?.renderPassId??s;let r=!0;for(this._pendingData.length>0&&(r=!1),this.prePassRenderer?.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&(r&&=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t<this.meshes.length;t++){const s=this.meshes[t];if(!s.subMeshes||0===s.subMeshes.length)continue;if(!s.isReady(!0)){r=!1;continue}const n=s.hasThinInstances||"InstancedMesh"===s.getClassName()||"InstancedLinesMesh"===s.getClassName()||i.getCaps().instancedArrays&&s.instances.length>0;for(const e of this._isReadyForMeshStage)e.action(s,n)||(r=!1);if(!e)continue;const a=s.material||this.defaultMaterial;if(a)if(a._storeEffectOnSubMeshes)for(const e of s.subMeshes){const t=e.getMaterial();t&&t.hasRenderTargetTextures&&null!=t.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(t)&&(this._processedMaterials.push(t),this._materialsRenderTargets.concatWithNoDuplicate(t.getRenderTargetTextures()))}else a.hasRenderTargetTextures&&null!=a.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(a)&&(this._processedMaterials.push(a),this._materialsRenderTargets.concatWithNoDuplicate(a.getRenderTargetTextures()))}if(e)for(t=0;t<this._materialsRenderTargets.length;++t){this._materialsRenderTargets.data[t].isReadyForRendering()||(r=!1)}for(t=0;t<this.geometries.length;t++){this.geometries[t].delayLoadState===Ve.DELAYLOADSTATE_LOADING&&(r=!1)}if(this.activeCameras&&this.activeCameras.length>0)for(const e of this.activeCameras)e.isReady(!0)||(r=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(r=!1));for(const e of this.particleSystems)e.isReady()||(r=!1);if(this.layers)for(const e of this.layers)e.isReady()||(r=!1);return i.areAllEffectsReady()||(r=!1),i.currentRenderPassId=s,r}resetCachedMaterial(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null}registerBeforeRender(e){this.onBeforeRenderObservable.add(e)}unregisterBeforeRender(e){this.onBeforeRenderObservable.removeCallback(e)}registerAfterRender(e){this.onAfterRenderObservable.add(e)}unregisterAfterRender(e){this.onAfterRenderObservable.removeCallback(e)}_executeOnceBeforeRender(e){const t=()=>{e(),setTimeout((()=>{this.unregisterBeforeRender(t)}))};this.registerBeforeRender(t)}executeOnceBeforeRender(e,t){void 0!==t?setTimeout((()=>{this._executeOnceBeforeRender(e)}),t):this._executeOnceBeforeRender(e)}addPendingData(e){this._pendingData.push(e)}removePendingData(e){const t=this.isLoading,i=this._pendingData.indexOf(e);-1!==i&&this._pendingData.splice(i,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)}getWaitingItemsCount(){return this._pendingData.length}get isLoading(){return this._pendingData.length>0}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),null===this._executeWhenReadyTimeoutId&&this._checkIsReady(t)}whenReadyAsync(e=!1){return new Promise((t=>{this.executeWhenReady((()=>{t()}),e)}))}_checkIsReady(e=!1){return this._registerTransientComponents(),this.isReady(e)?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):void(this._executeWhenReadyTimeoutId=setTimeout((()=>{this.incrementRenderId(),this._checkIsReady(e)}),100))}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=Re.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,i,s){i||s||!this._multiviewSceneUbo||(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?vi.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=vi.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,s):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e){const t=new rs(this._engine,void 0,!1,e??"scene");return t.addUniform("viewProjection",16),t.addUniform("view",16),t.addUniform("projection",16),t.addUniform("vEyePosition",4),t}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}getUniqueId(){return nn.UniqueId}addMesh(e,t=!1){this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),pi.SetImmediate((()=>{this.onNewMeshAddedObservable.notifyObservers(e)})),t&&e.getChildMeshes().forEach((e=>{this.addMesh(e)})))}removeMesh(e,t=!1){const i=this.meshes.indexOf(e);return-1!==i&&(this.meshes.splice(i,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((e=>{this.removeMesh(e)})),i}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneTransformNodesArray||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){const t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){const e=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=e,e._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t}removeSkeleton(e){const t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){const t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t}removeLight(e){const t=this.lights.indexOf(e);if(-1!==t){for(const t of this.meshes)t._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(e),t}removeCamera(e){const t=this.cameras.indexOf(e);if(-1!==t&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){const t=this.activeCameras.indexOf(e);-1!==t&&this.activeCameras.splice(t,1)}return this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t}removeParticleSystem(e){const t=this.particleSystems.indexOf(e);return-1!==t&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),t}removeAnimation(e){const t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t}stopAnimation(e,t,i){}removeAnimationGroup(e){const t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t}removeMultiMaterial(e){const t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){const t=e._indexInSceneMaterialArray;if(-1!==t&&t<this.materials.length){if(t!==this.materials.length-1){const e=this.materials[this.materials.length-1];this.materials[t]=e,e._indexInSceneMaterialArray=t}e._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(e),t}removeActionManager(e){const t=this.actionManagers.indexOf(e);return-1!==t&&this.actionManagers.splice(t,1),t}removeTexture(e){const t=this.textures.indexOf(e);return-1!==t&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t}addLight(e){if(!this._blockEntityCollection){this.lights.push(e),this.sortLightsByPriority(),e.parent||e._addToSceneRootNodes();for(const t of this.meshes)-1===t.lightSources.indexOf(e)&&(t.lightSources.push(e),t._resyncLightSources());pi.SetImmediate((()=>{this.onNewLightAddedObservable.notifyObservers(e)}))}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(us.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),pi.SetImmediate((()=>{this.onNewCameraAddedObservable.notifyObservers(e)})),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),pi.SetImmediate((()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)})))}addParticleSystem(e){this._blockEntityCollection||this.particleSystems.push(e)}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||this.animationGroups.push(e)}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),pi.SetImmediate((()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)})))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneMaterialArray||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),pi.SetImmediate((()=>{this.onNewMaterialAddedObservable.notifyObservers(e)})))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){const t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){const t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;t<this.animationGroups.length;t++)if(this.animationGroups[t].name===e)return this.animationGroups[t];return null}_getMaterial(e,t){for(let e=0;e<this.materials.length;e++){const i=this.materials[e];if(t(i))return i}if(e)for(let e=0;e<this.multiMaterials.length;e++){const i=this.multiMaterials[e];if(t(i))return i}return null}getMaterialByUniqueID(e,t=!1){return this._getMaterial(t,(t=>t.uniqueId===e))}getMaterialById(e,t=!1){return this._getMaterial(t,(t=>t.id===e))}getMaterialByName(e,t=!1){return this._getMaterial(t,(t=>t.name===e))}getLastMaterialById(e,t=!1){for(let t=this.materials.length-1;t>=0;t--)if(this.materials[t].id===e)return this.materials[t];if(t)for(let t=this.multiMaterials.length-1;t>=0;t--)if(this.multiMaterials[t].id===e)return this.multiMaterials[t];return null}getTextureByUniqueId(e){for(let t=0;t<this.textures.length;t++)if(this.textures[t].uniqueId===e)return this.textures[t];return null}getTextureByName(e){for(let t=0;t<this.textures.length;t++)if(this.textures[t].name===e)return this.textures[t];return null}getCameraById(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null}getCameraByUniqueId(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null}getCameraByName(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null}getBoneById(e){for(let t=0;t<this.skeletons.length;t++){const i=this.skeletons[t];for(let t=0;t<i.bones.length;t++)if(i.bones[t].id===e)return i.bones[t]}return null}getBoneByName(e){for(let t=0;t<this.skeletons.length;t++){const i=this.skeletons[t];for(let t=0;t<i.bones.length;t++)if(i.bones[t].name===e)return i.bones[t]}return null}getLightByName(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null}getLightById(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null}getLightByUniqueId(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null}getParticleSystemById(e){for(let t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null}getGeometryById(e){for(let t=0;t<this.geometries.length;t++)if(this.geometries[t].id===e)return this.geometries[t];return null}_getGeometryByUniqueId(e){if(this._geometriesByUniqueId){const t=this._geometriesByUniqueId[e];if(void 0!==t)return this.geometries[t]}else for(let t=0;t<this.geometries.length;t++)if(this.geometries[t].uniqueId===e)return this.geometries[t];return null}pushGeometry(e,t){return!(!t&&this._getGeometryByUniqueId(e.uniqueId))&&(this.addGeometry(e),pi.SetImmediate((()=>{this.onNewGeometryAddedObservable.notifyObservers(e)})),!0)}removeGeometry(e){let t;if(this._geometriesByUniqueId){if(t=this._geometriesByUniqueId[e.uniqueId],void 0===t)return!1}else if(t=this.geometries.indexOf(e),t<0)return!1;if(t!==this.geometries.length-1){const e=this.geometries[this.geometries.length-1];e&&(this.geometries[t]=e,this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=t))}return this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=void 0),this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0}getGeometries(){return this.geometries}getMeshById(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null}getMeshesById(e){return this.meshes.filter((function(t){return t.id===e}))}getTransformNodeById(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getTransformNodeByUniqueId(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].uniqueId===e)return this.transformNodes[t];return null}getTransformNodesById(e){return this.transformNodes.filter((function(t){return t.id===e}))}getMeshByUniqueId(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null}getLastMeshById(e){for(let t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null}getLastTransformNodeById(e){for(let t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getLastEntryById(e){let t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null}getNodeById(e){const t=this.getMeshById(e);if(t)return t;const i=this.getTransformNodeById(e);if(i)return i;const s=this.getLightById(e);if(s)return s;const r=this.getCameraById(e);if(r)return r;const n=this.getBoneById(e);return n||null}getNodeByName(e){const t=this.getMeshByName(e);if(t)return t;const i=this.getTransformNodeByName(e);if(i)return i;const s=this.getLightByName(e);if(s)return s;const r=this.getCameraByName(e);if(r)return r;const n=this.getBoneByName(e);return n||null}getMeshByName(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null}getTransformNodeByName(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].name===e)return this.transformNodes[t];return null}getLastSkeletonById(e){for(let t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].uniqueId===e)return this.skeletons[t];return null}getSkeletonById(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByName(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null}getMorphTargetManagerById(e){for(let t=0;t<this.morphTargetManagers.length;t++)if(this.morphTargetManagers[t].uniqueId===e)return this.morphTargetManagers[t];return null}getMorphTargetById(e){for(let t=0;t<this.morphTargetManagers.length;++t){const i=this.morphTargetManagers[t];for(let t=0;t<i.numTargets;++t){const s=i.getTarget(t);if(s.id===e)return s}}return null}getMorphTargetByName(e){for(let t=0;t<this.morphTargetManagers.length;++t){const i=this.morphTargetManagers[t];for(let t=0;t<i.numTargets;++t){const s=i.getTarget(t);if(s.name===e)return s}}return null}getPostProcessByName(e){for(let t=0;t<this.postProcesses.length;++t){const i=this.postProcesses[t];if(i.name===e)return i}return null}isActiveMesh(e){return-1!==this._activeMeshes.indexOf(e)}get uid(){return this._uid||(this._uid=pi.RandomId()),this._uid}addExternalData(e,t){return this._externalData||(this._externalData=new Pr),this._externalData.add(e,t)}getExternalData(e){return this._externalData?this._externalData.get(e):null}getOrAddExternalDataWithFactory(e,t){return this._externalData||(this._externalData=new Pr),this._externalData.getOrAddWithFactory(e,t)}removeExternalData(e){return this._externalData.remove(e)}_evaluateSubMesh(e,t,i,s){if(s||e.isInFrustum(this._frustumPlanes)){for(const i of this._evaluateSubMeshStage)i.action(t,e);const i=e.getMaterial();null!=i&&(i.hasRenderTargetTextures&&null!=i.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(i)&&(this._processedMaterials.push(i),this._materialsRenderTargets.concatWithNoDuplicate(i.getRenderTargetTextures())),this._renderingManager.dispatch(e,t,i))}}freeProcessedMaterials(){this._processedMaterials.dispose()}get blockfreeActiveMeshesAndRenderingGroups(){return this._preventFreeActiveMeshesAndRenderingGroups}set blockfreeActiveMeshesAndRenderingGroups(e){this._preventFreeActiveMeshesAndRenderingGroups!==e&&(e&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=e)}freeActiveMeshes(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(let e=0;e<this.activeCameras.length;e++){const t=this.activeCameras[e];t&&t._activeMeshes&&t._activeMeshes.dispose()}}freeRenderingGroups(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(let e=0;e<this.textures.length;e++){const t=this.textures[e];t&&t.renderList&&t.freeRenderingGroups()}}_isInIntermediateRendering(){return this._intermediateRendering}freezeActiveMeshes(e=!1,t,i,s=!0,r=!1){return this.executeWhenReady((()=>{if(this.activeCamera){if(this._frustumPlanes||this.updateTransformMatrix(),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,s)for(let e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._freeze();t&&t()}else i&&i("No active camera found")})),this}unfreezeActiveMeshes(){for(let e=0;e<this.meshes.length;e++){const t=this.meshes[e];t._internalAbstractMeshDataInfo&&(t._internalAbstractMeshDataInfo._isActive=!1)}for(let e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();return this._activeMeshesFrozen=!1,this}_executeActiveContainerCleanup(e){(!this._engine.snapshotRendering||this._engine.snapshotRenderingMode!==Ve.SNAPSHOTRENDERING_FAST)&&this._activeMeshesFrozen&&this._activeMeshes.length||this.onBeforeRenderObservable.addOnce((()=>e.dispose()))}_evaluateActiveMeshes(){if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===Ve.SNAPSHOTRENDERING_FAST)return void(this._activeMeshes.length>0&&(this.activeCamera?._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset()));if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely){const e=this._activeMeshes.length;for(let t=0;t<e;t++){this._activeMeshes.data[t].computeWorldMatrix()}}if(this._activeParticleSystems){const e=this._activeParticleSystems.length;for(let t=0;t<e;t++)this._activeParticleSystems.data[t].animate()}return void this._renderingManager.resetSprites()}if(!this.activeCamera)return;this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._materialsRenderTargets.reset();for(const e of this._beforeEvaluateActiveMeshStage)e.action();const e=this.getActiveMeshCandidates(),t=e.length;for(let i=0;i<t;i++){const t=e.data[i];if(t._internalAbstractMeshDataInfo._currentLODIsUpToDate=!1,t.isBlocked)continue;if(this._totalVertices.addCount(t.getTotalVertices(),!1),!t.isReady()||!t.isEnabled()||t.scaling.hasAZeroComponent)continue;t.computeWorldMatrix(),t.actionManager&&t.actionManager.hasSpecificTriggers2(Ve.ACTION_OnIntersectionEnterTrigger,Ve.ACTION_OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(t);let s=this.customLODSelector?this.customLODSelector(t,this.activeCamera):t.getLOD(this.activeCamera);if(t._internalAbstractMeshDataInfo._currentLOD=s,t._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,null!=s&&(s!==t&&0!==s.billboardMode&&s.computeWorldMatrix(),t._preActivate(),t.isVisible&&t.visibility>0&&t.layerMask&this.activeCamera.layerMask&&(this._skipFrustumClipping||t.alwaysSelectAsActiveMesh||t.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(t),this.activeCamera._activeMeshes.push(t),s!==t&&s._activate(this._renderId,!1);for(const e of this._preActiveMeshStage)e.action(t);t._activate(this._renderId,!1)&&(t.isAnInstance?t._internalAbstractMeshDataInfo._actAsRegularMesh&&(s=t):s._internalAbstractMeshDataInfo._onlyForInstances=!1,s._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(t,s)),t._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let e=0;e<this.particleSystems.length;e++){const t=this.particleSystems[e];if(!t.isStarted()||!t.emitter)continue;const i=t.emitter;i.position&&!i.isEnabled()||(this._activeParticleSystems.push(t),t.animate(),this._renderingManager.dispatchParticles(t))}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}_prepareSkeleton(e){this._skeletonsEnabled&&e.skeleton&&(this._activeSkeletons.pushNoDuplicate(e.skeleton)&&(e.skeleton.prepare(),this._activeBones.addCount(e.skeleton.bones.length,!1)),e.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(e)&&this.frameGraph&&e.applySkeleton(e.skeleton))}_activeMesh(e,t){this._prepareSkeleton(t);let i=e.hasInstances||e.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||t.alwaysSelectAsActiveMesh;if(t&&t.subMeshes&&t.subMeshes.length>0){const s=this.getActiveSubMeshCandidates(t),r=s.length;i=i||1===r;for(let n=0;n<r;n++){const r=s.data[n];this._evaluateSubMesh(r,t,e,i)}}}updateTransformMatrix(e){const t=this.activeCamera;if(t)if(t._renderingMultiview){const i=t._rigCameras[0],s=t._rigCameras[1];this.setTransformMatrix(i.getViewMatrix(),i.getProjectionMatrix(e),s.getViewMatrix(),s.getProjectionMatrix(e))}else this.setTransformMatrix(t.getViewMatrix(),t.getProjectionMatrix(e))}_bindFrameBuffer(e,t=!0){e&&e._multiviewTexture?e._multiviewTexture._bindFrameBuffer():e&&e.outputRenderTarget?e.outputRenderTarget._bindFrameBuffer():this._engine._currentFrameBufferIsDefaultFrameBuffer()||this._engine.restoreDefaultFramebuffer(),t&&this._clearFrameBuffer(e)}_clearFrameBuffer(e){if(e&&e._multiviewTexture);else if(e&&e.outputRenderTarget&&!e._renderingMultiview){const t=e.outputRenderTarget;t.onClearObservable.hasObservers()?t.onClearObservable.notifyObservers(this._engine):t.skipInitialClear||e.isRightCamera||(this.autoClear&&this._engine.clear(t.clearColor||this._clearColor,!t._cleared,!0,!0),t._cleared=!0)}else this._defaultFrameBufferCleared?this._engine.clear(null,!1,!0,!0):(this._defaultFrameBufferCleared=!0,this._clear())}_renderForCamera(e,t,i=!0){if(e&&e._skipRendering)return;const s=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");if(s.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,!this.prePass&&i){let t=!0;e._renderingMultiview&&e.outputRenderTarget&&(t=e.outputRenderTarget.skipInitialClear,this.autoClear&&(this._defaultFrameBufferCleared=!1,e.outputRenderTarget.skipInitialClear=!1)),this._bindFrameBuffer(this._activeCamera),e._renderingMultiview&&e.outputRenderTarget&&(e.outputRenderTarget.skipInitialClear=t)}this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(let e=0;e<this._softwareSkinnedMeshes.length;e++){const t=this._softwareSkinnedMeshes.data[e];t.applySkeleton(t.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets),e.customRenderTargets&&e.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(const e of this._gatherActiveCameraRenderTargetsStage)e.action(this._renderTargets);let r=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){pi.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(let e=0;e<this._renderTargets.length;e++){const t=this._renderTargets.data[e];if(t._shouldRender()){this._renderId++;const e=t.activeCamera&&t.activeCamera!==this.activeCamera;t.render(e,this.dumpNextRenderTargets),r=!0}}pi.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(const e of this._cameraDrawRenderTargetStage)r=e.action(this.activeCamera)||r;this._intermediateRendering=!1}this._engine.currentRenderPassId=e.outputRenderTarget?.renderPassId??e.renderPassId??Ve.RENDERPASS_MAIN,r&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||e._multiviewTexture||this.prePass||this.postProcessManager._prepareFrame();for(const e of this._beforeCameraDrawStage)e.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this),s.snapshotRendering&&s.snapshotRenderingMode===Ve.SNAPSHOTRENDERING_FAST&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(const e of this._afterCameraDrawStage)e.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const t=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,t)}for(const e of this._afterCameraPostProcessStage)e.action(this.activeCamera);this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}_processSubCameras(e,t=!0){if(e.cameraRigMode===Ve.RIG_MODE_NONE||e._renderingMultiview)return e._renderingMultiview&&!this._multiviewSceneUbo&&this._createMultiviewUbo(),this._renderForCamera(e,void 0,t),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else{this.onBeforeCameraRenderObservable.notifyObservers(e);for(let t=0;t<e._rigCameras.length;t++)this._renderForCamera(e._rigCameras[t],e)}this._activeCamera=e,this.updateTransformMatrix(),this.onAfterRenderCameraObservable.notifyObservers(e)}_checkIntersections(){for(let e=0;e<this._meshesForIntersections.length;e++){const t=this._meshesForIntersections.data[e];if(t.actionManager)for(let e=0;t.actionManager&&e<t.actionManager.actions.length;e++){const i=t.actionManager.actions[e];if(i.trigger===Ve.ACTION_OnIntersectionEnterTrigger||i.trigger===Ve.ACTION_OnIntersectionExitTrigger){const e=i.getTriggerParameter(),s=e.mesh?e.mesh:e,r=s.intersectsMesh(t,e.usePreciseIntersection),n=t._intersectionsInProgress.indexOf(s);r&&-1===n?i.trigger===Ve.ACTION_OnIntersectionEnterTrigger?(i._executeCurrent(Fr.CreateNew(t,void 0,s)),t._intersectionsInProgress.push(s)):i.trigger===Ve.ACTION_OnIntersectionExitTrigger&&t._intersectionsInProgress.push(s):!r&&n>-1&&(i.trigger===Ve.ACTION_OnIntersectionExitTrigger&&i._executeCurrent(Fr.CreateNew(t,void 0,s)),t.actionManager.hasSpecificTrigger(Ve.ACTION_OnIntersectionExitTrigger,(e=>{const t=e.mesh?e.mesh:e;return s===t}))&&i.trigger!==Ve.ACTION_OnIntersectionExitTrigger||t._intersectionsInProgress.splice(n,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max(ln.MinDeltaTime,Math.min(this._engine.getDeltaTime(),ln.MaxDeltaTime))+this._timeAccumulator;const t=this._engine.getTimeStep(),i=1e3/t/1e3;let s=0;const r=this._engine.getLockstepMaxSteps();let n=Math.floor(e/t);for(n=Math.min(n,r);e>0&&s<n;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=t*i,this._animate(t),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(t),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,s++,e-=t;this._timeAccumulator=e<0?0:e}else{const e=this.useConstantAnimationDeltaTime?16:Math.max(ln.MinDeltaTime,Math.min(this._engine.getDeltaTime(),ln.MaxDeltaTime));this._animationRatio=.06*e,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(e)}}_clear(){(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this._clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil)}_checkCameraRenderTarget(e){if(e?.outputRenderTarget&&!e?.isRigCamera&&(e.outputRenderTarget._cleared=!1),e?.rigCameras?.length)for(let t=0;t<e.rigCameras.length;++t){const i=e.rigCameras[t].outputRenderTarget;i&&(i._cleared=!1)}}resetDrawCache(e){if(this.meshes)for(const t of this.meshes)t.resetDrawCache(e)}_renderWithFrameGraph(e=!0,t=!1){if(this.activeCamera=null,this._activeParticleSystems.reset(),this._activeSkeletons.reset(),e)for(const e of this.cameras)if(e.update(),e.cameraRigMode!==Ve.RIG_MODE_NONE)for(let t=0;t<e._rigCameras.length;t++)e._rigCameras[t].update();for(const e of this._beforeClearStage)e.action();const i=this.getActiveMeshCandidates(),s=i.length;for(let e=0;e<s;e++){const t=i.data[e];t.isBlocked||(this._totalVertices.addCount(t.getTotalVertices(),!1),t.isReady()&&t.isEnabled()&&!t.scaling.hasAZeroComponent&&(t.computeWorldMatrix(),t.actionManager&&t.actionManager.hasSpecificTriggers2(Ve.ACTION_OnIntersectionEnterTrigger,Ve.ACTION_OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(t)))}if(this.particlesEnabled)for(let e=0;e<this.particleSystems.length;e++){const t=this.particleSystems[e];if(!t.isStarted()||!t.emitter)continue;const i=t.emitter;i.position&&!i.isEnabled()||(this._activeParticleSystems.push(t),t.animate())}this.frameGraph?.execute()}render(e=!0,t=!1){if(!this.isDisposed){this.onReadyObservable.hasObservers()&&null===this._executeWhenReadyTimeoutId&&this._checkIsReady(),this._frameId++,this._defaultFrameBufferCleared=!1,this._checkCameraRenderTarget(this.activeCamera),this.activeCameras?.length&&this.activeCameras.forEach(this._checkCameraRenderTarget),this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(Ve.ACTION_OnEveryFrameTrigger),t||this.animate();for(const e of this._beforeCameraUpdateStage)e.action();if(e)if(this.activeCameras&&this.activeCameras.length>0)for(let e=0;e<this.activeCameras.length;e++){const t=this.activeCameras[e];if(t.update(),t.cameraRigMode!==Ve.RIG_MODE_NONE)for(let e=0;e<t._rigCameras.length;e++)t._rigCameras[e].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==Ve.RIG_MODE_NONE))for(let e=0;e<this.activeCamera._rigCameras.length;e++)this.activeCamera._rigCameras[e].update();if(this.onBeforeRenderObservable.notifyObservers(this),this.customRenderFunction)this._renderId++,this._engine.currentRenderPassId=Ve.RENDERPASS_MAIN,this.customRenderFunction(e,t);else{const e=this.getEngine();this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);const t=this.activeCameras?.length?this.activeCameras[0]:this.activeCamera;if(this.renderTargetsEnabled){pi.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(let i=0;i<this.customRenderTargets.length;i++){const s=this.customRenderTargets[i];if(s._shouldRender()){if(this._renderId++,this.activeCamera=s.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");e.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),s.render(t!==this.activeCamera,this.dumpNextRenderTargets)}}pi.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=t?.renderPassId??Ve.RENDERPASS_MAIN,this.activeCamera=t,this._activeCamera&&this._activeCamera.cameraRigMode!==Ve.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const e of this._beforeClearStage)e.action();this._clearFrameBuffer(this.activeCamera);for(const e of this._gatherRenderTargetsStage)e.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let e=0;e<this.activeCameras.length;e++)this._processSubCameras(this.activeCameras[e],e>0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(const e of this._afterRenderStage)e.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let e=0;e<this._toBeDisposed.length;e++){const t=this._toBeDisposed[e];t&&t.dispose()}this._toBeDisposed.length=0}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0),this._engine.restoreDefaultFramebuffer()}}freezeMaterials(){for(let e=0;e<this.materials.length;e++)this.materials[e].freeze()}unfreezeMaterials(){for(let e=0;e<this.materials.length;e++)this.materials[e].unfreeze()}dispose(){if(this.isDisposed)return;this.beforeRender=null,this.afterRender=null,this.metadata=null,this.skeletons.length=0,this.morphTargetManagers.length=0,this._transientComponents.length=0,this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear(),this.importedMeshesFiles=[],this._activeAnimatables&&this.stopAllAnimations&&(this._activeAnimatables.forEach((e=>{e.onAnimationEndObservable.clear(),e.onAnimationEnd=null})),this.stopAllAnimations()),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this.activeCameras=null,this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._materialsRenderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.length=0;const e=this._activeRequests.slice();for(const t of e)t.abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(e){Ae.Error("An error occurred while calling onDisposeObservable!",e)}this.detachControl();if(this._engine.getInputElement())for(let e=0;e<this.cameras.length;e++)this.cameras[e].detachControl();this._disposeList(this.animationGroups),this._disposeList(this.lights),this._defaultMaterial&&this._defaultMaterial.dispose(),this._disposeList(this.multiMaterials),this._disposeList(this.materials),this._disposeList(this.meshes,(e=>e.dispose(!0))),this._disposeList(this.transformNodes,(e=>e.dispose(!0)));const t=this.cameras;this._disposeList(t),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let i=this._engine.scenes.indexOf(this);i>-1&&this._engine.scenes.splice(i,1),O._LastCreatedScene===this&&(this._engine.scenes.length>0?O._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:O._LastCreatedScene=null),i=this._engine._virtualScenes.indexOf(this),i>-1&&this._engine._virtualScenes.splice(i,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this.onEnvironmentTextureChangedObservable.clear(),this.onMeshUnderPointerUpdatedObservable.clear(),this._isDisposed=!0}_disposeList(e,t){const i=e.slice(0);t=t??(e=>e.dispose());for(const e of i)t(e);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e<this.meshes.length;e++){const t=this.meshes[e].geometry;t&&t.clearCachedData()}}cleanCachedTextureBuffer(){for(const e of this.textures){e._buffer&&(e._buffer=null)}}getWorldExtends(e){const t=new X(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new X(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return e=e||(()=>!0),this.meshes.filter(e).forEach((e=>{if(e.computeWorldMatrix(!0),!e.subMeshes||0===e.subMeshes.length||e.infiniteDistance)return;const s=e.getBoundingInfo(),r=s.boundingBox.minimumWorld,n=s.boundingBox.maximumWorld;X.CheckExtends(r,t,i),X.CheckExtends(n,t,i)})),{min:t,max:i}}createPickingRay(e,t,i,s,r=!1){throw te("Ray")}createPickingRayToRef(e,t,i,s,r,n=!1,a=!1){throw te("Ray")}createPickingRayInCameraSpace(e,t,i){throw te("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,s){throw te("Ray")}pick(e,t,i,s,r,n){const a=te("Ray",!0);return a&&Ae.Warn(a),new ss}pickWithBoundingInfo(e,t,i,s,r){const n=te("Ray",!0);return n&&Ae.Warn(n),new ss}pickWithRay(e,t,i,s){throw te("Ray")}multiPick(e,t,i,s,r){throw te("Ray")}multiPickWithRay(e,t,i){throw te("Ray")}setPointerOverMesh(e,t,i){this._inputManager.setPointerOverMesh(e,t,i)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(const e of this._components)e.rebuild();for(const e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(const e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(const e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag)}_getByTags(e,t,i){if(void 0===t)return e;const s=[];for(const r in e){const n=e[r];se&&se.MatchesQuery(n,t)&&(!i||i(n))&&s.push(n)}return s}getMeshesByTags(e,t){return this._getByTags(this.meshes,e,t)}getCamerasByTags(e,t){return this._getByTags(this.cameras,e,t)}getLightsByTags(e,t){return this._getByTags(this.lights,e,t)}getMaterialByTags(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))}getTransformNodesByTags(e,t){return this._getByTags(this.transformNodes,e,t)}setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,s)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(Ve.MATERIAL_AllDirtyFlag))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(const i of this.materials)t&&!t(i)||i.markAsDirty(e)}_loadFile(e,t,i,s,r,n,a){const o=$t(e,t,i,s?this.offlineProvider:void 0,r,n,a);return this._activeRequests.push(o),o.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),o}_loadFileAsync(e,t,i,s,r){return new Promise(((n,a)=>{this._loadFile(e,(e=>{n(e)}),t,i,s,((e,t)=>{a(t)}),r)}))}_requestFile(e,t,i,s,r,n,a){const o=ei(e,t,i,s?this.offlineProvider:void 0,r,n,a);return this._activeRequests.push(o),o.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),o}_requestFileAsync(e,t,i,s,r){return new Promise(((n,a)=>{this._requestFile(e,(e=>{n(e)}),t,i,s,(e=>{a(e)}),r)}))}_readFile(e,t,i,s,r){const n=Jt(e,t,i,s,r);return this._activeRequests.push(n),n.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),n}_readFileAsync(e,t,i){return new Promise(((s,r)=>{this._readFile(e,(e=>{s(e)}),t,i,(e=>{r(e)}))}))}getPerfCollector(){throw te("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}}ln.FOGMODE_NONE=Ve.FOGMODE_NONE,ln.FOGMODE_EXP=Ve.FOGMODE_EXP,ln.FOGMODE_EXP2=Ve.FOGMODE_EXP2,ln.FOGMODE_LINEAR=Ve.FOGMODE_LINEAR,ln.MinDeltaTime=1,ln.MaxDeltaTime=1e3,S("BABYLON.Scene",ln),function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(hn||(hn={}));const cn=new A,un={};function dn(){return un[".babylon"]}function _n(e,t){const i=un[e];return i||(Ae.Warn("Unable to find a plugin to load "+e+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),t?dn():void 0)}async function fn(e,t,i,s,r,n,a,o,h){const l="data:"===(c=e.url).substring(0,5)?c.substring(5):null;var c;if(e.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";const u=l||a?"":function(e){const t=e.indexOf("?");-1!==t&&(e=e.substring(0,t));const i=e.lastIndexOf(".");return e.substring(i,e.length).toLowerCase()}(e.url);let d=a?_n(a,!0):l?function(e){for(const t in un){const i=un[t].plugin;if(i.canDirectLoad&&i.canDirectLoad(e))return un[t]}return dn()}(e.url):_n(u,!1);if(!d&&u){if(e.url&&!e.url.startsWith("blob:")){const t=await function(e,t){const i=t.method||"GET";return new Promise(((s,r)=>{const n=new ye;n.addEventListener("readystatechange",(()=>{if(4==n.readyState)if(200==n.status){const e={};if(t.responseHeaders)for(const i of t.responseHeaders)e[i]=n.getResponseHeader(i)||"";s({response:n.response,headerValues:e})}else r(`Unable to fetch data from ${e}. Error code: ${n.status}`)})),n.open(i,e),n.send()}))}(e.url,{method:"HEAD",responseHeaders:["Content-Type"]}),i=t.headerValues?t.headerValues["Content-Type"]:"";i&&(d=function(e){for(const t in un){const i=un[t];if(i.mimeType===e)return i}}(i))}d||(d=dn())}if(!d)throw new Error(`No plugin or fallback for ${a??e.url}`);if(!1===h?.[d.plugin.name]?.enabled)throw new Error(`The '${d.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(e.rawData&&!d.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(e=>{if(d.plugin.createPlugin){const t=d.plugin.createPlugin(h??{});return t instanceof Promise?(t.then(e).catch((e=>{r("Error instantiating plugin.",e)})),null):(e(t),t)}return e(d.plugin),d.plugin})((h=>{if(!h)throw`The loader plugin corresponding to the '${a}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(cn.notifyObservers(h),l&&(h.canDirectLoad&&h.canDirectLoad(e.url)||!ii(e.url))){if(h.directLoad){const e=h.directLoad(t,l);e instanceof Promise?e.then((e=>{i(h,e)})).catch((e=>{r("Error in directLoad of _loadData: "+e,e)})):i(h,e)}else i(h,l);return}const c=d.isBinary,u=(e,s)=>{t.isDisposed?r("Scene has been disposed"):i(h,e,s)};let _=null,f=!1;h.onDisposeObservable?.add((()=>{f=!0,_&&(_.abort(),_=null),n()}));const p=()=>{if(f)return;const i=(e,t)=>{r(e?.statusText,t)};if(!h.loadFile&&e.rawData)throw"Plugin does not support loading ArrayBufferView.";_=h.loadFile?h.loadFile(t,e.rawData||e.file||e.url,e.rootUrl,u,s,c,i,o):t._loadFile(e.file||e.url,u,s,!0,c,i)},g=t.getEngine();let m=g.enableOfflineSupport;if(m){let i=!1;for(const s of t.disableOfflineSupportExceptionRules)if(s.test(e.url)){i=!0;break}m=!i}m&&Wt.OfflineProviderFactory?t.offlineProvider=Wt.OfflineProviderFactory(e.url,p,g.disableManifestCheck):p()}))}function pn(e){if("string"==typeof e.extensions){const t=e.extensions;un[t.toLowerCase()]={plugin:e,isBinary:!1}}else{const t=e.extensions;Object.keys(t).forEach((i=>{un[i.toLowerCase()]={plugin:e,isBinary:t[i].isBinary,mimeType:t[i].mimeType}}))}}async function gn(e,t="",i=O.LastCreatedScene,s=null,r=null,n=null,a=null,o="",h={}){if(!i)return Ae.Error("No scene available to load asset container to"),null;const l=function(e,t){let i,s,r=null,n=null;if(t)if(t.name)i=`file:${t.name}`,s=t.name,r=t;else if(ArrayBuffer.isView(t))i="",s=hi(),n=t;else if(t.startsWith("data:"))i=t,s="";else if(e){const r=t;if("/"===r.substring(0,1))return pi.Error("Wrong sceneFilename parameter"),null;i=e+r,s=r}else i=t,s=pi.GetFilename(t),e=pi.GetFolderPath(t);else i=e,s=pi.GetFilename(e),e=pi.GetFolderPath(e);return{url:i,rootUrl:e,name:s,file:r,rawData:n}}(e,t);if(!l)return null;const c={};i.addPendingData(c);const u=()=>{i.removePendingData(c)},d=(e,t)=>{const s=function(e,t,i){let s="Unable to load from "+(e.rawData?"binary data":e.url);return t?s+=`: ${t}`:i&&(s+=`: ${i}`),s}(l,e,t);n?n(i,s,new xe(s,ve.SceneLoaderError,t)):Ae.Error(s),u()},_=r?e=>{try{r(e)}catch(e){d("Error in onProgress callback",e)}}:void 0,f=e=>{if(s)try{s(e)}catch(e){d("Error in onSuccess callback",e)}i.removePendingData(c)};return await fn(l,i,((e,t)=>{if(e.loadAssetContainer){const s=e.loadAssetContainer(i,t,l.rootUrl,d);if(!s)return;s.populateRootNodes(),i.loadingPluginName=e.name,f(s)}else if(e.loadAssetContainerAsync){e.loadAssetContainerAsync(i,t,l.rootUrl,_,l.name).then((t=>{t.populateRootNodes(),i.loadingPluginName=e.name,f(t)})).catch((e=>{d(e.message,e)}))}else d("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")}),_,d,u,a,o,h)}function mn(e,t,i){const{rootUrl:s="",onProgress:r,pluginExtension:n,name:a,pluginOptions:o}=i??{};return function(e,t,i,s,r,n,a){return new Promise(((o,h)=>{gn(e,t,i,(e=>{o(e)}),s,((e,t,i)=>{h(i||new Error(t))}),r,n,a)}))}(s,e,t,r,n,a,o)}class Tn{get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get coordinatesMode(){return 0}get isCube(){return!!this._texture&&this._texture.isCube}set isCube(e){this._texture&&(this._texture.isCube=e)}get is3D(){return!!this._texture&&this._texture.is3D}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return!!this._texture&&this._texture.is2DArray}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}getClassName(){return"ThinTexture"}static _IsRenderTargetWrapper(e){return void 0!==e?.shareDepth}constructor(e){this._wrapU=Ve.TEXTURE_WRAP_ADDRESSMODE,this._wrapV=Ve.TEXTURE_WRAP_ADDRESSMODE,this.wrapR=Ve.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this.delayLoadState=Ve.DELAYLOADSTATE_NONE,this._texture=null,this._engine=null,this._cachedSize=sr.Zero(),this._cachedBaseSize=sr.Zero(),this._initialSamplingMode=Ve.TEXTURE_BILINEAR_SAMPLINGMODE,this._texture=Tn._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine())}isReady(){return this.delayLoadState===Ve.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return this.isReady()&&this._texture?this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize):(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}class An extends Tn{set hasAlpha(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))))}get hasAlpha(){return this._hasAlpha}set getAlphaFromRGB(e){this._getAlphaFromRGB!==e&&(this._getAlphaFromRGB=e,this._scene&&this._scene.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))))}get getAlphaFromRGB(){return this._getAlphaFromRGB}set coordinatesIndex(e){this._coordinatesIndex!==e&&(this._coordinatesIndex=e,this._scene&&this._scene.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))))}get coordinatesIndex(){return this._coordinatesIndex}set coordinatesMode(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))))}get coordinatesMode(){return this._coordinatesMode}get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get isCube(){return this._texture?this._texture.isCube:this._isCube}set isCube(e){this._texture?this._texture.isCube=e:this._isCube=e}get is3D(){return!!this._texture&&this._texture.is3D}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return!!this._texture&&this._texture.is2DArray}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}get gammaSpace(){return this._texture?(null===this._texture._gammaSpace&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace&&!this._texture._useSRGBBuffer):this._gammaSpace}set gammaSpace(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this.getScene()?.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this)))}get isRGBD(){return null!=this._texture&&this._texture._isRGBD}set isRGBD(e){e!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=e),this.getScene()?.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))))}get noMipmap(){return!1}get lodGenerationOffset(){return this._texture?this._texture._lodGenerationOffset:0}set lodGenerationOffset(e){this._texture&&(this._texture._lodGenerationOffset=e)}get lodGenerationScale(){return this._texture?this._texture._lodGenerationScale:0}set lodGenerationScale(e){this._texture&&(this._texture._lodGenerationScale=e)}get linearSpecularLOD(){return!!this._texture&&this._texture._linearSpecularLOD}set linearSpecularLOD(e){this._texture&&(this._texture._linearSpecularLOD=e)}get irradianceTexture(){return this._texture?this._texture._irradianceTexture:null}set irradianceTexture(e){this._texture&&(this._texture._irradianceTexture=e)}get uid(){return this._uid||(this._uid=hi()),this._uid}toString(){return this.name}getClassName(){return"BaseTexture"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get isBlocking(){return!0}get loadingError(){return this._loadingError}get errorObject(){return this._errorObject}constructor(e,t=null){super(null),this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this._getAlphaFromRGB=!1,this.level=1,this._coordinatesIndex=0,this.optimizeUVAllocation=!0,this._coordinatesMode=Ve.TEXTURE_EXPLICIT_MODE,this.wrapR=Ve.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=An.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new A,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?An._IsScene(e)?this._scene=e:this._engine=e:this._scene=O.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this),this._engine=this._scene.getEngine()),this._texture=t,this._uid=null}getScene(){return this._scene}_getEngine(){return this._engine}getTextureMatrix(){return j.IdentityReadOnly}getReflectionTextureMatrix(){return j.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,s,r,n){const a=this._getEngine();if(!a)return null;const o=a._getUseSRGBBuffer(!!r,t),h=a.getLoadedTexturesCache();for(let a=0;a<h.length;a++){const l=h[a];if(!(void 0!==r&&o!==l._useSRGBBuffer||void 0!==s&&s!==l.invertY||l.url!==e||l.generateMipMaps!==!t||i&&i!==l.samplingMode||void 0!==n&&n!==l.isCube))return l.incrementReferences(),l}return null}_rebuild(e=!1){}clone(){return null}get textureType(){return this._texture&&void 0!==this._texture.type?this._texture.type:Ve.TEXTURETYPE_UNSIGNED_BYTE}get textureFormat(){return this._texture&&void 0!==this._texture.format?this._texture.format:Ve.TEXTUREFORMAT_RGBA}_markAllSubMeshesAsTexturesDirty(){const e=this.getScene();e&&e.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag)}readPixels(e=0,t=0,i=null,s=!0,r=!1,n=0,a=0,o=Number.MAX_VALUE,h=Number.MAX_VALUE){if(!this._texture)return null;const l=this._getEngine();if(!l)return null;const c=this.getSize();let u=c.width,d=c.height;0!==t&&(u/=Math.pow(2,t),d/=Math.pow(2,t),u=Math.round(u),d=Math.round(d)),o=Math.min(u,o),h=Math.min(d,h);try{return this._texture.isCube?l._readTexturePixels(this._texture,o,h,e,t,i,s,r,n,a):l._readTexturePixels(this._texture,o,h,-1,t,i,s,r,n,a)}catch(e){return null}}_readPixelsSync(e=0,t=0,i=null,s=!0,r=!1){if(!this._texture)return null;const n=this.getSize();let a=n.width,o=n.height;const h=this._getEngine();if(!h)return null;0!=t&&(a/=Math.pow(2,t),o/=Math.pow(2,t),a=Math.round(a),o=Math.round(o));try{return this._texture.isCube?h._readTexturePixelsSync(this._texture,a,o,e,t,i,s,r):h._readTexturePixelsSync(this._texture,a,o,-1,t,i,s,r)}catch(e){return null}}get _lodTextureHigh(){return this._texture?this._texture._lodTextureHigh:null}get _lodTextureMid(){return this._texture?this._texture._lodTextureMid:null}get _lodTextureLow(){return this._texture?this._texture._lodTextureLow:null}dispose(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene.removePendingData(this);const e=this._scene.textures.indexOf(this);if(e>=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){const e=this._parentContainer.textures.indexOf(this);e>-1&&this._parentContainer.textures.splice(e,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,super.dispose()}serialize(e=!1){if(!this.name&&!e)return null;const t=de.Serialize(this);return de.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let i=e.length;if(0!==i)for(let s=0;s<e.length;s++){const r=e[s];if(r.isReady())0==--i&&t();else{const e=r.onLoadObservable;e?e.addOnce((()=>{0==--i&&t()})):0==--i&&t()}}else t()}static _IsScene(e){return"Scene"===e.getClassName()}}function En(e,t,i=!1){const s=t.width,r=t.height;if(e instanceof Float32Array){let t=e.byteLength/e.BYTES_PER_ELEMENT;const i=new Uint8Array(t);for(;--t>=0;){let s=e[t];s<0?s=0:s>1&&(s=1),i[t]=255*s}e=i}const n=document.createElement("canvas");n.width=s,n.height=r;const a=n.getContext("2d");if(!a)return null;const o=a.createImageData(s,r);if(o.data.set(e),a.putImageData(o,0,0),i){const e=document.createElement("canvas");e.width=s,e.height=r;const t=e.getContext("2d");return t?(t.translate(0,r),t.scale(1,-1),t.drawImage(n,0,0),e.toDataURL("image/png")):null}return n.toDataURL("image/png")}An.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,e([a()],An.prototype,"uniqueId",void 0),e([a()],An.prototype,"name",void 0),e([a()],An.prototype,"displayName",void 0),e([a()],An.prototype,"metadata",void 0),e([a("hasAlpha")],An.prototype,"_hasAlpha",void 0),e([a("getAlphaFromRGB")],An.prototype,"_getAlphaFromRGB",void 0),e([a()],An.prototype,"level",void 0),e([a("coordinatesIndex")],An.prototype,"_coordinatesIndex",void 0),e([a()],An.prototype,"optimizeUVAllocation",void 0),e([a("coordinatesMode")],An.prototype,"_coordinatesMode",void 0),e([a()],An.prototype,"wrapU",null),e([a()],An.prototype,"wrapV",null),e([a()],An.prototype,"wrapR",void 0),e([a()],An.prototype,"anisotropicFilteringLevel",void 0),e([a()],An.prototype,"isCube",null),e([a()],An.prototype,"is3D",null),e([a()],An.prototype,"is2DArray",null),e([a()],An.prototype,"gammaSpace",null),e([a()],An.prototype,"invertZ",void 0),e([a()],An.prototype,"lodLevelInAlpha",void 0),e([a()],An.prototype,"lodGenerationOffset",null),e([a()],An.prototype,"lodGenerationScale",null),e([a()],An.prototype,"linearSpecularLOD",null),e([o()],An.prototype,"irradianceTexture",null),e([a()],An.prototype,"isRenderTarget",void 0);class bn extends An{static _CreateVideoTexture(e,t,i,s=!1,r=!1,n=bn.TRILINEAR_SAMPLINGMODE,a={},o,h=Ve.TEXTUREFORMAT_RGBA){throw te("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,i,s,r=bn.TRILINEAR_SAMPLINGMODE,n=null,a=null,o=null,h=!1,l,c,u,d,_){let f;super(t),this.url=null,this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.uRotationCenter=.5,this.vRotationCenter=.5,this.wRotationCenter=.5,this.homogeneousRotationInUVTransform=!1,this.inspectableCustomProperties=null,this._noMipmap=!1,this._invertY=!1,this._rowGenerationMatrix=null,this._cachedTextureMatrix=null,this._projectionModeMatrix=null,this._t0=null,this._t1=null,this._t2=null,this._cachedUOffset=-1,this._cachedVOffset=-1,this._cachedUScale=0,this._cachedVScale=0,this._cachedUAng=-1,this._cachedVAng=-1,this._cachedWAng=-1,this._cachedReflectionProjectionMatrixId=-1,this._cachedURotationCenter=-1,this._cachedVRotationCenter=-1,this._cachedWRotationCenter=-1,this._cachedHomogeneousRotationInUVTransform=!1,this._cachedIdentity3x2=!0,this._cachedReflectionTextureMatrix=null,this._cachedReflectionUOffset=-1,this._cachedReflectionVOffset=-1,this._cachedReflectionUScale=0,this._cachedReflectionVScale=0,this._cachedReflectionCoordinatesMode=-1,this._buffer=null,this._deleteBuffer=!1,this._format=null,this._delayedOnLoad=null,this._delayedOnError=null,this.onLoadObservable=new A,this._isBlocking=!0,this.name=e||"",this.url=e;let p=!1,g=null,m=!0;"object"==typeof i&&null!==i?(f=i.noMipmap??!1,s=i.invertY??!0,r=i.samplingMode??bn.TRILINEAR_SAMPLINGMODE,n=i.onLoad??null,a=i.onError??null,o=i.buffer??null,h=i.deleteBuffer??!1,l=i.format,c=i.mimeType,u=i.loaderOptions,d=i.creationFlags,p=i.useSRGBBuffer??!1,g=i.internalTexture??null,m=i.gammaSpace??m,_=i.forcedExtension??_):f=!!i,this._gammaSpace=m,this._noMipmap=f,this._invertY=void 0===s||s,this._initialSamplingMode=r,this._buffer=o,this._deleteBuffer=h,this._mimeType=c,this._loaderOptions=u,this._creationFlags=d,this._useSRGBBuffer=p,this._forcedExtension=_,l&&(this._format=l);const T=this.getScene(),E=this._getEngine();if(!E)return;E.onBeforeTextureInitObservable.notifyObservers(this);const b=()=>{this._texture&&(this._texture._invertVScale&&(this.vScale*=-1,this.vOffset+=1),null!==this._texture._cachedWrapU&&(this.wrapU=this._texture._cachedWrapU,this._texture._cachedWrapU=null),null!==this._texture._cachedWrapV&&(this.wrapV=this._texture._cachedWrapV,this._texture._cachedWrapV=null),null!==this._texture._cachedWrapR&&(this.wrapR=this._texture._cachedWrapR,this._texture._cachedWrapR=null)),this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),n&&n(),!this.isBlocking&&T&&T.resetCachedMaterial()},R=(e,t)=>{this._loadingError=!0,this._errorObject={message:e,exception:t},a&&a(e,t),bn.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!g)return this._delayedOnLoad=b,void(this._delayedOnError=R);if(this._texture=g??this._getFromCache(this.url,f,r,this._invertY,p,this.isCube),this._texture)if(this._texture.isReady)lt.SetImmediate((()=>b()));else{const e=this._texture.onLoadedObservable.add(b);this._texture.onErrorObservable.add((t=>{R(t.message,t.exception),this._texture?.onLoadedObservable.remove(e)}))}else if(T&&T.useDelayedTextureLoading)this.delayLoadState=Ve.DELAYLOADSTATE_NOTLOADED,this._delayedOnLoad=b,this._delayedOnError=R;else{try{this._texture=E.createTexture(this.url,f,this._invertY,T,r,b,R,this._buffer,void 0,this._format,this._forcedExtension,c,u,d,p)}catch(e){throw R("error loading",e),e}h&&(this._buffer=null)}}updateURL(e,t=null,i,s){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this)))),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=s,this.delayLoadState=Ve.DELAYLOADSTATE_NOTLOADED,i&&(this._delayedOnLoad=i),this.delayLoad()}delayLoad(){if(this.delayLoadState!==Ve.DELAYLOADSTATE_NOTLOADED)return;const e=this.getScene();e&&(this.delayLoadState=Ve.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?lt.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}_prepareRowForTextureGeneration(e,t,i,s){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,X.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,s),s.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,s.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,s.z+=this.wRotationCenter}getTextureMatrix(e=1){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=j.Zero(),this._rowGenerationMatrix=new j,this._t0=X.Zero(),this._t1=X.Zero(),this._t2=X.Zero()),j.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(j.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,J.Matrix[0]),j.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,J.Matrix[1]),j.ScalingToRef(this._cachedUScale,this._cachedVScale,0,J.Matrix[2]),j.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,J.Matrix[3]),J.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(J.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(J.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(J.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),j.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));const t=this.getScene();if(!t)return this._cachedTextureMatrix;const i=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&i!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))),this._cachedTextureMatrix}getReflectionTextureMatrix(){const e=this.getScene();if(!e)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode){if(this.coordinatesMode!==bn.PROJECTION_MODE)return this._cachedReflectionTextureMatrix;if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=j.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=j.Zero());const t=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case bn.PLANAR_MODE:j.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break;case bn.PROJECTION_MODE:{j.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);const t=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=t.updateFlag,t.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:j.IdentityToRef(this._cachedReflectionTextureMatrix)}return t&&e.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>e.hasTexture(this))),this._cachedReflectionTextureMatrix}clone(){const e={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return de.Clone((()=>new bn(this._texture?this._texture.url:null,this.getScene(),e)),this)}serialize(){const e=this.name;bn.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(bn._SerializeInternalTextureUniqueId);return t?((bn.SerializeBuffers||bn.ForceSerializeBuffers)&&("string"==typeof this._buffer&&"data:"===this._buffer.substring(0,5)?(t.base64String=this._buffer,t.name=t.name.replace("data:","")):this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array?t.base64String="data:image/png;base64,"+Ce(this._buffer):(bn.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?function(e,t=0,i=0){const s=e.getInternalTexture();if(!s)return null;const r=e._readPixelsSync(t,i);return r?En(r,e.getSize(),s.invertY):null}(this):async function(e,t=0,i=0){const s=e.getInternalTexture();if(!s)return null;const r=await e.readPixels(t,i);return r?En(r,e.getSize(),s.invertY):null}(this))),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,bn._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=this._texture?.uniqueId),t.internalTextureLabel=this._texture?.label,t.noMipmap=this._noMipmap,this.name=e,t):null}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,i){if(e.customType){const s=oi.Instantiate(e.customType).Parse(e,t,i);return e.samplingMode&&s.updateSamplingMode&&s._samplingMode&&s._samplingMode!==e.samplingMode&&s.updateSamplingMode(e.samplingMode),s}if(e.isCube&&!e.isRenderTarget)return bn._CubeTextureParser(e,t,i);const s=void 0!==e.internalTextureUniqueId;if(!e.name&&!e.isRenderTarget&&!s)return null;let r;if(s){const i=t.getEngine().getLoadedTexturesCache();for(const t of i)if(t.uniqueId===e.internalTextureUniqueId){r=t;break}}const n=t=>{if(t&&t._texture&&(t._texture._cachedWrapU=null,t._texture._cachedWrapV=null,t._texture._cachedWrapR=null),e.samplingMode){const i=e.samplingMode;t&&t.samplingMode!==i&&t.updateSamplingMode(i)}if(t&&e.animations)for(let i=0;i<e.animations.length;i++){const s=e.animations[i],r=C("BABYLON.Animation");r&&t.animations.push(r.Parse(s))}t&&t._texture&&(s&&!r&&t._texture._setUniqueId(e.internalTextureUniqueId),t._texture.label=e.internalTextureLabel)};return de.Parse((()=>{let s=!0;if(e.noMipmap&&(s=!1),e.mirrorPlane){const i=bn._CreateMirror(e.name,e.renderTargetSize,t,s);return i._waitingRenderList=e.renderList,i.mirrorPlane=Mi.FromArray(e.mirrorPlane),n(i),i}if(e.isRenderTarget){let i=null;if(e.isCube){if(t.reflectionProbes)for(let i=0;i<t.reflectionProbes.length;i++){const s=t.reflectionProbes[i];if(s.name===e.name)return s.cubeTexture}}else i=bn._CreateRenderTargetTexture(e.name,e.renderTargetSize,t,s,e._creationFlags??0),i._waitingRenderList=e.renderList;return n(i),i}if(e.isVideo){const r=bn._CreateVideoTexture(i+(e.url||e.name),i+(e.src||e.url),t,s,e.invertY,e.samplingMode,e.settings||{});return n(r),r}{let a;if(e.base64String&&!r)a=bn.CreateFromBase64String(e.base64String,e.base64String,t,!s,e.invertY,e.samplingMode,(()=>{n(a)}),e._creationFlags??0,e._useSRGBBuffer??!1),a.name=e.name;else{let o;o=e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?e.name:i+e.name,e.url&&(e.url.startsWith("data:")||bn.UseSerializedUrlIfAny)&&(o=e.url);const h={noMipmap:!s,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{n(a)},internalTexture:r};a=new bn(o,t,h)}return a}}),e,t)}static CreateFromBase64String(e,t,i,s,r,n=bn.TRILINEAR_SAMPLINGMODE,a=null,o=null,h=Ve.TEXTUREFORMAT_RGBA,l,c){return new bn("data:"+t,i,s,r,n,a,o,e,!1,h,void 0,void 0,l,c)}static LoadFromDataString(e,t,i,s=!1,r,n=!0,a=bn.TRILINEAR_SAMPLINGMODE,o=null,h=null,l=Ve.TEXTUREFORMAT_RGBA,c,u){return"data:"!==e.substring(0,5)&&(e="data:"+e),new bn(e,i,r,n,a,o,h,t,s,l,void 0,void 0,c,u)}}bn.SerializeBuffers=!0,bn.ForceSerializeBuffers=!1,bn.OnTextureLoadErrorObservable=new A,bn._SerializeInternalTextureUniqueId=!1,bn._CubeTextureParser=(e,t,i)=>{throw te("CubeTexture")},bn._CreateMirror=(e,t,i,s)=>{throw te("MirrorTexture")},bn._CreateRenderTargetTexture=(e,t,i,s,r)=>{throw te("RenderTargetTexture")},bn.NEAREST_SAMPLINGMODE=Ve.TEXTURE_NEAREST_SAMPLINGMODE,bn.NEAREST_NEAREST_MIPLINEAR=Ve.TEXTURE_NEAREST_NEAREST_MIPLINEAR,bn.BILINEAR_SAMPLINGMODE=Ve.TEXTURE_BILINEAR_SAMPLINGMODE,bn.LINEAR_LINEAR_MIPNEAREST=Ve.TEXTURE_LINEAR_LINEAR_MIPNEAREST,bn.TRILINEAR_SAMPLINGMODE=Ve.TEXTURE_TRILINEAR_SAMPLINGMODE,bn.LINEAR_LINEAR_MIPLINEAR=Ve.TEXTURE_LINEAR_LINEAR_MIPLINEAR,bn.NEAREST_NEAREST_MIPNEAREST=Ve.TEXTURE_NEAREST_NEAREST_MIPNEAREST,bn.NEAREST_LINEAR_MIPNEAREST=Ve.TEXTURE_NEAREST_LINEAR_MIPNEAREST,bn.NEAREST_LINEAR_MIPLINEAR=Ve.TEXTURE_NEAREST_LINEAR_MIPLINEAR,bn.NEAREST_LINEAR=Ve.TEXTURE_NEAREST_LINEAR,bn.NEAREST_NEAREST=Ve.TEXTURE_NEAREST_NEAREST,bn.LINEAR_NEAREST_MIPNEAREST=Ve.TEXTURE_LINEAR_NEAREST_MIPNEAREST,bn.LINEAR_NEAREST_MIPLINEAR=Ve.TEXTURE_LINEAR_NEAREST_MIPLINEAR,bn.LINEAR_LINEAR=Ve.TEXTURE_LINEAR_LINEAR,bn.LINEAR_NEAREST=Ve.TEXTURE_LINEAR_NEAREST,bn.EXPLICIT_MODE=Ve.TEXTURE_EXPLICIT_MODE,bn.SPHERICAL_MODE=Ve.TEXTURE_SPHERICAL_MODE,bn.PLANAR_MODE=Ve.TEXTURE_PLANAR_MODE,bn.CUBIC_MODE=Ve.TEXTURE_CUBIC_MODE,bn.PROJECTION_MODE=Ve.TEXTURE_PROJECTION_MODE,bn.SKYBOX_MODE=Ve.TEXTURE_SKYBOX_MODE,bn.INVCUBIC_MODE=Ve.TEXTURE_INVCUBIC_MODE,bn.EQUIRECTANGULAR_MODE=Ve.TEXTURE_EQUIRECTANGULAR_MODE,bn.FIXED_EQUIRECTANGULAR_MODE=Ve.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,bn.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=Ve.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,bn.CLAMP_ADDRESSMODE=Ve.TEXTURE_CLAMP_ADDRESSMODE,bn.WRAP_ADDRESSMODE=Ve.TEXTURE_WRAP_ADDRESSMODE,bn.MIRROR_ADDRESSMODE=Ve.TEXTURE_MIRROR_ADDRESSMODE,bn.UseSerializedUrlIfAny=!1,e([a()],bn.prototype,"url",void 0),e([a()],bn.prototype,"uOffset",void 0),e([a()],bn.prototype,"vOffset",void 0),e([a()],bn.prototype,"uScale",void 0),e([a()],bn.prototype,"vScale",void 0),e([a()],bn.prototype,"uAng",void 0),e([a()],bn.prototype,"vAng",void 0),e([a()],bn.prototype,"wAng",void 0),e([a()],bn.prototype,"uRotationCenter",void 0),e([a()],bn.prototype,"vRotationCenter",void 0),e([a()],bn.prototype,"wRotationCenter",void 0),e([a()],bn.prototype,"homogeneousRotationInUVTransform",void 0),e([a()],bn.prototype,"isBlocking",null),S("BABYLON.Texture",bn),de._TextureParser=bn.Parse;const Rn="postprocessVertexShader",yn="attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";ct.ShadersStore[Rn]=yn;const In={name:Rn,shader:yn};var Mn=Object.freeze({__proto__:null,postprocessVertexShader:In});const vn={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class xn{constructor(e,t=vn){this._fullscreenViewport=new Ii(0,0,1,1);const i=t.positions??vn.positions,s=t.indices??vn.indices;this.engine=e,this._vertexBuffers={[wi.PositionKind]:new wi(e,i,wi.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(s),this._onContextRestoredObserver=e.onContextRestoredObservable.add((()=>{this._indexBuffer=e.createIndexBuffer(s);for(const e in this._vertexBuffers){this._vertexBuffers[e]._rebuild()}}))}setViewport(e=this._fullscreenViewport){this.engine.setViewport(e)}bindBuffers(e){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,e)}applyEffectWrapper(e){this.engine.setState(!0),this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(Ve.MATERIAL_TriangleFillMode,0,6)}_isRenderTargetTexture(e){return void 0!==e.renderTarget}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();const i=null===t?null:this._isRenderTargetTexture(t)?t.renderTarget:t;i&&this.engine.bindFramebuffer(i),this.applyEffectWrapper(e),this.draw(),i&&this.engine.unBindFramebuffer(i),this.restoreStates()}dispose(){const e=this._vertexBuffers[wi.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[wi.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class Sn{static RegisterShaderCodeProcessing(e,t){t?Sn._CustomShaderCodeProcessing[e??""]=t:delete Sn._CustomShaderCodeProcessing[e??""]}static _GetShaderCodeProcessing(e){return Sn._CustomShaderCodeProcessing[e]??Sn._CustomShaderCodeProcessing[""]}get name(){return this.options.name}set name(e){this.options.name=e}isReady(){return this._drawWrapper.effect?.isReady()??!1}get drawWrapper(){return this._drawWrapper}get effect(){return this._drawWrapper.effect}set effect(e){this._drawWrapper.effect=e}constructor(e){this.alphaMode=Ve.ALPHA_DISABLE,this.onEffectCreatedObservable=new A(void 0,!0),this.onApplyObservable=new A,this._shadersLoaded=!1,this._webGPUReady=!1,this._importPromises=[],this.options={...e,name:e.name||"effectWrapper",engine:e.engine,uniforms:e.uniforms||e.uniformNames||[],uniformNames:void 0,samplers:e.samplers||e.samplerNames||[],samplerNames:void 0,attributeNames:e.attributeNames||["position"],uniformBuffers:e.uniformBuffers||[],defines:e.defines||"",useShaderStore:e.useShaderStore||!1,vertexUrl:e.vertexUrl||e.vertexShader||"postprocess",vertexShader:void 0,fragmentShader:e.fragmentShader||"pass",indexParameters:e.indexParameters,blockCompilation:e.blockCompilation||!1,shaderLanguage:e.shaderLanguage||0,onCompiled:e.onCompiled||void 0,extraInitializations:e.extraInitializations||void 0,extraInitializationsAsync:e.extraInitializationsAsync||void 0,useAsPostProcess:e.useAsPostProcess??!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(-1===this.options.samplers.indexOf("textureSampler")&&this.options.samplers.push("textureSampler"),-1===this.options.uniforms.indexOf("scale")&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add((()=>{this.effect.setFloat2("scale",1,1)}))),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add((()=>{this.bind()})),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add((()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()}))),this._drawWrapper=new Yi(this.options.engine),this._webGPUReady=1===this.options.shaderLanguage;const t=Array.isArray(this.options.defines)?this.options.defines.join("\n"):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){this.options.useAsPostProcess&&(e&&this._webGPUReady?t.push(Promise.all([import("./postprocess.vertex-BYAf7HA1.esm.min.js")])):t.push(Promise.all([Promise.resolve().then((function(){return Mn}))])))}_postConstructor(e,t=null,i,s){this._importPromises.length=0,s&&this._importPromises.push(...s);const r=this.options.engine.isWebGPU&&!Sn.ForceGLSL;this._gatherImports(r,this._importPromises),void 0!==i&&i(r,this._importPromises),r&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,s,r,n,a,o){const h=Sn._GetShaderCodeProcessing(this.name);if(h?.defineCustomBindings){const s=t?.slice()??[];s.push(...this.options.uniforms);const r=i?.slice()??[];r.push(...this.options.samplers),e=h.defineCustomBindings(this.name,e,s,r),t=s,i=r}this.options.defines=e||"";const l=this._shadersLoaded||0===this._importPromises.length?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0};let c;c=this.options.extraInitializationsAsync?async()=>{l?.(),await this.options.extraInitializationsAsync}:l,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:a??this._shaderPath.vertex,fragment:o??this._shaderPath.fragment},{attributes:this.options.attributeNames,uniformsNames:t||this.options.uniforms,uniformBuffersNames:this.options.uniformBuffers,samplers:i||this.options.samplers,defines:null!==e?e:"",fallbacks:null,onCompiled:r??this.options.onCompiled,onError:n??null,indexParameters:s||this.options.indexParameters,processCodeAfterIncludes:h?.processCodeAfterIncludes?(e,t)=>h.processCodeAfterIncludes(this.name,e,t):null,processFinalCode:h?.processFinalCode?(e,t)=>h.processFinalCode(this.name,e,t):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:c},this.options.engine):this._drawWrapper.effect=new Ct(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,r||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,c),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(){this.options.useAsPostProcess&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),Sn._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this._drawWrapper.dispose(!0)}}Sn.ForceGLSL=!1,Sn._CustomShaderCodeProcessing={},Wt.prototype.setTextureFromPostProcess=function(e,t,i){let s=null;t&&(t._forcedOutputTexture?s=t._forcedOutputTexture:t._textures.data[t._currentRenderTextureInd]&&(s=t._textures.data[t._currentRenderTextureInd])),this._bindTexture(e,s?.texture??null,i)},Wt.prototype.setTextureFromPostProcessOutput=function(e,t,i){this._bindTexture(e,t?._outputTexture?.texture??null,i)},Ct.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers[e],t,e)},Ct.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers[e],t,e)};class Cn{static get ForceGLSL(){return Sn.ForceGLSL}static set ForceGLSL(e){Sn.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){Sn.RegisterShaderCodeProcessing(e,t)}get name(){return this._effectWrapper.name}set name(e){this._effectWrapper.name=e}get alphaMode(){return this._effectWrapper.alphaMode}set alphaMode(e){this._effectWrapper.alphaMode=e}get samples(){return this._samples}set samples(e){this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((e=>{e.setSamples(this._samples)}))}get shaderLanguage(){return this._shaderLanguage}getEffectName(){return this._fragmentUrl}set onActivate(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))}set onSizeChanged(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)}set onApply(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}get inputTexture(){return this._textures.data[this._currentRenderTextureInd]}set inputTexture(e){this._forcedOutputTexture=e}restoreDefaultInputTexture(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())}getCamera(){return this._camera}get texelSize(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)}constructor(e,t,i,s,r,n,a=Ve.TEXTURE_NEAREST_SAMPLINGMODE,o,h,l=null,c=Ve.TEXTURETYPE_UNSIGNED_BYTE,u="postprocess",d,_=!1,f=Ve.TEXTUREFORMAT_RGBA,p,g){this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=Ve.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new Ri(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new Y(1,1),this._texelSize=Y.Zero(),this.onActivateObservable=new A,this.onSizeChangedObservable=new A,this.onApplyObservable=new A,this.onBeforeRenderObservable=new A,this.onAfterRenderObservable=new A;let m,T=1,E=null;if(i&&!Array.isArray(i)){const e=i;i=e.uniforms??null,s=e.samplers??null,T=e.size??1,n=e.camera??null,a=e.samplingMode??Ve.TEXTURE_NEAREST_SAMPLINGMODE,o=e.engine,h=e.reusable,l=Array.isArray(e.defines)?e.defines.join("\n"):e.defines??null,c=e.textureType??Ve.TEXTURETYPE_UNSIGNED_BYTE,u=e.vertexUrl??"postprocess",d=e.indexParameters,_=e.blockCompilation??!1,f=e.textureFormat??Ve.TEXTUREFORMAT_RGBA,p=e.shaderLanguage??0,E=e.uniformBuffers??null,g=e.extraInitializations,m=e.effectWrapper}else r&&(T="number"==typeof r?r:{width:r.width,height:r.height});const b=!!m;if(this._effectWrapper=m??new Sn({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:o||n?.getScene().getEngine(),uniforms:i,samplers:s,uniformBuffers:E,defines:l,vertexUrl:u,indexParameters:d,blockCompilation:!0,shaderLanguage:p,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,null!=n?(this._camera=n,this._scene=n.getScene(),n.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):o&&(this._engine=o,this._engine.postProcesses.push(this)),this._options=T,this.renderTargetSamplingMode=a||Ve.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=h||!1,this._textureType=c,this._textureFormat=f,this._shaderLanguage=p||0,this._samplers=s||[],-1===this._samplers.indexOf("textureSampler")&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=u,this._parameters=i||[],-1===this._parameters.indexOf("scale")&&this._parameters.push("scale"),this._uniformBuffers=E||[],this._indexParameters=d,!b){this._webGPUReady=1===this._shaderLanguage;const e=[];this._gatherImports(this._engine.isWebGPU&&!Cn.ForceGLSL,e),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(_,l,g,e)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([import("./postprocess.vertex-BYAf7HA1.esm.min.js")])):t.push(Promise.all([Promise.resolve().then((function(){return Mn}))]))}getClassName(){return"PostProcess"}getEngine(){return this._engine}getEffect(){return this._effectWrapper.drawWrapper.effect}shareOutputWith(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this}useOwnOutput(){0==this._textures.length&&(this._textures=new Ri(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,s,r,n,a,o){this._effectWrapper.updateEffect(e,t,i,s,r,n,a,o),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join("\n"):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,i=0){for(let s=0;s<this._textureCache.length;s++)if(this._textureCache[s].texture.width===e.width&&this._textureCache[s].texture.height===e.height&&this._textureCache[s].postProcessChannel===i&&this._textureCache[s].texture._generateDepthBuffer===t.generateDepthBuffer&&this._textureCache[s].texture.samples===t.samples)return this._textureCache[s].texture;const s=this._engine.createRenderTargetTexture(e,t);return this._textureCache.push({texture:s,postProcessChannel:i,lastUsedRenderId:-1}),s}_flushTextureCache(){const e=this._renderId;for(let t=this._textureCache.length-1;t>=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let e=!1;for(let i=0;i<this._textures.length;i++)if(this._textures.data[i]===this._textureCache[t].texture){e=!0;break}e||(this._textureCache[t].texture.dispose(),this._textureCache.splice(t,1))}}resize(e,t,i=null,s=!1,r=!1){this._textures.length>0&&this._textures.reset(),this.width=e,this.height=t;let n=null;if(i)for(let e=0;e<i._postProcesses.length;e++)if(null!==i._postProcesses[e]){n=i._postProcesses[e];break}const a={width:this.width,height:this.height},o={generateMipMaps:s,generateDepthBuffer:r||n===this,generateStencilBuffer:(r||n===this)&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType,format:this._textureFormat,samples:this._samples,label:"PostProcessRTT-"+this.name};this._textures.push(this._createRenderTargetTexture(a,o,0)),this._reusable&&this._textures.push(this._createRenderTargetTexture(a,o,1)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}_getTarget(){let e;if(this._shareOutputWithPostProcess)e=this._shareOutputWithPostProcess.inputTexture;else if(this._forcedOutputTexture)e=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height;else{let t;e=this.inputTexture;for(let i=0;i<this._textureCache.length;i++)if(this._textureCache[i].texture===e){t=this._textureCache[i];break}t&&(t.lastUsedRenderId=this._renderId)}return e}activate(e,t=null,i){const s=null===e||void 0!==e.cameraRigMode?e||this._camera:null,r=s?.getScene()??e,n=r.getEngine(),a=n.getCaps().maxTextureSize,o=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,h=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0;let l=this._options.width||o,c=this._options.height||h;const u=this.renderTargetSamplingMode!==Ve.TEXTURE_NEAREST_LINEAR&&this.renderTargetSamplingMode!==Ve.TEXTURE_NEAREST_NEAREST&&this.renderTargetSamplingMode!==Ve.TEXTURE_LINEAR_LINEAR;let d=null;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){const e=n.currentViewport;e&&(l*=e.width,c*=e.height)}(u||this.alwaysForcePOT)&&(this._options.width||(l=n.needPOTTextures?fi(l,a,this.scaleMode):l),this._options.height||(c=n.needPOTTextures?fi(c,a,this.scaleMode):c)),this.width===l&&this.height===c&&(d=this._getTarget())||this.resize(l,c,s,u,i),this._textures.forEach((e=>{e.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(e,this.samples)})),this._flushTextureCache(),this._renderId++}return d||(d=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(o/l,h/c),this._engine.bindFramebuffer(d,0,o,h,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(d,0,void 0,void 0,this.forceFullscreenViewport)),this._engine._debugInsertMarker?.(`post process ${this.name} input`),this.onActivateObservable.notifyObservers(s),this.autoClear&&(this.alphaMode===Ve.ALPHA_DISABLE||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:r.clearColor,r._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),d}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;let e;return this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e?.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(),this._effectWrapper.drawWrapper.effect}_disposeTextures(){this._shareOutputWithPostProcess||this._forcedOutputTexture?this._disposeTextureCache():(this._disposeTextureCache(),this._textures.dispose())}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)}dispose(e){let t;if(e=e||this._camera,this._disposeTextures(),this._scene&&(t=this._scene.postProcesses.indexOf(this),-1!==t&&this._scene.postProcesses.splice(t,1)),this._parentContainer){const e=this._parentContainer.postProcesses.indexOf(this);e>-1&&this._parentContainer.postProcesses.splice(e,1),this._parentContainer=null}if(t=this._engine.postProcesses.indexOf(this),-1!==t&&this._engine.postProcesses.splice(t,1),e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),0===t&&e._postProcesses.length>0){const e=this._camera._getFirstPostProcess();e&&e.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear(),this.onEffectCreatedObservable.clear()}}serialize(){const e=de.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.uniformBuffers=this._uniformBuffers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e}clone(){const e=this.serialize();e._engine=this._engine,e.cameraId=null;const t=Cn.Parse(e,this._scene,"");return t?(t.onActivateObservable=this.onActivateObservable.clone(),t.onSizeChangedObservable=this.onSizeChangedObservable.clone(),t.onApplyObservable=this.onApplyObservable.clone(),t.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),t.onAfterRenderObservable=this.onAfterRenderObservable.clone(),t._prePassEffectConfiguration=this._prePassEffectConfiguration,t):null}static Parse(e,t,i){const s=C(e.customType);if(!s||!s._Parse)return null;const r=t?t.getCameraById(e.cameraId):null;return s._Parse(e,r,t,i)}static _Parse(e,t,i,s){return de.Parse((()=>new Cn(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat)),e,i,s)}}e([a()],Cn.prototype,"uniqueId",void 0),e([a()],Cn.prototype,"name",null),e([a()],Cn.prototype,"width",void 0),e([a()],Cn.prototype,"height",void 0),e([a()],Cn.prototype,"renderTargetSamplingMode",void 0),e([_()],Cn.prototype,"clearColor",void 0),e([a()],Cn.prototype,"autoClear",void 0),e([a()],Cn.prototype,"forceAutoClearInAlphaMode",void 0),e([a()],Cn.prototype,"alphaMode",null),e([a()],Cn.prototype,"alphaConstants",void 0),e([a()],Cn.prototype,"enablePixelPerfectMode",void 0),e([a()],Cn.prototype,"forceFullscreenViewport",void 0),e([a()],Cn.prototype,"scaleMode",void 0),e([a()],Cn.prototype,"alwaysForcePOT",void 0),e([a("samples")],Cn.prototype,"_samples",void 0),e([a()],Cn.prototype,"adaptScaleToCurrentViewport",void 0),S("BABYLON.PostProcess",Cn);class Pn{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=v(e,this._renderListHasChanged)),this._renderList=e)}get renderPassIds(){return this._renderPassIds}get currentRefreshId(){return this._currentRefreshId}setMaterialForRendering(e,t){let i;i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;++e)for(let s=0;s<this.options.numPasses;++s)i[e].setMaterialForRenderPass(this._renderPassIds[s],void 0!==t?Array.isArray(t)?t[s]:t:void 0)}constructor(e,t,i){this._unObserveRenderList=null,this._renderListHasChanged=(e,t)=>{const i=this._renderList?this._renderList.length:0;(0===t&&i>0||0===i)&&this._scene.meshes.forEach((e=>{e._markSubMeshesAsLightDirty()}))},this.particleSystemList=null,this.getCustomRenderList=null,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.onBeforeRenderObservable=new A,this.onAfterRenderObservable=new A,this.onBeforeRenderingManagerRenderObservable=new A,this.onAfterRenderingManagerRenderObservable=new A,this.onFastPathRenderObservable=new A,this._currentRefreshId=-1,this._refreshRate=1,this._currentSceneCamera=null,this.name=e,this._scene=t,this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,...i},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new Ur(t),this._renderingManager._useSceneAutoClearSetup=!0}_releaseRenderPassId(){const e=this._scene.getEngine();for(let t=0;t<this.options.numPasses;++t)e.releaseRenderPassId(this._renderPassIds[t]);this._renderPassIds.length=0}_createRenderPassId(){this._releaseRenderPassId();const e=this._scene.getEngine();for(let t=0;t<this.options.numPasses;++t)this._renderPassIds[t]=e.createRenderPassId(`ObjectRenderer - ${this.name}#${t}`)}resetRefreshCounter(){this._currentRefreshId=-1}get refreshRate(){return this._refreshRate}set refreshRate(e){this._refreshRate=e,this.resetRefreshCounter()}shouldRender(){return-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)}isReadyForRendering(e,t){this.prepareRenderList(),this.initRender(e,t);const i=this._checkReadiness();return this.finishRender(),i}prepareRenderList(){const e=this._scene;if(this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(let t=0;t<this._waitingRenderList.length;t++){const i=this._waitingRenderList[t],s=e.getMeshById(i);s&&this.renderList.push(s)}}this._waitingRenderList=void 0}if(this.renderListPredicate){this.renderList?this.renderList.length=0:this.renderList=[];const e=this._scene.meshes;for(let t=0;t<e.length;t++){const i=e[t];this.renderListPredicate(i)&&this.renderList.push(i)}}}initRender(e,t){const i=this._scene.getEngine(),s=this.activeCamera??this._scene.activeCamera;this._currentSceneCamera=this._scene.activeCamera,s&&(s!==this._scene.activeCamera&&(this._scene.setTransformMatrix(s.getViewMatrix(),s.getProjectionMatrix(!0)),this._scene.activeCamera=s),i.setViewport(s.rigParent?s.rigParent.viewport:s.viewport,e,t)),this._defaultRenderListPrepared=!1}finishRender(){const e=this._scene;e.activeCamera=this._currentSceneCamera,this._currentSceneCamera&&(this.activeCamera&&this.activeCamera!==e.activeCamera&&e.setTransformMatrix(this._currentSceneCamera.getViewMatrix(),this._currentSceneCamera.getProjectionMatrix(!0)),e.getEngine().setViewport(this._currentSceneCamera.viewport)),e.resetCachedMaterial()}render(e=0,t=!1){const i=this._scene,s=i.getEngine(),r=s.currentRenderPassId;s.currentRenderPassId=this._renderPassIds[e],this.onBeforeRenderObservable.notifyObservers(e);if(s.snapshotRendering&&s.snapshotRenderingMode===Ve.SNAPSHOTRENDERING_FAST)this.onFastPathRenderObservable.notifyObservers(e);else{let t=null;const s=this.renderList?this.renderList:i.getActiveMeshes().data,r=this.renderList?this.renderList.length:i.getActiveMeshes().length;this.getCustomRenderList&&(t=this.getCustomRenderList(e,s,r)),t?this._prepareRenderingManager(t,t.length,this.forceLayerMaskCheck):(this._defaultRenderListPrepared||(this._prepareRenderingManager(s,r,!this.renderList||this.forceLayerMaskCheck),this._defaultRenderListPrepared=!0),t=s),this.onBeforeRenderingManagerRenderObservable.notifyObservers(e),this._renderingManager.render(this.customRenderFunction,t,this.renderParticles,this.renderSprites),this.onAfterRenderingManagerRenderObservable.notifyObservers(e)}t||this.onAfterRenderObservable.notifyObservers(e),s.currentRenderPassId=r}_checkReadiness(){const e=this._scene,t=e.getEngine(),i=t.currentRenderPassId;let s=!0;e.getViewMatrix()||e.updateTransformMatrix();const r=this.options.numPasses;for(let i=0;i<r&&s;i++){let n=null;const a=this.renderList?this.renderList:e.getActiveMeshes().data,o=this.renderList?this.renderList.length:e.getActiveMeshes().length;t.currentRenderPassId=this._renderPassIds[i],this.onBeforeRenderObservable.notifyObservers(i),this.getCustomRenderList&&(n=this.getCustomRenderList(i,a,o)),n||(n=a),this._doNotChangeAspectRatio||e.updateTransformMatrix(!0);for(let e=0;e<n.length&&s;++e){const t=n[e];if(t.isEnabled()&&!t.isBlocked&&t.isVisible&&t.subMeshes)if(this.customIsReadyFunction){if(!this.customIsReadyFunction(t,this.refreshRate,!0)){s=!1;continue}}else if(!t.isReady(!0)){s=!1;continue}}this.onAfterRenderObservable.notifyObservers(i),r>1&&(e.incrementRenderId(),e.resetCachedMaterial())}const n=this.particleSystemList||e.particleSystems;for(const e of n)e.isReady()||(s=!1);return t.currentRenderPassId=i,s}_prepareRenderingManager(e,t,i){const s=this._scene,r=s.activeCamera;this._renderingManager.reset();const n=s.getRenderId();for(let a=0;a<t;a++){const t=e[a];if(t&&!t.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(t,this.refreshRate,!1)){this.resetRefreshCounter();continue}}else if(!t.isReady(0===this.refreshRate)){this.resetRefreshCounter();continue}if(!t._internalAbstractMeshDataInfo._currentLODIsUpToDate&&r&&(t._internalAbstractMeshDataInfo._currentLOD=s.customLODSelector?s.customLODSelector(t,r):t.getLOD(r),t._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0),!t._internalAbstractMeshDataInfo._currentLOD)continue;let e,a=t._internalAbstractMeshDataInfo._currentLOD;if(a!==t&&0!==a.billboardMode&&a.computeWorldMatrix(),a._preActivateForIntermediateRendering(n),e=!(!i||!r)&&!(t.layerMask&r.layerMask),t.isEnabled()&&t.isVisible&&t.subMeshes&&!e){if(a!==t&&a._activate(n,!0),t._activate(n,!0)&&t.subMeshes.length){t.isAnInstance?t._internalAbstractMeshDataInfo._actAsRegularMesh&&(a=t):a._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,a._internalAbstractMeshDataInfo._isActiveIntermediate=!0,s._prepareSkeleton(a);for(let e=0;e<a.subMeshes.length;e++){const t=a.subMeshes[e];this._renderingManager.dispatch(t,a)}}t._postActivate()}}}const a=this.particleSystemList||s.particleSystems;for(let e=0;e<a.length;e++){const t=a[e],i=t.emitter;t.isStarted()&&i&&(!i.position||i.isEnabled())&&this._renderingManager.dispatchParticles(t)}}setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t),this._renderingManager._useSceneAutoClearSetup=!1}clone(){const e=new Pn(this.name,this._scene,this.options);return this.renderList&&(e.renderList=this.renderList.slice(0)),e}dispose(){const e=this.renderList?this.renderList:this._scene.getActiveMeshes().data,t=this.renderList?this.renderList.length:this._scene.getActiveMeshes().length;for(let i=0;i<t;i++){const t=e[i];void 0!==t.getMaterialForRenderPass(this.renderPassId)&&t.setMaterialForRenderPass(this.renderPassId,void 0)}this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderingManagerRenderObservable.clear(),this.onAfterRenderingManagerRenderObservable.clear(),this.onFastPathRenderObservable.clear(),this._releaseRenderPassId(),this.renderList=null}_rebuild(){this.refreshRate===Pn.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Pn.REFRESHRATE_RENDER_ONCE)}freeRenderingGroups(){this._renderingManager&&this._renderingManager.freeRenderingGroups()}}Pn.REFRESHRATE_RENDER_ONCE=0,Pn.REFRESHRATE_RENDER_ONEVERYFRAME=1,Pn.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,Ct.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t,e)};class On extends bn{get renderListPredicate(){return this._objectRenderer.renderListPredicate}set renderListPredicate(e){this._objectRenderer.renderListPredicate=e}get renderList(){return this._objectRenderer.renderList}set renderList(e){this._objectRenderer.renderList=e}get particleSystemList(){return this._objectRenderer.particleSystemList}set particleSystemList(e){this._objectRenderer.particleSystemList=e}get getCustomRenderList(){return this._objectRenderer.getCustomRenderList}set getCustomRenderList(e){this._objectRenderer.getCustomRenderList=e}get renderParticles(){return this._objectRenderer.renderParticles}set renderParticles(e){this._objectRenderer.renderParticles=e}get renderSprites(){return this._objectRenderer.renderSprites}set renderSprites(e){this._objectRenderer.renderSprites=e}get forceLayerMaskCheck(){return this._objectRenderer.forceLayerMaskCheck}set forceLayerMaskCheck(e){this._objectRenderer.forceLayerMaskCheck=e}get activeCamera(){return this._objectRenderer.activeCamera}set activeCamera(e){this._objectRenderer.activeCamera=e}get customIsReadyFunction(){return this._objectRenderer.customIsReadyFunction}set customIsReadyFunction(e){this._objectRenderer.customIsReadyFunction=e}get customRenderFunction(){return this._objectRenderer.customRenderFunction}set customRenderFunction(e){this._objectRenderer.customRenderFunction=e}get postProcesses(){return this._postProcesses}get _prePassEnabled(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled}set onAfterUnbind(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)}get onBeforeRenderObservable(){return this._objectRenderer.onBeforeRenderObservable}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}get onAfterRenderObservable(){return this._objectRenderer.onAfterRenderObservable}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}set onClear(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)}get _waitingRenderList(){return this._objectRenderer._waitingRenderList}set _waitingRenderList(e){this._objectRenderer._waitingRenderList=e}get renderPassId(){return this._objectRenderer.renderPassId}get renderPassIds(){return this._objectRenderer.renderPassIds}get currentRefreshId(){return this._objectRenderer.currentRefreshId}setMaterialForRendering(e,t){this._objectRenderer.setMaterialForRendering(e,t)}get isMulti(){return this._renderTarget?.isMulti??!1}get renderTargetOptions(){return this._renderTargetOptions}get renderTarget(){return this._renderTarget}_onRatioRescale(){this._sizeRatio&&this.resize(this._initialSizeParameter)}set boundingBoxSize(e){if(this._boundingBoxSize&&this._boundingBoxSize.equals(e))return;this._boundingBoxSize=e;const t=this.getScene();t&&t.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag)}get boundingBoxSize(){return this._boundingBoxSize}get depthStencilTexture(){return this._renderTarget?._depthStencilTexture??null}constructor(e,t,i,s=!1,r=!0,n=Ve.TEXTURETYPE_UNSIGNED_BYTE,a=!1,o=bn.TRILINEAR_SAMPLINGMODE,h=!0,l=!1,c=!1,u=Ve.TEXTUREFORMAT_RGBA,d=!1,_,f,p=!1,g=!1){let m,T=!0;if("object"==typeof s){const e=s;s=!!e.generateMipMaps,r=e.doNotChangeAspectRatio??!0,n=e.type??Ve.TEXTURETYPE_UNSIGNED_BYTE,a=!!e.isCube,o=e.samplingMode??bn.TRILINEAR_SAMPLINGMODE,h=e.generateDepthBuffer??!0,l=!!e.generateStencilBuffer,c=!!e.isMulti,u=e.format??Ve.TEXTUREFORMAT_RGBA,d=!!e.delayAllocation,_=e.samples,f=e.creationFlags,p=!!e.noColorAttachment,g=!!e.useSRGBBuffer,m=e.colorAttachment,T=e.gammaSpace??T}if(super(null,i,!s,void 0,o,void 0,void 0,void 0,void 0,u),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new A,this.onAfterUnbindObservable=new A,this.onClearObservable=new A,this.onResizeObservable=new A,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this.boundingBoxPosition=X.Zero(),this._disableEngineStages=!1,this._dumpToolsLoading=!1,!(i=this.getScene()))return;const E=this.getScene().getEngine();this._gammaSpace=T,this._coordinatesMode=bn.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._processSizeParameter(t),this._objectRenderer=new Pn(e,i,{numPasses:a?6:this.getRenderLayers()||1,doNotChangeAspectRatio:r}),this._objectRenderer.onBeforeRenderingManagerRenderObservable.add((()=>{if(!this._disableEngineStages)for(const e of this._scene._beforeRenderTargetClearStage)e.action(this,this._currentFaceIndex,this._currentLayer);if(this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(E):this.skipInitialClear||E.clear(this.clearColor||this._scene.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),!this._disableEngineStages)for(const e of this._scene._beforeRenderTargetDrawStage)e.action(this,this._currentFaceIndex,this._currentLayer)})),this._objectRenderer.onAfterRenderingManagerRenderObservable.add((()=>{if(!this._disableEngineStages)for(const e of this._scene._afterRenderTargetDrawStage)e.action(this,this._currentFaceIndex,this._currentLayer);const e=this._texture?.generateMipMaps??!1;if(this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex),!this._disableEngineStages)for(const e of this._scene._afterRenderTargetPostProcessStage)e.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=e),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),E):Ae.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))})),this._objectRenderer.onFastPathRenderObservable.add((()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(E):this.skipInitialClear||E.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)})),this._resizeObserver=E.onResizeObservable.add((()=>{})),this._generateMipMaps=!!s,this._doNotChangeAspectRatio=r,c||(this._renderTargetOptions={generateMipMaps:s,type:n,format:this._format??void 0,samplingMode:this.samplingMode,generateDepthBuffer:h,generateStencilBuffer:l,samples:_,creationFlags:f,noColorAttachment:p,useSRGBBuffer:g,colorAttachment:m,label:this.name},this.samplingMode===bn.NEAREST_SAMPLINGMODE&&(this.wrapU=bn.CLAMP_ADDRESSMODE,this.wrapV=bn.CLAMP_ADDRESSMODE),d||(a?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=bn.INVCUBIC_MODE,this._textureMatrix=j.Identity()):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==_&&(this.samples=_)))}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=Ve.TEXTUREFORMAT_DEPTH32_FLOAT,n){this._renderTarget?.createDepthStencilTexture(e,t,i,s,r,n)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;const t=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(t.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(t.getRenderHeight(),this._sizeRatio)}}else this._size=e}get samples(){return this._renderTarget?.samples??this._samples}set samples(e){this._renderTarget&&(this._samples=this._renderTarget.setSamples(e))}addPostProcess(e){if(!this._postProcessManager){const e=this.getScene();if(!e)return;this._postProcessManager=new wr(e),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(const e of this._postProcesses)e.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;const t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}resetRefreshCounter(){this._objectRenderer.resetRefreshCounter()}get refreshRate(){return this._objectRenderer.refreshRate}set refreshRate(e){this._objectRenderer.refreshRate=e}_shouldRender(){return this._objectRenderer.shouldRender()}getRenderSize(){return this.getRenderWidth()}getRenderWidth(){return this._size.width?this._size.width:this._size}getRenderHeight(){return this._size.width?this._size.height:this._size}getRenderLayers(){const e=this._size.layers;if(e)return e;const t=this._size.depth;return t||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){const t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){const t=this.isCube;this._renderTarget?.dispose(),this._renderTarget=null;const i=this.getScene();i&&(this._processSizeParameter(e),this._renderTarget=t?i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==this._renderTargetOptions.samples&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))}render(e=!1,t=!1){this._render(e,t)}isReadyForRendering(){this._dumpToolsLoading||(this._dumpToolsLoading=!0,import("./dumpTools-a-Jxv0UI.esm.min.js").then((e=>this._dumpTools=e))),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());const e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){const i=this.getScene();if(i){if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight()),!this.is2DArray&&!this.is3D||this.isMulti)if(this.isCube&&!this.isMulti)for(let s=0;s<6;s++)this._renderToTarget(s,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this._renderToTarget(0,e,t);else for(let s=0;s<this.getRenderLayers();s++)this._renderToTarget(0,e,t,s),i.incrementRenderId(),i.resetCachedMaterial();this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender()}}_bestReflectionRenderTargetDimension(e,t){const i=e*t,s=ui(i+16384/(128+i));return Math.min(_i(e),s)}_bindFrameBuffer(e=0,t=0){const i=this.getScene();if(!i)return;const s=i.getEngine();this._renderTarget&&s.bindFramebuffer(this._renderTarget,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindFramebuffer(this._renderTarget,this.isCube,(()=>{this.onAfterRenderObservable.notifyObservers(t)}))}_prepareFrame(e,t,i,s){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses):s&&e.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(t,i)}_renderToTarget(e,t,i,s=0){const r=this.getScene();if(!r)return;const n=r.getEngine();this._currentFaceIndex=e,this._currentLayer=s,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(r,e,s,t),n._debugPushGroup?.(`render to face #${e} layer #${s}`,2),this._objectRenderer.render(e+s,!0),n._debugPopGroup?.(2),this._unbindFrameBuffer(n,e),this._texture&&this.isCube&&5===e&&n.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,i=null,s=null){this._objectRenderer.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){const e=this.getSize(),t=new On(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t}serialize(){if(!this.name)return null;const e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t<this.renderList.length;t++)e.renderList.push(this.renderList[t].id);return e}disposeFramebufferObjects(){this._renderTarget?.dispose(!0)}releaseInternalTexture(){this._renderTarget?.releaseTextures(),this._texture=null}dispose(){this.onResizeObservable.clear(),this.onClearObservable.clear(),this.onAfterUnbindObservable.clear(),this.onBeforeBindObservable.clear(),this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this._prePassRenderTarget&&this._prePassRenderTarget.dispose(),this._objectRenderer.dispose(),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null);const e=this.getScene();if(!e)return;let t=e.customRenderTargets.indexOf(this);t>=0&&e.customRenderTargets.splice(t,1);for(const i of e.cameras)t=i.customRenderTargets.indexOf(this),t>=0&&i.customRenderTargets.splice(t,1);this._renderTarget?.dispose(),this._renderTarget=null,this._texture=null,super.dispose()}_rebuild(){this._objectRenderer._rebuild(),this._postProcessManager&&this._postProcessManager._rebuild()}freeRenderingGroups(){this._objectRenderer.freeRenderingGroups()}getViewCount(){return 1}}On.REFRESHRATE_RENDER_ONCE=Pn.REFRESHRATE_RENDER_ONCE,On.REFRESHRATE_RENDER_ONEVERYFRAME=Pn.REFRESHRATE_RENDER_ONEVERYFRAME,On.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Pn.REFRESHRATE_RENDER_ONEVERYTWOFRAMES,bn._CreateRenderTargetTexture=(e,t,i,s,r)=>new On(e,t,i,s);class Dn extends Cn{getClassName(){return"PassPostProcess"}constructor(e,t,i=null,s,r,n,a=Ve.TEXTURETYPE_UNSIGNED_BYTE,o=!1){super(e,"pass",null,null,t,i,s,r,n,void 0,a,void 0,null,o)}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([import("./pass.fragment-DvFaAVdg.esm.min.js")]))):t.push(Promise.all([import("./pass.fragment-DfyFrxFg.esm.min.js")])),super._gatherImports(e,t)}static _Parse(e,t,i,s){return de.Parse((()=>new Dn(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable)),e,i,s)}}let Ln,Fn;function wn(e){Ln||(Ln=new Float32Array(1),Fn=new Int32Array(Ln.buffer)),Ln[0]=e;const t=Fn[0];let i=t>>16&32768,s=t>>12&2047;const r=t>>23&255;return r<103?i:r>142?(i|=31744,i|=(255==r?0:1)&&8388607&t,i):r<113?(s|=2048,i|=(s>>114-r)+(s>>113-r&1),i):(i|=r-112<<10|s>>1,i+=1&s,i)}function Nn(e){const t=(32768&e)>>15,i=(31744&e)>>10,s=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(s/Math.pow(2,10)):31==i?s?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+s/Math.pow(2,10))}S("BABYLON.PassPostProcess",Dn),Wt._RescalePostProcessFactory=e=>new Dn("rescale",1,null,Ve.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,Ve.TEXTURETYPE_UNSIGNED_BYTE);class Bn{static ExpandRGBDTexture(e){const t=e._texture;if(!t||!e.isRGBD)return;const i=t.getEngine(),s=i.getCaps(),r=t.isReady;let n=!1;s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?(n=!0,t.type=Ve.TEXTURETYPE_HALF_FLOAT):s.textureFloatRender&&s.textureFloatLinearFiltering&&(n=!0,t.type=Ve.TEXTURETYPE_FLOAT),n&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);const a=async()=>{const s=i.isWebGPU,r=s?1:0;t.isReady=!1,s?await import("./rgbdDecode.fragment-Cwx1U7TE.esm.min.js"):await import("./rgbdDecode.fragment-DAz-9d4q.esm.min.js");const n=new Cn("rgbdDecode","rgbdDecode",null,null,1,null,Ve.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!1,void 0,t.type,void 0,null,!1,void 0,r);n.externalTextureSamplerBinding=!0;const a=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:Ve.TEXTUREFORMAT_RGBA});n.onEffectCreatedObservable.addOnce((s=>{s.executeWhenCompiled((()=>{n.onApply=e=>{e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([n],a,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),n&&n.dispose(),a._swapAndDie(t),t.isReady=!0}))}))};n&&(r?a():e.onLoadObservable.addOnce(a))}static async EncodeTextureToRGBD(e,t,i=Ve.TEXTURETYPE_UNSIGNED_BYTE){return t.getEngine().isWebGPU?await import("./rgbdEncode.fragment-B-B_-l4T.esm.min.js"):await import("./rgbdEncode.fragment-D2kStupC.esm.min.js"),function(e,t,i,s,r,n,a,o){const h=t.getEngine();return t.isReady=!1,r=r??t.samplingMode,s=s??t.type,n=n??t.format,a=a??t.width,o=o??t.height,-1===s&&(s=Ve.TEXTURETYPE_UNSIGNED_BYTE),new Promise((l=>{const c=new Cn("postprocess",e,null,null,1,null,r,h,!1,void 0,s,void 0,null,!1,n);c.externalTextureSamplerBinding=!0;const u=h.createRenderTargetTexture({width:a,height:o},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:r,type:s,format:n});c.onEffectCreatedObservable.addOnce((e=>{e.executeWhenCompiled((()=>{c.onApply=e=>{e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},i.postProcessManager.directRender([c],u,!0),h.restoreDefaultFramebuffer(),h._releaseTexture(t),c&&c.dispose(),u._swapAndDie(t),t.type=s,t.format=Ve.TEXTUREFORMAT_RGBA,t.isReady=!0,l(t)}))}))}))}("rgbdEncode",e,t,i,Ve.TEXTURE_NEAREST_SAMPLINGMODE,Ve.TEXTUREFORMAT_RGBA)}}let Un=0;const kn=e=>{if(!e.environmentBRDFTexture){const t=e.useDelayedTextureLoading;e.useDelayedTextureLoading=!1;const i=e._blockEntityCollection;e._blockEntityCollection=!1;const s=bn.CreateFromBase64String("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==","EnvironmentBRDFTexture"+Un++,e,!0,!1,bn.BILINEAR_SAMPLINGMODE);e._blockEntityCollection=i;const r=e.getEngine().getLoadedTexturesCache(),n=r.indexOf(s.getInternalTexture());-1!==n&&r.splice(n,1),s.isRGBD=!0,s.wrapU=bn.CLAMP_ADDRESSMODE,s.wrapV=bn.CLAMP_ADDRESSMODE,e.environmentBRDFTexture=s,e.useDelayedTextureLoading=t,Bn.ExpandRGBDTexture(s);const a=e.getEngine().onContextRestoredObservable.add((()=>{s.isRGBD=!0;const t=e.onBeforeRenderObservable.add((()=>{s.isReady()&&(e.onBeforeRenderObservable.remove(t),Bn.ExpandRGBDTexture(s))}))}));e.onDisposeObservable.add((()=>{e.getEngine().onContextRestoredObservable.remove(a)}))}return e.environmentBRDFTexture};class Vn{constructor(e){if(this._keys=[],this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1,this._externalProperties=e,e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!1,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(const e of Object.keys(this))"_"!==e[0]&&this._keys.push(e);if(this._externalProperties)for(const e in this._externalProperties)-1===this._keys.indexOf(e)&&this._keys.push(e)}isEqual(e){if(this._keys.length!==e._keys.length)return!1;for(let t=0;t<this._keys.length;t++){const i=this._keys[t];if(this[i]!==e[i])return!1}return!0}cloneTo(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(let t=0;t<this._keys.length;t++){const i=this._keys[t];e[i]=this[i]}}reset(){this._keys.forEach((e=>this._setDefaultValue(e)))}_setDefaultValue(e){const t=this._externalProperties?.[e]?.type??typeof this[e],i=this._externalProperties?.[e]?.default;switch(t){case"number":this[e]=i??0;break;case"string":this[e]=i??"";break;default:this[e]=i??!1}}toString(){let e="";for(let t=0;t<this._keys.length;t++){const i=this._keys[t],s=this[i];switch(typeof s){case"number":case"string":e+="#define "+i+" "+s+"\n";break;default:s&&(e+="#define "+i+"\n")}}return e}}const zn=new RegExp("^([gimus]+)!");class Gn{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let t=0;t<this._plugins.length;++t)if(this._plugins[t].name===e.name)return!1;if(this._material._uniformBufferLayoutBuilt&&(this._material.resetDrawCache(),this._material._createUniformBuffer()),!e.isCompatible(this._material.shaderLanguage))throw`The plugin "${e.name}" can't be added to the material "${this._material.name}" because the plugin is not compatible with the shader language of the material.`;const t=e.getClassName();Gn._MaterialPluginClassToMainDefine[t]||(Gn._MaterialPluginClassToMainDefine[t]="MATERIALPLUGIN_"+ ++Gn._MaterialPluginCounter),this._material._callbackPluginEventGeneric=(e,t)=>this._handlePluginEvent(e,t),this._plugins.push(e),this._plugins.sort(((e,t)=>e.priority-t.priority)),this._codeInjectionPoints={};const i={};i[Gn._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(const e of this._plugins)e.collectDefines(i),this._collectPointNames("vertex",e.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",e.getCustomCode("fragment",this._material.shaderLanguage));return this._defineNamesFromPlugins=i,!0}_activatePlugin(e){-1===this._activePlugins.indexOf(e)&&(this._activePlugins.push(e),this._activePlugins.sort(((e,t)=>e.priority-t.priority)),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefinesBeforeAttributes=this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),e.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(e),this._activePluginsForExtraEvents.sort(((e,t)=>e.priority-t.priority)),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRenderTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))}getPlugin(e){for(let t=0;t<this._plugins.length;++t)if(this._plugins[t].name===e)return this._plugins[t];return null}_handlePluginEventIsReadyForSubMesh(e){let t=!0;for(const i of this._activePlugins)t=t&&i.isReadyForSubMesh(e.defines,this._scene,this._engine,e.subMesh);e.isReadyForSubMesh=t}_handlePluginEventPrepareDefinesBeforeAttributes(e){for(const t of this._activePlugins)t.prepareDefinesBeforeAttributes(e.defines,this._scene,e.mesh)}_handlePluginEventPrepareDefines(e){for(const t of this._activePlugins)t.prepareDefines(e.defines,this._scene,e.mesh)}_handlePluginEventHardBindForSubMesh(e){for(const t of this._activePluginsForExtraEvents)t.hardBindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,e.subMesh)}_handlePluginEventBindForSubMesh(e){for(const t of this._activePlugins)t.bindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,e.subMesh)}_handlePluginEventHasRenderTargetTextures(e){let t=!1;for(const e of this._activePluginsForExtraEvents)if(t=e.hasRenderTargetTextures(),t)break;e.hasRenderTargetTextures=t}_handlePluginEventFillRenderTargetTextures(e){for(const t of this._activePluginsForExtraEvents)t.fillRenderTargetTextures(e.renderTargets)}_handlePluginEvent(e,t){switch(e){case 512:{const e=t;for(const t of this._activePlugins)t.getActiveTextures(e.activeTextures);break}case 256:{const e=t;for(const t of this._activePlugins)t.getAnimatables(e.animatables);break}case 1024:{const e=t;let i=!1;for(const t of this._activePlugins)if(i=t.hasTexture(e.texture),i)break;e.hasTexture=i;break}case 2:{const e=t;for(const t of this._plugins)t.dispose(e.forceDisposeTextures);break}case 4:t.defineNames=this._defineNamesFromPlugins;break;case 128:{const e=t;for(const t of this._activePlugins)e.fallbackRank=t.addFallbacks(e.defines,e.fallbacks,e.fallbackRank),t.getAttributes(e.attributes,this._scene,e.mesh);this._uniformList.length>0&&e.uniforms.push(...this._uniformList),this._samplerList.length>0&&e.samplers.push(...this._samplerList),this._uboList.length>0&&e.uniformBuffersNames.push(...this._uboList),e.customCode=this._injectCustomCode(e,e.customCode);break}case 8:{const e=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];const i=1===this._material.shaderLanguage;for(const t of this._plugins){const s=t.getUniforms(this._material.shaderLanguage);if(s){if(s.ubo)for(const t of s.ubo){if(t.size&&t.type){const s=t.arraySize??0;if(e.ubo.addUniform(t.name,t.size,s),i){let e;switch(t.type){case"mat4":e="mat4x4f";break;case"float":e="f32";break;default:e=`${t.type}f`}this._uboDeclaration+=`uniform ${t.name}: ${e}${s>0?`[${s}]`:""};\n`}else this._uboDeclaration+=`${t.type} ${t.name}${s>0?`[${s}]`:""};\n`}this._uniformList.push(t.name)}s.vertex&&(this._vertexDeclaration+=s.vertex+"\n"),s.fragment&&(this._fragmentDeclaration+=s.fragment+"\n")}t.getSamplers(this._samplerList),t.getUniformBuffersNames(this._uboList)}break}}}_collectPointNames(e,t){if(t)for(const i in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][i]=!0}_injectCustomCode(e,t){return(i,s)=>{t&&(s=t(i,s)),this._uboDeclaration&&(s=s.replace("#define ADDITIONAL_UBO_DECLARATION",this._uboDeclaration)),this._vertexDeclaration&&(s=s.replace("#define ADDITIONAL_VERTEX_DECLARATION",this._vertexDeclaration)),this._fragmentDeclaration&&(s=s.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",this._fragmentDeclaration));const r=this._codeInjectionPoints?.[i];if(!r)return s;let n=null;for(let t in r){let r="";for(const s of this._activePlugins){let a=s.getCustomCode(i,this._material.shaderLanguage)?.[t];if(a){if(s.resolveIncludes){if(null===n){const t=0;n={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:ct.GetShadersRepository(t),includesShadersStore:ct.GetIncludesShadersStore(t),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}}n.isFragment="fragment"===i,ot(a,n,(e=>a=e))}r+=a+"\n"}}if(r.length>0)if("!"===t.charAt(0)){t=t.substring(1);let e="g";if("!"===t.charAt(0))e="",t=t.substring(1);else{const i=zn.exec(t);i&&i.length>=2&&(e=i[1],t=t.substring(e.length+1))}e.indexOf("g")<0&&(e+="g");const i=s,n=new RegExp(t,e);let a=n.exec(i);for(;null!==a;){let e=r;for(let t=0;t<a.length;++t)e=e.replace("$"+t,a[t]);s=s.replace(a[0],e),a=n.exec(i)}}else{const e="#define "+t;s=s.replace(e,"\n"+r+"\n"+e)}}return s}}}Gn._MaterialPluginClassToMainDefine={},Gn._MaterialPluginCounter=0,O.OnEnginesDisposedObservable.add((()=>{Hn.length=0,ks.OnEventObservable.remove(Wn),Wn=null}));const Hn=[];let Wn=null;class Kn{isCompatible(e){return 0===e}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,s,r=!0,n=!1,a=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this.doNotSerialize=!1,this._material=e,this.name=t,this.priority=i,this.resolveIncludes=a,e.pluginManager||(e.pluginManager=new Gn(e),e.onDisposeObservable.add((()=>{e.pluginManager=void 0}))),this._pluginDefineNames=s,this._pluginManager=e.pluginManager,r&&this._pluginManager._addPlugin(this),n&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[Ve.MATERIAL_AllDirtyFlag]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,i,s){return!0}hardBindForSubMesh(e,t,i,s){}bindForSubMesh(e,t,i,s){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(const t of Object.keys(this._pluginDefineNames)){if("_"===t[0])continue;const i=typeof this._pluginDefineNames[t];e[t]={type:"number"===i?"number":"string"===i?"string":"boolean"===i?"boolean":"object",default:this._pluginDefineNames[t]}}}prepareDefinesBeforeAttributes(e,t,i){}prepareDefines(e,t,i){}hasTexture(e){return!1}hasRenderTargetTextures(){return!1}fillRenderTargetTextures(e){}getActiveTextures(e){}getAnimatables(e){}addFallbacks(e,t,i){return i}getSamplers(e){}getAttributes(e,t,i){}getUniformBuffersNames(e){}getUniforms(e=0){return{}}copyTo(e){de.Clone((()=>e),this)}serialize(){return de.Serialize(this)}parse(e,t,i){de.Parse((()=>this),e,t,i)}}e([a()],Kn.prototype,"name",void 0),e([a()],Kn.prototype,"priority",void 0),e([a()],Kn.prototype,"resolveIncludes",void 0),e([a()],Kn.prototype,"registerForExtraEvents",void 0),S("BABYLON.MaterialPluginBase",Kn);class Yn extends Vn{constructor(){super(...arguments),this.BRDF_V_HEIGHT_CORRELATED=!1,this.MS_BRDF_ENERGY_CONSERVATION=!1,this.SPHERICAL_HARMONICS=!1,this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1}}class Xn extends Kn{_markAllSubMeshesAsMiscDirty(){this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRBRDF",90,new Yn,t),this._useEnergyConservation=Xn.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=Xn.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=Xn.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=Xn.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=Xn.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=Xn.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=Xn.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=Xn.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[Ve.MATERIAL_MiscDirtyFlag],this._enable(!0)}prepareDefines(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation}getClassName(){return"PBRBRDFConfiguration"}}Xn.DEFAULT_USE_ENERGY_CONSERVATION=!0,Xn.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,Xn.DEFAULT_USE_SPHERICAL_HARMONICS=!0,Xn.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,e([a(),n("_markAllSubMeshesAsMiscDirty")],Xn.prototype,"useEnergyConservation",void 0),e([a(),n("_markAllSubMeshesAsMiscDirty")],Xn.prototype,"useSmithVisibilityHeightCorrelated",void 0),e([a(),n("_markAllSubMeshesAsMiscDirty")],Xn.prototype,"useSphericalHarmonics",void 0),e([a(),n("_markAllSubMeshesAsMiscDirty")],Xn.prototype,"useSpecularGlossinessInputEnergyConservation",void 0);class Qn{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,s,r){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&(-1!==t.prePassRenderer.getIndex(Ve.PREPASS_VELOCITY_TEXTURE_TYPE)||-1!==t.prePassRenderer.getIndex(Ve.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE))){this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=s.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());const r=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==r.frameId&&(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=s.clone()}}}class qn extends ks{constructor(e,t,i=!0,s=!1){super(e,t,void 0,s),this._normalMatrix=new j,this._storeEffectOnSubMeshes=i}getEffect(){return this._storeEffectOnSubMeshes?this._activeEffect:super.getEffect()}isReady(e,t){return!!e&&(!this._storeEffectOnSubMeshes||(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t)))}_isReadyForSubMesh(e){const t=e.materialDefines;return!(this.checkReadyOnEveryCall||!e.effect||!t||t._renderId!==this.getScene().getRenderId())}bindOnlyWorldMatrix(e){this._activeEffect.setMatrix("world",e)}bindOnlyNormalMatrix(e){this._activeEffect.setMatrix("normalMatrix",e)}bind(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])}_afterBind(e,t=null,i){super._afterBind(e,t,i),this.getScene()._cachedEffect=t,i?i._drawWrapper._forceRebindOnNextCall=!1:this._drawWrapper._forceRebindOnNextCall=!1}_mustRebind(e,t,i,s=1){return i._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,s)}dispose(e,t,i){this._activeEffect=void 0,super.dispose(e,t,i)}}class jn{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_FresnelDirtyFlag))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,Wt.MarkAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag))}}jn._DiffuseTextureEnabled=!0,jn._DetailTextureEnabled=!0,jn._DecalMapEnabled=!0,jn._AmbientTextureEnabled=!0,jn._OpacityTextureEnabled=!0,jn._ReflectionTextureEnabled=!0,jn._EmissiveTextureEnabled=!0,jn._SpecularTextureEnabled=!0,jn._BumpTextureEnabled=!0,jn._LightmapTextureEnabled=!0,jn._RefractionTextureEnabled=!0,jn._ColorGradingTextureEnabled=!0,jn._FresnelEnabled=!0,jn._ClearCoatTextureEnabled=!0,jn._ClearCoatBumpTextureEnabled=!0,jn._ClearCoatTintTextureEnabled=!0,jn._SheenTextureEnabled=!0,jn._AnisotropicTextureEnabled=!0,jn._ThicknessTextureEnabled=!0,jn._RefractionIntensityTextureEnabled=!0,jn._TranslucencyIntensityTextureEnabled=!0,jn._TranslucencyColorTextureEnabled=!0,jn._IridescenceTextureEnabled=!0;const Zn=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],Jn=[()=>1,e=>e.y,e=>e.z,e=>e.x,e=>e.x*e.y,e=>e.y*e.z,e=>3*e.z*e.z-1,e=>e.x*e.z,e=>e.x*e.x-e.y*e.y],$n=(e,t)=>Zn[e]*Jn[e](t),ea=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class ta{constructor(){this.preScaled=!1,this.l00=X.Zero(),this.l1_1=X.Zero(),this.l10=X.Zero(),this.l11=X.Zero(),this.l2_2=X.Zero(),this.l2_1=X.Zero(),this.l20=X.Zero(),this.l21=X.Zero(),this.l22=X.Zero()}addLight(e,t,i){J.Vector3[0].set(t.r,t.g,t.b);const s=J.Vector3[0],r=J.Vector3[1];s.scaleToRef(i,r),r.scaleToRef($n(0,e),J.Vector3[2]),this.l00.addInPlace(J.Vector3[2]),r.scaleToRef($n(1,e),J.Vector3[2]),this.l1_1.addInPlace(J.Vector3[2]),r.scaleToRef($n(2,e),J.Vector3[2]),this.l10.addInPlace(J.Vector3[2]),r.scaleToRef($n(3,e),J.Vector3[2]),this.l11.addInPlace(J.Vector3[2]),r.scaleToRef($n(4,e),J.Vector3[2]),this.l2_2.addInPlace(J.Vector3[2]),r.scaleToRef($n(5,e),J.Vector3[2]),this.l2_1.addInPlace(J.Vector3[2]),r.scaleToRef($n(6,e),J.Vector3[2]),this.l20.addInPlace(J.Vector3[2]),r.scaleToRef($n(7,e),J.Vector3[2]),this.l21.addInPlace(J.Vector3[2]),r.scaleToRef($n(8,e),J.Vector3[2]),this.l22.addInPlace(J.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(ea[0]),this.l1_1.scaleInPlace(ea[1]),this.l10.scaleInPlace(ea[2]),this.l11.scaleInPlace(ea[3]),this.l2_2.scaleInPlace(ea[4]),this.l2_1.scaleInPlace(ea[5]),this.l20.scaleInPlace(ea[6]),this.l21.scaleInPlace(ea[7]),this.l22.scaleInPlace(ea[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(Zn[0]),this.l1_1.scaleInPlace(Zn[1]),this.l10.scaleInPlace(Zn[2]),this.l11.scaleInPlace(Zn[3]),this.l2_2.scaleInPlace(Zn[4]),this.l2_1.scaleInPlace(Zn[5]),this.l20.scaleInPlace(Zn[6]),this.l21.scaleInPlace(Zn[7]),this.l22.scaleInPlace(Zn[8])}updateFromArray(e){return X.FromArrayToRef(e[0],0,this.l00),X.FromArrayToRef(e[1],0,this.l1_1),X.FromArrayToRef(e[2],0,this.l10),X.FromArrayToRef(e[3],0,this.l11),X.FromArrayToRef(e[4],0,this.l2_2),X.FromArrayToRef(e[5],0,this.l2_1),X.FromArrayToRef(e[6],0,this.l20),X.FromArrayToRef(e[7],0,this.l21),X.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return X.FromFloatsToRef(e[0],e[1],e[2],this.l00),X.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),X.FromFloatsToRef(e[6],e[7],e[8],this.l10),X.FromFloatsToRef(e[9],e[10],e[11],this.l11),X.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),X.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),X.FromFloatsToRef(e[18],e[19],e[20],this.l20),X.FromFloatsToRef(e[21],e[22],e[23],this.l21),X.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return(new ta).updateFromArray(e)}static FromPolynomial(e){const t=new ta;return t.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),t.l1_1=e.y.scale(.977204),t.l10=e.z.scale(.977204),t.l11=e.x.scale(.977204),t.l2_2=e.xy.scale(1.16538),t.l2_1=e.yz.scale(1.16538),t.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),t.l21=e.zx.scale(1.16538),t.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),t.l1_1.scaleInPlace(-1),t.l11.scaleInPlace(-1),t.l2_1.scaleInPlace(-1),t.l21.scaleInPlace(-1),t.scaleInPlace(Math.PI),t}}class ia{constructor(){this.x=X.Zero(),this.y=X.Zero(),this.z=X.Zero(),this.xx=X.Zero(),this.yy=X.Zero(),this.zz=X.Zero(),this.xy=X.Zero(),this.yz=X.Zero(),this.zx=X.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=ta.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){J.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=J.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(t)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),J.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),J.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(J.Vector3[0]).addInPlace(J.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(J.Vector3[0]).subtractInPlace(J.Vector3[1]),this.zz.copyFrom(e.l00),J.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(J.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return(new ia).updateFromHarmonics(e)}static FromArray(e){const t=new ia;return X.FromArrayToRef(e[0],0,t.x),X.FromArrayToRef(e[1],0,t.y),X.FromArrayToRef(e[2],0,t.z),X.FromArrayToRef(e[3],0,t.xx),X.FromArrayToRef(e[4],0,t.yy),X.FromArrayToRef(e[5],0,t.zz),X.FromArrayToRef(e[6],0,t.yz),X.FromArrayToRef(e[7],0,t.zx),X.FromArrayToRef(e[8],0,t.xy),t}}class sa{constructor(e,t,i,s){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=s}}class ra{static ConvertCubeMapTextureToSphericalPolynomial(e){if(!e.isCube)return null;e.getScene()?.getEngine().flushFramebuffer();const t=e.getSize().width,i=e.readPixels(0,void 0,void 0,!1),s=e.readPixels(1,void 0,void 0,!1);let r,n;e.isRenderTarget?(r=e.readPixels(3,void 0,void 0,!1),n=e.readPixels(2,void 0,void 0,!1)):(r=e.readPixels(2,void 0,void 0,!1),n=e.readPixels(3,void 0,void 0,!1));const a=e.readPixels(4,void 0,void 0,!1),o=e.readPixels(5,void 0,void 0,!1),h=e.gammaSpace,l=Ve.TEXTUREFORMAT_RGBA;let c=Ve.TEXTURETYPE_UNSIGNED_BYTE;return e.textureType!=Ve.TEXTURETYPE_FLOAT&&e.textureType!=Ve.TEXTURETYPE_HALF_FLOAT||(c=Ve.TEXTURETYPE_FLOAT),new Promise((e=>{Promise.all([s,i,r,n,a,o]).then((([i,s,r,n,a,o])=>{const u={size:t,right:s,left:i,up:r,down:n,front:a,back:o,format:l,type:c,gammaSpace:h};e(this.ConvertCubeMapToSphericalPolynomial(u))}))}))}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static ConvertCubeMapToSphericalPolynomial(e){const t=new ta;let i=0;const s=2/e.size,r=s,n=.5*s,a=n-1;for(let o=0;o<6;o++){const h=this._FileFaces[o],l=e[h.name];let c=a;const u=e.format===Ve.TEXTUREFORMAT_RGBA?4:3;for(let o=0;o<e.size;o++){let d=a;for(let r=0;r<e.size;r++){const a=h.worldAxisForFileX.scale(d).add(h.worldAxisForFileY.scale(c)).add(h.worldAxisForNormal);a.normalize();const _=this._AreaElement(d-n,c-n)-this._AreaElement(d-n,c+n)-this._AreaElement(d+n,c-n)+this._AreaElement(d+n,c+n);let f=l[o*e.size*u+r*u+0],p=l[o*e.size*u+r*u+1],g=l[o*e.size*u+r*u+2];isNaN(f)&&(f=0),isNaN(p)&&(p=0),isNaN(g)&&(g=0),e.type===Ve.TEXTURETYPE_UNSIGNED_BYTE&&(f/=255,p/=255,g/=255),e.gammaSpace&&(f=Math.pow(N(f),b),p=Math.pow(N(p),b),g=Math.pow(N(g),b));const m=this.MAX_HDRI_VALUE;if(this.PRESERVE_CLAMPED_COLORS){const e=Math.max(f,p,g);if(e>m){const t=m/e;f*=t,p*=t,g*=t}}else f=N(f,0,m),p=N(p,0,m),g=N(g,0,m);const T=new he(f,p,g);t.addLight(a,T,_),i+=_,d+=s}c+=r}}const o=6*(4*Math.PI)/6/i;return t.scaleInPlace(o),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),ia.FromHarmonics(t)}}ra._FileFaces=[new sa("right",new X(1,0,0),new X(0,0,-1),new X(0,-1,0)),new sa("left",new X(-1,0,0),new X(0,0,1),new X(0,-1,0)),new sa("up",new X(0,1,0),new X(1,0,0),new X(0,0,1)),new sa("down",new X(0,-1,0),new X(1,0,0),new X(0,0,-1)),new sa("front",new X(0,0,1),new X(1,0,0),new X(0,-1,0)),new sa("back",new X(0,0,-1),new X(-1,0,0),new X(0,-1,0))],ra.MAX_HDRI_VALUE=4096,ra.PRESERVE_CLAMPED_COLORS=!1,An.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)},Object.defineProperty(An.prototype,"sphericalPolynomial",{get:function(){if(this._texture){if(this._texture._sphericalPolynomial||this._texture._sphericalPolynomialComputed)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomialPromise||(this._texture._sphericalPolynomialPromise=ra.ConvertCubeMapTextureToSphericalPolynomial(this),null===this._texture._sphericalPolynomialPromise?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then((e=>{this._texture._sphericalPolynomial=e,this._texture._sphericalPolynomialComputed=!0}))),null}return null},set:function(e){this._texture&&(this._texture._sphericalPolynomial=e)},enumerable:!0,configurable:!0});class na{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)}get hasMoreFallbacks(){return this._currentRank<=this._maxRank}reduce(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;const i=this._mesh.getScene();for(let e=0;e<i.meshes.length;e++){const s=i.meshes[e];if(s.material){if(s.computeBonesUsingShaders&&0!==s.numBoneInfluencers)if(s.material.getEffect()===t)s.computeBonesUsingShaders=!1;else if(s.subMeshes)for(const e of s.subMeshes){if(e.effect===t){s.computeBonesUsingShaders=!1;break}}}else!this._mesh.material&&s.computeBonesUsingShaders&&s.numBoneInfluencers>0&&(s.computeBonesUsingShaders=!1)}}else{const t=this._defines[this._currentRank];if(t)for(let i=0;i<t.length;i++)e=e.replace("#define "+t[i],"");this._currentRank++}return e}}class aa extends Vn{constructor(){super(...arguments),this.CLEARCOAT=!1,this.CLEARCOAT_DEFAULTIOR=!1,this.CLEARCOAT_TEXTURE=!1,this.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this.CLEARCOAT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,this.CLEARCOAT_BUMP=!1,this.CLEARCOAT_BUMPDIRECTUV=0,this.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,this.CLEARCOAT_REMAP_F0=!1,this.CLEARCOAT_TINT=!1,this.CLEARCOAT_TINT_TEXTURE=!1,this.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TINT_GAMMATEXTURE=!1}}class oa extends Kn{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRClearCoat",100,new aa,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=oa._DefaultIndexOfRefraction,this.indexOfRefraction=oa._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._textureRoughness=null,this.textureRoughness=null,this._remapF0OnInterfaceChange=!0,this.remapF0OnInterfaceChange=!0,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=he.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag]}isReadyForSubMesh(e,t,i){if(!this._isEnabled)return!0;const s=this._material._disableBumpMap;if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&jn.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&jn.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1;if(i.getCaps().standardDerivatives&&this._bumpTexture&&jn.ClearCoatBumpTextureEnabled&&!s&&!this._bumpTexture.isReady())return!1;if(this._isTintEnabled&&this._tintTexture&&jn.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.CLEARCOAT=!0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&jn.ClearCoatTextureEnabled?Es(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&jn.ClearCoatTextureEnabled?Es(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&jn.ClearCoatBumpTextureEnabled?Es(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===oa._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&jn.ClearCoatTintTextureEnabled?(Es(this._tintTexture,e,"CLEARCOAT_TINT_TEXTURE"),e.CLEARCOAT_TINT_GAMMATEXTURE=this._tintTexture.gammaSpace):e.CLEARCOAT_TINT_TEXTURE=!1):(e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1))):(e.CLEARCOAT=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_REMAP_F0=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TINT_GAMMATEXTURE=!1)}bindForSubMesh(e,t,i,s){if(!this._isEnabled)return;const r=s.materialDefines,n=this._material.isFrozen,a=this._material._disableBumpMap,o=this._material._invertNormalMapX,h=this._material._invertNormalMapY;if(!e.useUbo||!n||!e.isSync){(this._texture||this._textureRoughness)&&jn.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._textureRoughness?.coordinatesIndex??0,this._textureRoughness?.level??0),this._texture&&bs(this._texture,e,"clearCoat"),this._textureRoughness&&!r.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&bs(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&jn.ClearCoatTextureEnabled&&!a&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),bs(this._bumpTexture,e,"clearCoatBump"),t._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",o?1:-1,h?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",o?-1:1,h?-1:1)),this._tintTexture&&jn.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),bs(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);const s=1-this._indexOfRefraction,n=1+this._indexOfRefraction,l=Math.pow(-s/n,2),c=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",l,c,s,n),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}t.texturesEnabled&&(this._texture&&jn.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!r.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&jn.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&jn.ClearCoatBumpTextureEnabled&&!a&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&jn.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))}hasTexture(e){return this._texture===e||(this._textureRoughness===e||(this._bumpTexture===e||this._tintTexture===e))}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)}dispose(e){e&&(this._texture?.dispose(),this._textureRoughness?.dispose(),this._bumpTexture?.dispose(),this._tintTexture?.dispose())}getClassName(){return"PBRClearCoatConfiguration"}addFallbacks(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i}getSamplers(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")}getUniforms(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}}}oa._DefaultIndexOfRefraction=1.5,e([a(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"isEnabled",void 0),e([a()],oa.prototype,"intensity",void 0),e([a()],oa.prototype,"roughness",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"indexOfRefraction",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"texture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"useRoughnessFromMainTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"textureRoughness",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"remapF0OnInterfaceChange",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"bumpTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"isTintEnabled",void 0),e([h()],oa.prototype,"tintColor",void 0),e([a()],oa.prototype,"tintColorAtDistance",void 0),e([a()],oa.prototype,"tintThickness",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],oa.prototype,"tintTexture",void 0);class ha extends Vn{constructor(){super(...arguments),this.IRIDESCENCE=!1,this.IRIDESCENCE_TEXTURE=!1,this.IRIDESCENCE_TEXTUREDIRECTUV=0,this.IRIDESCENCE_THICKNESS_TEXTURE=!1,this.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0}}class la extends Kn{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRIridescence",110,new ha,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.minimumThickness=la._DefaultMinimumThickness,this.maximumThickness=la._DefaultMaximumThickness,this.indexOfRefraction=la._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._thicknessTexture=null,this.thicknessTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag]}isReadyForSubMesh(e,t){if(!this._isEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&jn.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._thicknessTexture&&jn.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&jn.IridescenceTextureEnabled?Es(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&jn.IridescenceTextureEnabled?Es(this._thicknessTexture,e,"IRIDESCENCE_THICKNESS_TEXTURE"):e.IRIDESCENCE_THICKNESS_TEXTURE=!1)):(e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0)}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;e.useUbo&&i&&e.isSync||((this._texture||this._thicknessTexture)&&jn.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._thicknessTexture?.coordinatesIndex??0,this._thicknessTexture?.level??0),this._texture&&bs(this._texture,e,"iridescence"),this._thicknessTexture&&bs(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&jn.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&jn.IridescenceTextureEnabled&&e.setTexture("iridescenceThicknessSampler",this._thicknessTexture))}hasTexture(e){return this._texture===e||this._thicknessTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._thicknessTexture&&e.push(this._thicknessTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture)}dispose(e){e&&(this._texture?.dispose(),this._thicknessTexture?.dispose())}getClassName(){return"PBRIridescenceConfiguration"}addFallbacks(e,t,i){return e.IRIDESCENCE&&t.addFallback(i++,"IRIDESCENCE"),i}getSamplers(e){e.push("iridescenceSampler","iridescenceThicknessSampler")}getUniforms(){return{ubo:[{name:"vIridescenceParams",size:4,type:"vec4"},{name:"vIridescenceInfos",size:4,type:"vec4"},{name:"iridescenceMatrix",size:16,type:"mat4"},{name:"iridescenceThicknessMatrix",size:16,type:"mat4"}]}}}la._DefaultMinimumThickness=100,la._DefaultMaximumThickness=400,la._DefaultIndexOfRefraction=1.3,e([a(),n("_markAllSubMeshesAsTexturesDirty")],la.prototype,"isEnabled",void 0),e([a()],la.prototype,"intensity",void 0),e([a()],la.prototype,"minimumThickness",void 0),e([a()],la.prototype,"maximumThickness",void 0),e([a()],la.prototype,"indexOfRefraction",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],la.prototype,"texture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],la.prototype,"thicknessTexture",void 0);class ca extends Vn{constructor(){super(...arguments),this.ANISOTROPIC=!1,this.ANISOTROPIC_TEXTURE=!1,this.ANISOTROPIC_TEXTUREDIRECTUV=0,this.ANISOTROPIC_LEGACY=!1,this.MAINUV1=!1}}class ua extends Kn{set angle(e){this.direction.x=Math.cos(e),this.direction.y=Math.sin(e)}get angle(){return Math.atan2(this.direction.y,this.direction.x)}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markAllSubMeshesAsMiscDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRAnisotropic",110,new ca,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new Y(1,0),this._texture=null,this.texture=null,this._legacy=!1,this.legacy=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag],this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[Ve.MATERIAL_MiscDirtyFlag]}isReadyForSubMesh(e,t){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&jn.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())}prepareDefinesBeforeAttributes(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(wi.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&jn.AnisotropicTextureEnabled?Es(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1),e._areMiscDirty&&(e.ANISOTROPIC_LEGACY=this._legacy)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1)}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;e.useUbo&&i&&e.isSync||(this._texture&&jn.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),bs(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&jn.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture&&this._texture.dispose()}getClassName(){return"PBRAnisotropicConfiguration"}addFallbacks(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i}getSamplers(e){e.push("anisotropySampler")}getUniforms(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}}parse(e,t,i){super.parse(e,t,i),void 0===e.legacy&&(this.legacy=!0)}}e([a(),n("_markAllSubMeshesAsTexturesDirty")],ua.prototype,"isEnabled",void 0),e([a()],ua.prototype,"intensity",void 0),e([c()],ua.prototype,"direction",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ua.prototype,"texture",void 0),e([a(),n("_markAllSubMeshesAsMiscDirty")],ua.prototype,"legacy",void 0);class da extends Vn{constructor(){super(...arguments),this.SHEEN=!1,this.SHEEN_TEXTURE=!1,this.SHEEN_GAMMATEXTURE=!1,this.SHEEN_TEXTURE_ROUGHNESS=!1,this.SHEEN_TEXTUREDIRECTUV=0,this.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,this.SHEEN_LINKWITHALBEDO=!1,this.SHEEN_ROUGHNESS=!1,this.SHEEN_ALBEDOSCALING=!1,this.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1}}class _a extends Kn{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"Sheen",120,new da,t),this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=he.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag]}isReadyForSubMesh(e,t){if(!this._isEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&jn.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&jn.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.SHEEN=!0,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=null!==this._roughness,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&jn.SheenTextureEnabled?(Es(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&jn.SheenTextureEnabled?Es(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0)}bindForSubMesh(e,t,i,s){if(!this._isEnabled)return;const r=s.materialDefines,n=this._material.isFrozen;e.useUbo&&n&&e.isSync||((this._texture||this._textureRoughness)&&jn.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._textureRoughness?.coordinatesIndex??0,this._textureRoughness?.level??0),this._texture&&bs(this._texture,e,"sheen"),this._textureRoughness&&!r.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&bs(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),null!==this._roughness&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&jn.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!r.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&jn.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}hasTexture(e){return this._texture===e||this._textureRoughness===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)}dispose(e){e&&(this._texture?.dispose(),this._textureRoughness?.dispose())}getClassName(){return"PBRSheenConfiguration"}addFallbacks(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i}getSamplers(e){e.push("sheenSampler","sheenRoughnessSampler")}getUniforms(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}}}e([a(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"isEnabled",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"linkSheenWithAlbedo",void 0),e([a()],_a.prototype,"intensity",void 0),e([h()],_a.prototype,"color",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"texture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"useRoughnessFromMainTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"roughness",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"textureRoughness",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],_a.prototype,"albedoScaling",void 0);class fa extends Vn{constructor(){super(...arguments),this.SUBSURFACE=!1,this.SS_REFRACTION=!1,this.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_TRANSLUCENCY=!1,this.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_SCATTERING=!1,this.SS_DISPERSION=!1,this.SS_THICKNESSANDMASK_TEXTURE=!1,this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,this.SS_HAS_THICKNESS=!1,this.SS_REFRACTIONINTENSITY_TEXTURE=!1,this.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,this.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,this.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,this.SS_REFRACTIONMAP_3D=!1,this.SS_REFRACTIONMAP_OPPOSITEZ=!1,this.SS_LODINREFRACTIONALPHA=!1,this.SS_GAMMAREFRACTION=!1,this.SS_RGBDREFRACTION=!1,this.SS_LINEARSPECULARREFRACTION=!1,this.SS_LINKREFRACTIONTOTRANSPARENCY=!1,this.SS_ALBEDOFORREFRACTIONTINT=!1,this.SS_ALBEDOFORTRANSLUCENCYTINT=!1,this.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,this.SS_USE_THICKNESS_AS_DEPTH=!1,this.SS_USE_GLTF_TEXTURES=!1}}class pa extends Kn{get scatteringDiffusionProfile(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null}set scatteringDiffusionProfile(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))}get volumeIndexOfRefraction(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction}set volumeIndexOfRefraction(e){this._volumeIndexOfRefraction=e>=1?e:-1}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markScenePrePassDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRSubSurface",130,new fa,t),this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isDispersionEnabled=!1,this.isDispersionEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this.useAlbedoToTintRefraction=!1,this.useAlbedoToTintTranslucency=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.useThicknessAsDepth=!1,this.tintColor=he.White(),this.tintColorAtDistance=1,this.dispersion=0,this.diffusionDistance=he.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._refractionIntensityTexture=null,this.refractionIntensityTexture=null,this._translucencyIntensityTexture=null,this.translucencyIntensityTexture=null,this.translucencyColor=null,this._translucencyColorTexture=null,this.translucencyColorTexture=null,this._useGltfStyleTextures=!0,this.useGltfStyleTextures=!0,this._scene=e.getScene(),this.registerForExtraEvents=!0,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag],this._internalMarkScenePrePassDirty=e._dirtyCallbacks[Ve.MATERIAL_PrePassDirtyFlag]}isReadyForSubMesh(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&jn.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;if(this._translucencyColorTexture&&jn.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking())return!1;if(this._translucencyIntensityTexture&&jn.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;const e=this._getRefractionTexture(t);if(e&&jn.RefractionTextureEnabled&&!e.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return e.SUBSURFACE=!1,e.SS_DISPERSION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,void(e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0);if(e._areTexturesDirty){if(e.SUBSURFACE=!0,e.SS_DISPERSION=this._isDispersionEnabled,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&jn.ThicknessTextureEnabled&&Es(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&jn.RefractionIntensityTextureEnabled&&Es(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&jn.TranslucencyIntensityTextureEnabled&&Es(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&jn.TranslucencyColorTextureEnabled&&Es(this._translucencyColorTexture,e,"SS_TRANSLUCENCYCOLOR_TEXTURE")),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!=0,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._refractionIntensityTexture,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._translucencyIntensityTexture,this._isRefractionEnabled&&t.texturesEnabled){const i=this._getRefractionTexture(t);i&&jn.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&i.isCube?!i.invertZ:i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=i.isCube&&i.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this.useAlbedoToTintTranslucency)}}hardBindForSubMesh(e,t,i,s){if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)if(0===this.maximumThickness&&0===this.minimumThickness)e.updateFloat2("vThicknessParam",0,0);else{s.getRenderingMesh().getWorldMatrix().decompose(J.Vector3[0]);const t=Math.max(Math.abs(J.Vector3[0].x),Math.abs(J.Vector3[0].y),Math.abs(J.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*t,(this.maximumThickness-this.minimumThickness)*t)}}bindForSubMesh(e,t,i,s){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return;const r=s.materialDefines,n=this._material.isFrozen,a=this._material.realTimeFiltering,o=r.LODBASEDMICROSFURACE,h=this._getRefractionTexture(t);if(!e.useUbo||!n||!e.isSync){if(this._thicknessTexture&&jn.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),bs(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&jn.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),bs(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&jn.TranslucencyColorTextureEnabled&&r.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),bs(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&jn.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),bs(this._translucencyIntensityTexture,e,"translucencyIntensity")),h&&jn.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",h.getRefractionTextureMatrix());let t=1;h.isCube||h.depth&&(t=h.depth);const i=h.getSize().width,s=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",h.level,1/s,t,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",i,h.lodGenerationScale,h.lodGenerationOffset,1/this.indexOfRefraction),a&&e.updateFloat2("vRefractionFilteringInfo",i,Math.log2(i)),h.boundingBoxSize){const t=h;e.updateVector3("vRefractionPosition",t.boundingBoxPosition),e.updateVector3("vRefractionSize",t.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateColor4("vTranslucencyColor",this.translucencyColor??this.tintColor,0),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0),e.updateFloat("dispersion",this.dispersion)}t.texturesEnabled&&(this._thicknessTexture&&jn.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&jn.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&jn.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&jn.TranslucencyColorTextureEnabled&&r.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),h&&jn.RefractionTextureEnabled&&(o?e.setTexture("refractionSampler",h):(e.setTexture("refractionSampler",h._lodTextureMid||h),e.setTexture("refractionSamplerLow",h._lodTextureLow||h),e.setTexture("refractionSamplerHigh",h._lodTextureHigh||h))))}_getRefractionTexture(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null}get disableAlphaBlending(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency}fillRenderTargetTextures(e){jn.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)}hasTexture(e){return this._thicknessTexture===e||(this._refractionTexture===e||(this._refractionIntensityTexture===e||(this._translucencyIntensityTexture===e||this._translucencyColorTexture===e)))}hasRenderTargetTextures(){return!!(jn.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)}getActiveTextures(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),this._translucencyColorTexture&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&e.push(this._translucencyIntensityTexture)}getAnimatables(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._translucencyColorTexture&&this._translucencyColorTexture.animations&&this._translucencyColorTexture.animations.length>0&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.animations&&this._translucencyIntensityTexture.animations.length>0&&e.push(this._translucencyIntensityTexture)}dispose(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._translucencyColorTexture&&this._translucencyColorTexture.dispose(),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.dispose())}getClassName(){return"PBRSubSurfaceConfiguration"}addFallbacks(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i}getSamplers(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","translucencyColorSampler")}getUniforms(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"},{name:"dispersion",size:1,type:"float"},{name:"vTranslucencyColor",size:4,type:"vec4"},{name:"vTranslucencyColorInfos",size:2,type:"vec2"},{name:"translucencyColorMatrix",size:16,type:"mat4"}]}}}e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"isRefractionEnabled",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"isTranslucencyEnabled",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"isDispersionEnabled",void 0),e([a(),n("_markScenePrePassDirty")],pa.prototype,"isScatteringEnabled",void 0),e([a()],pa.prototype,"_scatteringDiffusionProfileIndex",void 0),e([a()],pa.prototype,"refractionIntensity",void 0),e([a()],pa.prototype,"translucencyIntensity",void 0),e([a()],pa.prototype,"useAlbedoToTintRefraction",void 0),e([a()],pa.prototype,"useAlbedoToTintTranslucency",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"thicknessTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"refractionTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"indexOfRefraction",void 0),e([a()],pa.prototype,"_volumeIndexOfRefraction",void 0),e([n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"volumeIndexOfRefraction",null),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"invertRefractionY",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"linkRefractionWithTransparency",void 0),e([a()],pa.prototype,"minimumThickness",void 0),e([a()],pa.prototype,"maximumThickness",void 0),e([a()],pa.prototype,"useThicknessAsDepth",void 0),e([h()],pa.prototype,"tintColor",void 0),e([a()],pa.prototype,"tintColorAtDistance",void 0),e([a()],pa.prototype,"dispersion",void 0),e([h()],pa.prototype,"diffusionDistance",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"useMaskFromThicknessTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"refractionIntensityTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"translucencyIntensityTexture",void 0),e([h()],pa.prototype,"translucencyColor",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"translucencyColorTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],pa.prototype,"useGltfStyleTextures",void 0);class ga extends Vn{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class ma extends Kn{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new ga,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=ks.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[Ve.MATERIAL_TextureDirtyFlag]}isReadyForSubMesh(e,t,i){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&jn.DetailTextureEnabled&&!this._texture.isReady())}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;const i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&jn.DetailTextureEnabled&&this._isEnabled?(Es(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;e.useUbo&&i&&e.isSync||this._texture&&jn.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),bs(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&jn.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture?.dispose()}getClassName(){return"DetailMapConfiguration"}getSamplers(e){e.push("detailSampler")}getUniforms(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}}}var Ta;e([o("detailTexture"),n("_markAllSubMeshesAsTexturesDirty")],ma.prototype,"texture",void 0),e([a()],ma.prototype,"diffuseBlendLevel",void 0),e([a()],ma.prototype,"roughnessBlendLevel",void 0),e([a()],ma.prototype,"bumpLevel",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ma.prototype,"normalBlendMethod",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ma.prototype,"isEnabled",void 0),function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.MaxViewZ=2]="MaxViewZ"}(Ta||(Ta={}));class Aa{static CreateConfiguration(e){return Aa._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:j.Zero(),currentViewProjection:j.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[]},Aa._Configurations[e]}static DeleteConfiguration(e){delete Aa._Configurations[e]}static GetConfiguration(e){return Aa._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(const i of t)if(i.subMeshes)for(const t of i.subMeshes)t._removeDrawWrapper(e)}static PrepareDefines(e,t,i){if(!i._arePrePassDirty)return;const s=Aa._Configurations[e];if(!s)return;i.PREPASS=!0,i.PREPASS_COLOR=!1,i.PREPASS_COLOR_INDEX=-1;let r=0;for(let e=0;e<Aa.GeometryTextureDescriptions.length;e++){const t=Aa.GeometryTextureDescriptions[e],n=t.define,a=t.defineIndex,o=s.defines[a];void 0!==o?(i[n]=!0,i[a]=o,r++):(i[n]=!1,delete i[a])}i.SCENE_MRT_COUNT=r,i.BONES_VELOCITY_ENABLED=t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&!t.skeleton.isUsingTextureForMatrices&&-1===s.excludedSkinnedMesh.indexOf(t)}static Bind(e,t,i,s){const r=Aa._Configurations[e];if(r&&(void 0!==r.defines.PREPASS_VELOCITY_INDEX||void 0!==r.defines.PREPASS_VELOCITY_LINEAR_INDEX)){r.previousWorldMatrices[i.uniqueId]||(r.previousWorldMatrices[i.uniqueId]=s.clone());const e=i.getScene();r.previousViewProjection||(r.previousViewProjection=e.getTransformMatrix().clone(),r.currentViewProjection=e.getTransformMatrix().clone());const n=e.getEngine();if(r.currentViewProjection.updateFlag!==e.getTransformMatrix().updateFlag?(r.lastUpdateFrameId=n.frameId,r.previousViewProjection.copyFrom(r.currentViewProjection),r.currentViewProjection.copyFrom(e.getTransformMatrix())):r.lastUpdateFrameId!==n.frameId&&(r.lastUpdateFrameId=n.frameId,r.previousViewProjection.copyFrom(r.currentViewProjection)),t.setMatrix("previousWorld",r.previousWorldMatrices[i.uniqueId]),t.setMatrix("previousViewProjection",r.previousViewProjection),r.previousWorldMatrices[i.uniqueId]=s.clone(),i.useBones&&i.computeBonesUsingShaders&&i.skeleton){const e=i.skeleton;if(!e.isUsingTextureForMatrices||-1===t.getUniformIndex("boneTextureWidth")){const s=e.getTransformMatrices(i);s&&(r.previousBones[i.uniqueId]||(r.previousBones[i.uniqueId]=s.slice()),t.setMatrices("mPreviousBones",r.previousBones[i.uniqueId]),r.previousBones[i.uniqueId].set(s))}}}}}Aa.GeometryTextureDescriptions=[{type:Ve.PREPASS_IRRADIANCE_TEXTURE_TYPE,name:"Irradiance",clearType:0,define:"PREPASS_IRRADIANCE",defineIndex:"PREPASS_IRRADIANCE_INDEX"},{type:Ve.PREPASS_POSITION_TEXTURE_TYPE,name:"WorldPosition",clearType:0,define:"PREPASS_POSITION",defineIndex:"PREPASS_POSITION_INDEX"},{type:Ve.PREPASS_VELOCITY_TEXTURE_TYPE,name:"Velocity",clearType:0,define:"PREPASS_VELOCITY",defineIndex:"PREPASS_VELOCITY_INDEX"},{type:Ve.PREPASS_REFLECTIVITY_TEXTURE_TYPE,name:"Reflectivity",clearType:0,define:"PREPASS_REFLECTIVITY",defineIndex:"PREPASS_REFLECTIVITY_INDEX"},{type:Ve.PREPASS_DEPTH_TEXTURE_TYPE,name:"ViewDepth",clearType:2,define:"PREPASS_DEPTH",defineIndex:"PREPASS_DEPTH_INDEX"},{type:Ve.PREPASS_NORMAL_TEXTURE_TYPE,name:"ViewNormal",clearType:0,define:"PREPASS_NORMAL",defineIndex:"PREPASS_NORMAL_INDEX"},{type:Ve.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,name:"AlbedoSqrt",clearType:0,define:"PREPASS_ALBEDO_SQRT",defineIndex:"PREPASS_ALBEDO_SQRT_INDEX"},{type:Ve.PREPASS_WORLD_NORMAL_TEXTURE_TYPE,name:"WorldNormal",clearType:0,define:"PREPASS_WORLD_NORMAL",defineIndex:"PREPASS_WORLD_NORMAL_INDEX"},{type:Ve.PREPASS_LOCAL_POSITION_TEXTURE_TYPE,name:"LocalPosition",clearType:0,define:"PREPASS_LOCAL_POSITION",defineIndex:"PREPASS_LOCAL_POSITION_INDEX"},{type:Ve.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE,name:"ScreenDepth",clearType:1,define:"PREPASS_SCREENSPACE_DEPTH",defineIndex:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:Ve.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE,name:"LinearVelocity",clearType:0,define:"PREPASS_VELOCITY_LINEAR",defineIndex:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:Ve.PREPASS_ALBEDO_TEXTURE_TYPE,name:"Albedo",clearType:0,define:"PREPASS_ALBEDO",defineIndex:"PREPASS_ALBEDO_INDEX"}],Aa._Configurations={};const Ea={effect:null,subMesh:null};class ba extends Vn{constructor(e){super(e),this.PBR=!0,this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,this.MAINUV1=!1,this.MAINUV2=!1,this.MAINUV3=!1,this.MAINUV4=!1,this.MAINUV5=!1,this.MAINUV6=!1,this.UV1=!1,this.UV2=!1,this.UV3=!1,this.UV4=!1,this.UV5=!1,this.UV6=!1,this.ALBEDO=!1,this.GAMMAALBEDO=!1,this.ALBEDODIRECTUV=0,this.VERTEXCOLOR=!1,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.AMBIENT=!1,this.AMBIENTDIRECTUV=0,this.AMBIENTINGRAYSCALE=!1,this.OPACITY=!1,this.VERTEXALPHA=!1,this.OPACITYDIRECTUV=0,this.OPACITYRGB=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHABLEND=!1,this.ALPHAFROMALBEDO=!1,this.ALPHATESTVALUE="0.5",this.SPECULAROVERALPHA=!1,this.RADIANCEOVERALPHA=!1,this.ALPHAFRESNEL=!1,this.LINEARALPHAFRESNEL=!1,this.PREMULTIPLYALPHA=!1,this.EMISSIVE=!1,this.EMISSIVEDIRECTUV=0,this.GAMMAEMISSIVE=!1,this.REFLECTIVITY=!1,this.REFLECTIVITY_GAMMA=!1,this.REFLECTIVITYDIRECTUV=0,this.SPECULARTERM=!1,this.MICROSURFACEFROMREFLECTIVITYMAP=!1,this.MICROSURFACEAUTOMATIC=!1,this.LODBASEDMICROSFURACE=!1,this.MICROSURFACEMAP=!1,this.MICROSURFACEMAPDIRECTUV=0,this.METALLICWORKFLOW=!1,this.ROUGHNESSSTOREINMETALMAPALPHA=!1,this.ROUGHNESSSTOREINMETALMAPGREEN=!1,this.METALLNESSSTOREINMETALMAPBLUE=!1,this.AOSTOREINMETALMAPRED=!1,this.METALLIC_REFLECTANCE=!1,this.METALLIC_REFLECTANCE_GAMMA=!1,this.METALLIC_REFLECTANCEDIRECTUV=0,this.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,this.REFLECTANCE=!1,this.REFLECTANCE_GAMMA=!1,this.REFLECTANCEDIRECTUV=0,this.ENVIRONMENTBRDF=!1,this.ENVIRONMENTBRDF_RGBD=!1,this.NORMAL=!1,this.TANGENT=!1,this.BUMP=!1,this.BUMPDIRECTUV=0,this.OBJECTSPACE_NORMALMAP=!1,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.NORMALXYSCALE=!0,this.LIGHTMAP=!1,this.LIGHTMAPDIRECTUV=0,this.USELIGHTMAPASSHADOWMAP=!1,this.GAMMALIGHTMAP=!1,this.RGBDLIGHTMAP=!1,this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.USEIRRADIANCEMAP=!1,this.USESPHERICALINVERTEX=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1,this.LINEARSPECULARREFLECTION=!1,this.RADIANCEOCCLUSION=!1,this.HORIZONOCCLUSION=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.PREPASS=!1,this.PREPASS_COLOR=!1,this.PREPASS_COLOR_INDEX=-1,this.PREPASS_IRRADIANCE=!1,this.PREPASS_IRRADIANCE_INDEX=-1,this.PREPASS_ALBEDO=!1,this.PREPASS_ALBEDO_INDEX=-1,this.PREPASS_ALBEDO_SQRT=!1,this.PREPASS_ALBEDO_SQRT_INDEX=-1,this.PREPASS_DEPTH=!1,this.PREPASS_DEPTH_INDEX=-1,this.PREPASS_SCREENSPACE_DEPTH=!1,this.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,this.PREPASS_NORMAL=!1,this.PREPASS_NORMAL_INDEX=-1,this.PREPASS_NORMAL_WORLDSPACE=!1,this.PREPASS_WORLD_NORMAL=!1,this.PREPASS_WORLD_NORMAL_INDEX=-1,this.PREPASS_POSITION=!1,this.PREPASS_POSITION_INDEX=-1,this.PREPASS_LOCAL_POSITION=!1,this.PREPASS_LOCAL_POSITION_INDEX=-1,this.PREPASS_VELOCITY=!1,this.PREPASS_VELOCITY_INDEX=-1,this.PREPASS_VELOCITY_LINEAR=!1,this.PREPASS_VELOCITY_LINEAR_INDEX=-1,this.PREPASS_REFLECTIVITY=!1,this.PREPASS_REFLECTIVITY_INDEX=-1,this.SCENE_MRT_COUNT=0,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.NONUNIFORMSCALING=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.IMAGEPROCESSING=!1,this.VIGNETTE=!1,this.VIGNETTEBLENDMODEMULTIPLY=!1,this.VIGNETTEBLENDMODEOPAQUE=!1,this.TONEMAPPING=0,this.CONTRAST=!1,this.COLORCURVES=!1,this.COLORGRADING=!1,this.COLORGRADING3D=!1,this.SAMPLER3DGREENDEPTH=!1,this.SAMPLER3DBGRMAP=!1,this.DITHER=!1,this.IMAGEPROCESSINGPOSTPROCESS=!1,this.SKIPFINALCOLORCLAMP=!1,this.EXPOSURE=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.USEGLTFLIGHTFALLOFF=!1,this.TWOSIDEDLIGHTING=!1,this.SHADOWFLOAT=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.LOGARITHMICDEPTH=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.FORCENORMALFORWARD=!1,this.SPECULARAA=!1,this.UNLIT=!1,this.DECAL_AFTER_DETAIL=!1,this.DEBUGMODE=0,this.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0}}class Ra extends qn{get realTimeFiltering(){return this._realTimeFiltering}set realTimeFiltering(e){this._realTimeFiltering=e,this.markAsDirty(Ve.MATERIAL_TextureDirtyFlag)}get realTimeFilteringQuality(){return this._realTimeFilteringQuality}set realTimeFilteringQuality(e){this._realTimeFilteringQuality=e,this.markAsDirty(Ve.MATERIAL_TextureDirtyFlag)}get canRenderToMRT(){return!0}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((()=>{this._markAllSubMeshesAsImageProcessingDirty()}))))}constructor(e,t,i=!1){super(e,t,void 0,i||Ra.ForceGLSL),this._directIntensity=1,this._emissiveIntensity=1,this._environmentIntensity=1,this._specularIntensity=1,this._lightingInfos=new Q(this._directIntensity,this._emissiveIntensity,this._environmentIntensity,this._specularIntensity),this._disableBumpMap=!1,this._albedoTexture=null,this._ambientTexture=null,this._ambientTextureStrength=1,this._ambientTextureImpactOnAnalyticalLights=Ra.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._reflectivityTexture=null,this._metallicTexture=null,this._metallic=null,this._roughness=null,this._metallicF0Factor=1,this._metallicReflectanceColor=he.White(),this._useOnlyMetallicFromMetallicReflectanceTexture=!1,this._metallicReflectanceTexture=null,this._reflectanceTexture=null,this._microSurfaceTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._ambientColor=new he(0,0,0),this._albedoColor=new he(1,1,1),this._reflectivityColor=new he(1,1,1),this._reflectionColor=new he(1,1,1),this._emissiveColor=new he(0,0,0),this._microSurface=.9,this._useLightmapAsShadowmap=!1,this._useHorizonOcclusion=!0,this._useRadianceOcclusion=!0,this._useAlphaFromAlbedoTexture=!1,this._useSpecularOverAlpha=!0,this._useMicroSurfaceFromReflectivityMapAlpha=!1,this._useRoughnessFromMetallicTextureAlpha=!0,this._useRoughnessFromMetallicTextureGreen=!1,this._useMetallnessFromMetallicTextureBlue=!1,this._useAmbientOcclusionFromMetallicTextureRed=!1,this._useAmbientInGrayScale=!1,this._useAutoMicroSurfaceFromReflectivityMap=!1,this._lightFalloff=Ra.LIGHTFALLOFF_PHYSICAL,this._useRadianceOverAlpha=!0,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this._parallaxScaleBias=.05,this._disableLighting=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._alphaCutOff=.4,this._forceAlphaTest=!1,this._useAlphaFresnel=!1,this._useLinearAlphaFresnel=!1,this._environmentBRDFTexture=null,this._forceIrradianceInFragment=!1,this._realTimeFiltering=!1,this._realTimeFilteringQuality=Ve.TEXTURE_FILTERING_QUALITY_LOW,this._forceNormalForward=!1,this._enableSpecularAntiAliasing=!1,this._imageProcessingObserver=null,this._renderTargets=new Ri(16),this._globalAmbientColor=new he(0,0,0),this._unlit=!1,this._applyDecalMapAfterDetailMap=!1,this._debugMode=0,this._shadersLoaded=!1,this._breakShaderLoadedCheck=!1,this.debugMode=0,this.debugLimit=-1,this.debugFactor=1,this._cacheHasRenderTargetTextures=!1,this.brdf=new Xn(this),this.clearCoat=new oa(this),this.iridescence=new la(this),this.anisotropy=new ua(this),this.sheen=new _a(this),this.subSurface=new pa(this),this.detailMap=new ma(this),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),jn.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=kn(this.getScene()),this.prePassConfiguration=new Qn}get hasRenderTargetTextures(){return!!(jn.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"PBRBaseMaterial"}get _disableAlphaBlending(){return this._transparencyMode===Ra.PBRMATERIAL_OPAQUE||this._transparencyMode===Ra.PBRMATERIAL_ALPHATEST||this.subSurface?.disableAlphaBlending}needAlphaBlending(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())}needAlphaTesting(){return!!this._forceAlphaTest||!this.subSurface?.disableAlphaBlending&&(this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===Ra.PBRMATERIAL_ALPHATEST))}_shouldUseAlphaFromAlbedoTexture(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==Ra.PBRMATERIAL_OPAQUE}_hasAlphaChannel(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha||null!=this._opacityTexture}getAlphaTestTexture(){return this._albedoTexture}isReadyForSubMesh(e,t,i){this._uniformBufferLayoutBuilt||this.buildUniformLayout();const s=t._drawWrapper;if(s.effect&&this.isFrozen&&s._wasPreviouslyReady&&s._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new ba(this._eventInfo.defineNames));const r=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const n=this.getScene(),a=n.getEngine();if(r._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,n.texturesEnabled)){if(this._albedoTexture&&jn.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&jn.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&jn.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;const e=this._getReflectionTexture();if(e&&jn.ReflectionTextureEnabled){if(!e.isReadyOrNotBlocking())return!1;if(e.irradianceTexture){if(!e.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!e.sphericalPolynomial&&e.getInternalTexture()?._sphericalPolynomialPromise)return!1}if(this._lightmapTexture&&jn.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&jn.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(jn.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking())return!1;if(this._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(a.getCaps().standardDerivatives&&this._bumpTexture&&jn.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&jn.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=r,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(r._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;a.getCaps().standardDerivatives||e.isVerticesDataPresent(wi.NormalKind)||(e.createNormals(!0),Ae.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));const o=t.effect,h=r._areLightsDisposed;let l=this._prepareEffect(e,r,this.onCompiled,this.onError,i,null,t.getRenderingMesh().hasThinInstances),c=!1;if(l)if(this._onEffectCreatedObservable&&(Ea.effect=l,Ea.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Ea)),this.allowShaderHotSwapping&&o&&!l.isReady()){if(l=o,r.markAsUnprocessed(),c=this.isFrozen,h)return r._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),t.setEffect(l,r,this._materialContext);return!(!t.effect||!t.effect.isReady())&&(r._renderId=n.getRenderId(),s._wasPreviouslyReady=!c,s._wasPreviouslyUsingInstances=!!i,this._checkScenePerformancePriority(),!0)}isMetallicWorkflow(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)}_prepareEffect(e,t,i=null,s=null,r=null,n=null,a){if(this._prepareDefines(e,t,r,n,a),!t.isDirty)return null;t.markAsProcessed();const o=this.getScene().getEngine(),h=new na;let l=0;t.USESPHERICALINVERTEX&&h.addFallback(l++,"USESPHERICALINVERTEX"),t.FOG&&h.addFallback(l,"FOG"),t.SPECULARAA&&h.addFallback(l,"SPECULARAA"),t.POINTSIZE&&h.addFallback(l,"POINTSIZE"),t.LOGARITHMICDEPTH&&h.addFallback(l,"LOGARITHMICDEPTH"),t.PARALLAX&&h.addFallback(l,"PARALLAX"),t.PARALLAX_RHS&&h.addFallback(l,"PARALLAX_RHS"),t.PARALLAXOCCLUSION&&h.addFallback(l++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&h.addFallback(l++,"ENVIRONMENTBRDF"),t.TANGENT&&h.addFallback(l++,"TANGENT"),t.BUMP&&h.addFallback(l++,"BUMP"),l=Ss(t,h,this._maxSimultaneousLights,l++),t.SPECULARTERM&&h.addFallback(l++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&h.addFallback(l++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&h.addFallback(l++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&h.addFallback(l++,"LIGHTMAP"),t.NORMAL&&h.addFallback(l++,"NORMAL"),t.AMBIENT&&h.addFallback(l++,"AMBIENT"),t.EMISSIVE&&h.addFallback(l++,"EMISSIVE"),t.VERTEXCOLOR&&h.addFallback(l++,"VERTEXCOLOR"),t.MORPHTARGETS&&h.addFallback(l++,"MORPHTARGETS"),t.MULTIVIEW&&h.addFallback(0,"MULTIVIEW");const c=[wi.PositionKind];t.NORMAL&&c.push(wi.NormalKind),t.TANGENT&&c.push(wi.TangentKind);for(let e=1;e<=Ve.MAX_SUPPORTED_UV_SETS;++e)t["UV"+e]&&c.push(`uv${1===e?"":e}`);t.VERTEXCOLOR&&c.push(wi.ColorKind),vs(c,e,t,h),xs(c,t),Ts(c,e,t),Rs(c,0,t);let u="pbr";const d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vMetallicReflectanceFactors","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vReflectionFilteringInfo","vMetallicReflectanceInfos","vReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","reflectanceMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX_ZZ","vSphericalYY_ZZ","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vSphericalL00","vSphericalL1_1","vSphericalL10","vSphericalL11","vSphericalL2_2","vSphericalL2_1","vSphericalL20","vSphericalL21","vSphericalL22","vReflectionMicrosurfaceInfos","vTangentSpaceParams","boneTextureWidth","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices"],_=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler","reflectanceSampler","morphTargets","oitDepthSampler","oitFrontColorSampler","icdfxSampler","icdfySampler"],f=["Material","Scene","Mesh"],p={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=h,this._eventInfo.fallbackRank=l,this._eventInfo.defines=t,this._eventInfo.uniforms=d,this._eventInfo.attributes=c,this._eventInfo.samplers=_,this._eventInfo.uniformBuffersNames=f,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=p,this._callbackPluginEventGeneric(128,this._eventInfo),Aa.AddUniformsAndSamplers(d,_),Qn.AddUniforms(d),ds(d),Lr&&(Lr.PrepareUniforms(d,t),Lr.PrepareSamplers(_,t)),Us({uniformsNames:d,uniformBuffersNames:f,samplers:_,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});const g={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,d,f,_,t,c,g));const m=t.toString(),T=o.createEffect(u,{attributes:c,uniformsNames:d,uniformBuffersNames:f,samplers:_,defines:m,fallbacks:h,onCompiled:i,onError:s,indexParameters:p,processFinalCode:g.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:t.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{1===this.shaderLanguage?await Promise.all([import("./pbr.vertex-CzdtHEkI.esm.min.js"),import("./pbr.fragment-nFI8xyI0.esm.min.js")]):await Promise.all([import("./pbr.vertex-CzNCwEDt.esm.min.js"),import("./pbr.fragment-C3zMQTsB.esm.min.js")]),this._shadersLoaded=!0}},o);return this._eventInfo.customCode=void 0,T}_prepareDefines(e,t,i=null,s=null,r=!1){const n=this.getScene(),a=n.getEngine();Ps(n,e,t,!0,this._maxSimultaneousLights,this._disableLighting),t._needNormals=!0,Fs(n,t);const o=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Ns(n,t,this.canRenderToMRT&&!o),ws(n,t,o),Aa.PrepareDefines(a.currentRenderPassId,e,t),t.METALLICWORKFLOW=this.isMetallicWorkflow(),t._areTexturesDirty){t._needUVs=!1;for(let e=1;e<=Ve.MAX_SUPPORTED_UV_SETS;++e)t["MAINUV"+e]=!1;if(n.texturesEnabled){t.ALBEDODIRECTUV=0,t.AMBIENTDIRECTUV=0,t.OPACITYDIRECTUV=0,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITYDIRECTUV=0,t.MICROSURFACEMAPDIRECTUV=0,t.METALLIC_REFLECTANCEDIRECTUV=0,t.REFLECTANCEDIRECTUV=0,t.BUMPDIRECTUV=0,t.LIGHTMAPDIRECTUV=0,a.getCaps().textureLOD&&(t.LODBASEDMICROSFURACE=!0),this._albedoTexture&&jn.DiffuseTextureEnabled?(Es(this._albedoTexture,t,"ALBEDO"),t.GAMMAALBEDO=this._albedoTexture.gammaSpace):t.ALBEDO=!1,this._ambientTexture&&jn.AmbientTextureEnabled?(Es(this._ambientTexture,t,"AMBIENT"),t.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):t.AMBIENT=!1,this._opacityTexture&&jn.OpacityTextureEnabled?(Es(this._opacityTexture,t,"OPACITY"),t.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):t.OPACITY=!1;const e=this._getReflectionTexture();if(e&&jn.ReflectionTextureEnabled){switch(t.REFLECTION=!0,t.GAMMAREFLECTION=e.gammaSpace,t.RGBDREFLECTION=e.isRGBD,t.LODINREFLECTIONALPHA=e.lodLevelInAlpha,t.LINEARSPECULARREFLECTION=e.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(t.NUM_SAMPLES=""+this.realTimeFilteringQuality,a._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,this.getScene().iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=e.coordinatesMode===bn.INVCUBIC_MODE,t.REFLECTIONMAP_3D=e.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!e.invertZ:e.invertZ,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.coordinatesMode){case bn.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case bn.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case bn.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case bn.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case bn.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case bn.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case bn.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case bn.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case bn.CUBIC_MODE:case bn.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!e.boundingBoxSize}e.coordinatesMode!==bn.SKYBOX_MODE&&(e.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1):e.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||a.getCaps().maxVaryingVectors<=8?t.USESPHERICALINVERTEX=!1:t.USESPHERICALINVERTEX=!0))}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&jn.LightmapTextureEnabled?(Es(this._lightmapTexture,t,"LIGHTMAP"),t.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,t.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,t.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):t.LIGHTMAP=!1,this._emissiveTexture&&jn.EmissiveTextureEnabled?(Es(this._emissiveTexture,t,"EMISSIVE"),t.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):t.EMISSIVE=!1,jn.SpecularTextureEnabled?(this._metallicTexture?(Es(this._metallicTexture,t,"REFLECTIVITY"),t.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,t.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,t.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,t.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,t.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(Es(this._reflectivityTexture,t,"REFLECTIVITY"),t.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,t.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,t.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):t.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(t.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?(Es(this._metallicReflectanceTexture,t,"METALLIC_REFLECTANCE"),t.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):t.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(Es(this._reflectanceTexture,t,"REFLECTANCE"),t.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):t.REFLECTANCE=!1):(t.METALLIC_REFLECTANCE=!1,t.REFLECTANCE=!1),this._microSurfaceTexture?Es(this._microSurfaceTexture,t,"MICROSURFACEMAP"):t.MICROSURFACEMAP=!1):(t.REFLECTIVITY=!1,t.MICROSURFACEMAP=!1),a.getCaps().standardDerivatives&&this._bumpTexture&&jn.BumpTextureEnabled&&!this._disableBumpMap?(Es(this._bumpTexture,t,"BUMP"),this._useParallax&&this._albedoTexture&&jn.DiffuseTextureEnabled?(t.PARALLAX=!0,t.PARALLAX_RHS=n.useRightHandedSystem,t.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):t.PARALLAX=!1,t.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(t.BUMP=!1,t.PARALLAX=!1,t.PARALLAX_RHS=!1,t.PARALLAXOCCLUSION=!1,t.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&jn.ReflectionTextureEnabled?(t.ENVIRONMENTBRDF=!0,t.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(t.ENVIRONMENTBRDF=!1,t.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?t.ALPHAFROMALBEDO=!0:t.ALPHAFROMALBEDO=!1}t.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===Ra.LIGHTFALLOFF_STANDARD?(t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===Ra.LIGHTFALLOFF_GLTF?(t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!0):(t.USEPHYSICALLIGHTFALLOFF=!0,t.USEGLTFLIGHTFALLOFF=!1),t.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?t.TWOSIDEDLIGHTING=!0:t.TWOSIDEDLIGHTING=!1,t.SPECULARAA=a.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(t._areTexturesDirty||t._areMiscDirty)&&(t.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1==0?".":""}`,t.PREMULTIPLYALPHA=this.alphaMode===Ve.ALPHA_PREMULTIPLIED||this.alphaMode===Ve.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHABLEND=this.needAlphaBlendingForMesh(e),t.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,t.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),t._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(t),t.FORCENORMALFORWARD=this._forceNormalForward,t.RADIANCEOCCLUSION=this._useRadianceOcclusion,t.HORIZONOCCLUSION=this._useHorizonOcclusion,t._areMiscDirty&&(Cs(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,t,this._applyDecalMapAfterDetailMap),t.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(wi.NormalKind),t.DEBUGMODE=this._debugMode),Ds(n,a,this,t,!!i,s,r),this._eventInfo.defines=t,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Ls(e,t,!0,!0,!0,this._transparencyMode!==Ra.PBRMATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}forceCompilation(e,t,i){const s={clipPlane:!1,useInstances:!1,...i};this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo);(()=>{if(this._breakShaderLoadedCheck)return;const i=new ba(this._eventInfo.defineNames),r=this._prepareEffect(e,i,void 0,void 0,s.useInstances,s.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(Ea.effect=r,Ea.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Ea)),r.isReady()?t&&t(this):r.onCompileObservable.add((()=>{t&&t(this)}))})()}buildUniformLayout(){const e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionFilteringInfo",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("reflectionMatrix",16),e.addUniform("vReflectionColor",3),e.addUniform("vAlbedoColor",4),e.addUniform("vLightingIntensity",4),e.addUniform("vReflectionMicrosurfaceInfos",3),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vAmbientColor",3),e.addUniform("vDebugMode",2),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),e.addUniform("vReflectanceInfos",2),e.addUniform("reflectanceMatrix",16),e.addUniform("vSphericalL00",3),e.addUniform("vSphericalL1_1",3),e.addUniform("vSphericalL10",3),e.addUniform("vSphericalL11",3),e.addUniform("vSphericalL2_2",3),e.addUniform("vSphericalL2_1",3),e.addUniform("vSphericalL20",3),e.addUniform("vSphericalL21",3),e.addUniform("vSphericalL22",3),e.addUniform("vSphericalX",3),e.addUniform("vSphericalY",3),e.addUniform("vSphericalZ",3),e.addUniform("vSphericalXX_ZZ",3),e.addUniform("vSphericalYY_ZZ",3),e.addUniform("vSphericalZZ",3),e.addUniform("vSphericalXY",3),e.addUniform("vSphericalYZ",3),e.addUniform("vSphericalZX",3),super.buildUniformLayout()}bindForSubMesh(e,t,i){const s=this.getScene(),r=i.materialDefines;if(!r)return;const n=i.effect;if(!n)return;this._activeEffect=n,t.getMeshUniformBuffer().bindToEffect(n,"Mesh"),t.transferToEffect(e);const a=s.getEngine();this._uniformBuffer.bindToEffect(n,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,s,t,e,this.isFrozen),Aa.Bind(a.currentRenderPassId,this._activeEffect,t,e),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const o=this._mustRebind(s,n,i,t.visibility);ys(t,this._activeEffect,this.prePassConfiguration);let h=null;const l=this._uniformBuffer;if(o){if(this.bindViewProjection(n),h=this._getReflectionTexture(),!l.useUbo||!this.isFrozen||!l.isSync||i._drawWrapper._forceRebindOnNextCall){if(s.texturesEnabled){if(this._albedoTexture&&jn.DiffuseTextureEnabled&&(l.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),bs(this._albedoTexture,l,"albedo")),this._ambientTexture&&jn.AmbientTextureEnabled&&(l.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),bs(this._ambientTexture,l,"ambient")),this._opacityTexture&&jn.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),bs(this._opacityTexture,l,"opacity")),h&&jn.ReflectionTextureEnabled){if(l.updateMatrix("reflectionMatrix",h.getReflectionTextureMatrix()),l.updateFloat2("vReflectionInfos",h.level,0),h.boundingBoxSize){const e=h;l.updateVector3("vReflectionPosition",e.boundingBoxPosition),l.updateVector3("vReflectionSize",e.boundingBoxSize)}if(this.realTimeFiltering){const e=h.getSize().width;l.updateFloat2("vReflectionFilteringInfo",e,Math.log2(e))}if(!r.USEIRRADIANCEMAP){const e=h.sphericalPolynomial;if(r.USESPHERICALFROMREFLECTIONMAP&&e)if(r.SPHERICAL_HARMONICS){const t=e.preScaledHarmonics;l.updateVector3("vSphericalL00",t.l00),l.updateVector3("vSphericalL1_1",t.l1_1),l.updateVector3("vSphericalL10",t.l10),l.updateVector3("vSphericalL11",t.l11),l.updateVector3("vSphericalL2_2",t.l2_2),l.updateVector3("vSphericalL2_1",t.l2_1),l.updateVector3("vSphericalL20",t.l20),l.updateVector3("vSphericalL21",t.l21),l.updateVector3("vSphericalL22",t.l22)}else l.updateFloat3("vSphericalX",e.x.x,e.x.y,e.x.z),l.updateFloat3("vSphericalY",e.y.x,e.y.y,e.y.z),l.updateFloat3("vSphericalZ",e.z.x,e.z.y,e.z.z),l.updateFloat3("vSphericalXX_ZZ",e.xx.x-e.zz.x,e.xx.y-e.zz.y,e.xx.z-e.zz.z),l.updateFloat3("vSphericalYY_ZZ",e.yy.x-e.zz.x,e.yy.y-e.zz.y,e.yy.z-e.zz.z),l.updateFloat3("vSphericalZZ",e.zz.x,e.zz.y,e.zz.z),l.updateFloat3("vSphericalXY",e.xy.x,e.xy.y,e.xy.z),l.updateFloat3("vSphericalYZ",e.yz.x,e.yz.y,e.yz.z),l.updateFloat3("vSphericalZX",e.zx.x,e.zx.y,e.zx.z)}l.updateFloat3("vReflectionMicrosurfaceInfos",h.getSize().width,h.lodGenerationScale,h.lodGenerationOffset)}this._emissiveTexture&&jn.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),bs(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&jn.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),bs(this._lightmapTexture,l,"lightmap")),jn.SpecularTextureEnabled&&(this._metallicTexture?(l.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),bs(this._metallicTexture,l,"reflectivity")):this._reflectivityTexture&&(l.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),bs(this._reflectivityTexture,l,"reflectivity")),this._metallicReflectanceTexture&&(l.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),bs(this._metallicReflectanceTexture,l,"metallicReflectance")),this._reflectanceTexture&&r.REFLECTANCE&&(l.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),bs(this._reflectanceTexture,l,"reflectance")),this._microSurfaceTexture&&(l.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),bs(this._microSurfaceTexture,l,"microSurfaceSampler"))),this._bumpTexture&&a.getCaps().standardDerivatives&&jn.BumpTextureEnabled&&!this._disableBumpMap&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),bs(this._bumpTexture,l,"bump"),s._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),r.METALLICWORKFLOW){ce.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,ce.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,l.updateColor4("vReflectivityColor",ce.Color3[0],1);const e=this.subSurface?._indexOfRefraction??1.5,t=1,i=Math.pow((e-t)/(e+t),2);this._metallicReflectanceColor.scaleToRef(i*this._metallicF0Factor,ce.Color3[0]);const s=this._metallicF0Factor;l.updateColor4("vMetallicReflectanceFactors",ce.Color3[0],s)}else l.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);l.updateColor3("vEmissiveColor",jn.EmissiveTextureEnabled?this._emissiveColor:he.BlackReadOnly),l.updateColor3("vReflectionColor",this._reflectionColor),!r.SS_REFRACTION&&this.subSurface?._linkRefractionWithTransparency?l.updateColor4("vAlbedoColor",this._albedoColor,1):l.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*s.environmentIntensity,this._lightingInfos.w=this._specularIntensity,l.updateVector4("vLightingIntensity",this._lightingInfos),s.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),l.updateColor3("vAmbientColor",this._globalAmbientColor),l.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}if(s.texturesEnabled){if(this._albedoTexture&&jn.DiffuseTextureEnabled&&l.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&jn.AmbientTextureEnabled&&l.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&jn.OpacityTextureEnabled&&l.setTexture("opacitySampler",this._opacityTexture),h&&jn.ReflectionTextureEnabled){r.LODBASEDMICROSFURACE?l.setTexture("reflectionSampler",h):(l.setTexture("reflectionSampler",h._lodTextureMid||h),l.setTexture("reflectionSamplerLow",h._lodTextureLow||h),l.setTexture("reflectionSamplerHigh",h._lodTextureHigh||h)),r.USEIRRADIANCEMAP&&l.setTexture("irradianceSampler",h.irradianceTexture);const e=this.getScene().iblCdfGenerator;this.realTimeFiltering&&e&&(l.setTexture("icdfxSampler",e.getIcdfxTexture()),l.setTexture("icdfySampler",e.getIcdfyTexture()))}r.ENVIRONMENTBRDF&&l.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&jn.EmissiveTextureEnabled&&l.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&jn.LightmapTextureEnabled&&l.setTexture("lightmapSampler",this._lightmapTexture),jn.SpecularTextureEnabled&&(this._metallicTexture?l.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&l.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&l.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&r.REFLECTANCE&&l.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&l.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&a.getCaps().standardDerivatives&&jn.BumpTextureEnabled&&!this._disableBumpMap&&l.setTexture("bumpSampler",this._bumpTexture)}this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(n),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),_s(this._activeEffect,this,s),this.bindEyePosition(n)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!o&&this.isFrozen||(s.lightsEnabled&&!this._disableLighting&&Ms(s,t,this._activeEffect,r,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==ln.FOGMODE_NONE||h||this.subSurface.refractionTexture||t.receiveShadows||r.PREPASS)&&this.bindView(n),ms(s,t,this._activeEffect,!0),r.NUM_MORPH_INFLUENCERS&&As(t,this._activeEffect),r.BAKED_VERTEX_ANIMATION_TEXTURE&&t.bakedVertexAnimationManager?.bind(n,r.INSTANCES),this._imageProcessingConfiguration.bind(this._activeEffect),gs(r,this._activeEffect,s)),this._afterBind(t,this._activeEffect,i),l.update()}getAnimatables(){const e=super.getAnimatables();return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._metallicReflectanceTexture&&this._metallicReflectanceTexture.animations&&this._metallicReflectanceTexture.animations.length>0&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&this._reflectanceTexture.animations&&this._reflectanceTexture.animations.length>0&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&this._microSurfaceTexture.animations&&this._microSurfaceTexture.animations.length>0&&e.push(this._microSurfaceTexture),e}_getReflectionTexture(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture}getActiveTextures(){const e=super.getActiveTextures();return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._metallicReflectanceTexture&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),e}hasTexture(e){return!!super.hasTexture(e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._metallicReflectanceTexture===e||(this._reflectanceTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||this._lightmapTexture===e)))))))))))}setPrePassRenderer(){if(!this.subSurface?.isScatteringEnabled)return!1;const e=this.getScene().enableSubSurfaceForPrePass();return e&&(e.enabled=!0),!0}dispose(e,t){this._breakShaderLoadedCheck=!0,t&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._albedoTexture?.dispose(),this._ambientTexture?.dispose(),this._opacityTexture?.dispose(),this._reflectionTexture?.dispose(),this._emissiveTexture?.dispose(),this._metallicTexture?.dispose(),this._reflectivityTexture?.dispose(),this._bumpTexture?.dispose(),this._lightmapTexture?.dispose(),this._metallicReflectanceTexture?.dispose(),this._reflectanceTexture?.dispose(),this._microSurfaceTexture?.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}}Ra.PBRMATERIAL_OPAQUE=ks.MATERIAL_OPAQUE,Ra.PBRMATERIAL_ALPHATEST=ks.MATERIAL_ALPHATEST,Ra.PBRMATERIAL_ALPHABLEND=ks.MATERIAL_ALPHABLEND,Ra.PBRMATERIAL_ALPHATESTANDBLEND=ks.MATERIAL_ALPHATESTANDBLEND,Ra.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,Ra.LIGHTFALLOFF_PHYSICAL=0,Ra.LIGHTFALLOFF_GLTF=1,Ra.LIGHTFALLOFF_STANDARD=2,Ra.ForceGLSL=!1,e([function(e){return r(9,e)}()],Ra.prototype,"_imageProcessingConfiguration",void 0),e([n("_markAllSubMeshesAsMiscDirty")],Ra.prototype,"debugMode",void 0);class ya extends Ra{get refractionTexture(){return this.subSurface.refractionTexture}set refractionTexture(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)}get indexOfRefraction(){return this.subSurface.indexOfRefraction}set indexOfRefraction(e){this.subSurface.indexOfRefraction=e}get invertRefractionY(){return this.subSurface.invertRefractionY}set invertRefractionY(e){this.subSurface.invertRefractionY=e}get linkRefractionWithTransparency(){return this.subSurface.linkRefractionWithTransparency}set linkRefractionWithTransparency(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)}get usePhysicalLightFalloff(){return this._lightFalloff===Ra.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?Ra.LIGHTFALLOFF_PHYSICAL:Ra.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===Ra.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?Ra.LIGHTFALLOFF_GLTF:Ra.LIGHTFALLOFF_STANDARD)}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}constructor(e,t,i=!1){super(e,t,i),this.directIntensity=1,this.emissiveIntensity=1,this.environmentIntensity=1,this.specularIntensity=1,this.disableBumpMap=!1,this.ambientTextureStrength=1,this.ambientTextureImpactOnAnalyticalLights=ya.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this.metallicF0Factor=1,this.metallicReflectanceColor=he.White(),this.useOnlyMetallicFromMetallicReflectanceTexture=!1,this.ambientColor=new he(0,0,0),this.albedoColor=new he(1,1,1),this.reflectivityColor=new he(1,1,1),this.reflectionColor=new he(1,1,1),this.emissiveColor=new he(0,0,0),this.microSurface=1,this.useLightmapAsShadowmap=!1,this.useAlphaFromAlbedoTexture=!1,this.forceAlphaTest=!1,this.alphaCutOff=.4,this.useSpecularOverAlpha=!0,this.useMicroSurfaceFromReflectivityMapAlpha=!1,this.useRoughnessFromMetallicTextureAlpha=!0,this.useRoughnessFromMetallicTextureGreen=!1,this.useMetallnessFromMetallicTextureBlue=!1,this.useAmbientOcclusionFromMetallicTextureRed=!1,this.useAmbientInGrayScale=!1,this.useAutoMicroSurfaceFromReflectivityMap=!1,this.useRadianceOverAlpha=!0,this.useObjectSpaceNormalMap=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.forceIrradianceInFragment=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.twoSidedLighting=!1,this.useAlphaFresnel=!1,this.useLinearAlphaFresnel=!1,this.environmentBRDFTexture=null,this.forceNormalForward=!1,this.enableSpecularAntiAliasing=!1,this.useHorizonOcclusion=!0,this.useRadianceOcclusion=!0,this.unlit=!1,this.applyDecalMapAfterDetailMap=!1,this._environmentBRDFTexture=kn(this.getScene())}getClassName(){return"PBRMaterial"}clone(e,t=!0,i=""){const s=de.Clone((()=>new ya(e,this.getScene())),this,{cloneTexturesOnlyOnce:t});return s.id=e,s.name=e,this.stencil.copyTo(s.stencil),this._clonePlugins(s,i),s}serialize(){const e=super.serialize();return e.customType="BABYLON.PBRMaterial",e}static Parse(e,t,i){const s=de.Parse((()=>new ya(e.name,t)),e,t,i);return e.stencil&&s.stencil.parse(e.stencil,t,i),ks._ParsePlugins(e,s,t,i),e.clearCoat&&s.clearCoat.parse(e.clearCoat,t,i),e.anisotropy&&s.anisotropy.parse(e.anisotropy,t,i),e.brdf&&s.brdf.parse(e.brdf,t,i),e.sheen&&s.sheen.parse(e.sheen,t,i),e.subSurface&&s.subSurface.parse(e.subSurface,t,i),e.iridescence&&s.iridescence.parse(e.iridescence,t,i),s}}ya.PBRMATERIAL_OPAQUE=Ra.PBRMATERIAL_OPAQUE,ya.PBRMATERIAL_ALPHATEST=Ra.PBRMATERIAL_ALPHATEST,ya.PBRMATERIAL_ALPHABLEND=Ra.PBRMATERIAL_ALPHABLEND,ya.PBRMATERIAL_ALPHATESTANDBLEND=Ra.PBRMATERIAL_ALPHATESTANDBLEND,ya.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=Ra.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"directIntensity",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"emissiveIntensity",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"environmentIntensity",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"specularIntensity",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"disableBumpMap",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"albedoTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"ambientTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"ambientTextureStrength",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),e([o(),n("_markAllSubMeshesAsTexturesAndMiscDirty")],ya.prototype,"opacityTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"reflectionTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"emissiveTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"reflectivityTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"metallicTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"metallic",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"roughness",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"metallicF0Factor",void 0),e([h(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"metallicReflectanceColor",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"metallicReflectanceTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"reflectanceTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"microSurfaceTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"bumpTexture",void 0),e([o(),n("_markAllSubMeshesAsTexturesDirty",null)],ya.prototype,"lightmapTexture",void 0),e([h("ambient"),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"ambientColor",void 0),e([h("albedo"),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"albedoColor",void 0),e([h("reflectivity"),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"reflectivityColor",void 0),e([h("reflection"),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"reflectionColor",void 0),e([h("emissive"),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"emissiveColor",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"microSurface",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useLightmapAsShadowmap",void 0),e([a(),n("_markAllSubMeshesAsTexturesAndMiscDirty")],ya.prototype,"useAlphaFromAlbedoTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesAndMiscDirty")],ya.prototype,"forceAlphaTest",void 0),e([a(),n("_markAllSubMeshesAsTexturesAndMiscDirty")],ya.prototype,"alphaCutOff",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useSpecularOverAlpha",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useRoughnessFromMetallicTextureGreen",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useMetallnessFromMetallicTextureBlue",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useAmbientInGrayScale",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),e([a()],ya.prototype,"usePhysicalLightFalloff",null),e([a()],ya.prototype,"useGLTFLightFalloff",null),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useRadianceOverAlpha",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useObjectSpaceNormalMap",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useParallax",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useParallaxOcclusion",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"parallaxScaleBias",void 0),e([a(),n("_markAllSubMeshesAsLightsDirty")],ya.prototype,"disableLighting",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"forceIrradianceInFragment",void 0),e([a(),n("_markAllSubMeshesAsLightsDirty")],ya.prototype,"maxSimultaneousLights",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"invertNormalMapX",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"invertNormalMapY",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"twoSidedLighting",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useAlphaFresnel",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useLinearAlphaFresnel",void 0),e([n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"environmentBRDFTexture",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"forceNormalForward",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"enableSpecularAntiAliasing",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useHorizonOcclusion",void 0),e([a(),n("_markAllSubMeshesAsTexturesDirty")],ya.prototype,"useRadianceOcclusion",void 0),e([a(),n("_markAllSubMeshesAsMiscDirty")],ya.prototype,"unlit",void 0),e([a(),n("_markAllSubMeshesAsMiscDirty")],ya.prototype,"applyDecalMapAfterDetailMap",void 0),S("BABYLON.PBRMaterial",ya),Wt.prototype._partialLoadFile=function(e,t,i,s,r=null){this._loadFile(e,(e=>{i[t]=e,i._internalCount++,6===i._internalCount&&s(i)}),void 0,void 0,!0,((e,t)=>{r&&e&&r(e.status+" "+e.statusText,t)}))},Wt.prototype._cascadeLoadFiles=function(e,t,i,s=null){const r=[];r._internalCount=0;for(let e=0;e<6;e++)this._partialLoadFile(i[e],e,r,t,s)},Wt.prototype._cascadeLoadImgs=function(e,t,i,s,r=null,n){const a=[];a._internalCount=0;for(let o=0;o<6;o++)this._partialLoadImg(s[o],o,a,e,t,i,r,n)},Wt.prototype._partialLoadImg=function(e,t,i,s,r,n,a=null,o){const h=hi();Zt(e,(e=>{i[t]=e,i._internalCount++,s&&s.removePendingData(h),6===i._internalCount&&n&&n(r,i)}),((e,t)=>{s&&s.removePendingData(h),a&&a(e,t)}),s?s.offlineProvider:null,o),s&&s.addPendingData(h)},Wt.prototype.createCubeTextureBase=function(e,t,i,s,r=null,n=null,a,o=null,h=!1,l=0,c=0,u=null,d=null,_=null,f=!1,p=null){const g=u||new kt(this,7);g.isCube=!0,g.url=e,g.generateMipMaps=!s,g._lodGenerationScale=l,g._lodGenerationOffset=c,g._useSRGBBuffer=!!f&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!s),g!==u&&(g.label=e.substring(0,60)),this._doNotHandleContextLost||(g._extension=o,g._files=i,g._buffer=p);const m=e;this._transformTextureUrl&&!u&&(e=this._transformTextureUrl(e));const T=e.split("?")[0],A=T.lastIndexOf("."),E=Gt(o||(A>-1?T.substring(A).toLowerCase():"")),b=(u,T)=>{e===m?n&&u&&n(u.status+" "+u.statusText,T):(Ae.Warn(`Failed to load ${e}, falling back to the ${m}`),this.createCubeTextureBase(m,t,i,!!s,r,n,a,o,h,l,c,g,d,_,f,p))};if(E)E.then((s=>{const a=e=>{d&&d(g,e),s.loadCubeData(e,g,h,r,n)};p?a(p):i&&6===i.length?s.supportCascades?this._cascadeLoadFiles(t,(e=>a(e.map((e=>new Uint8Array(e))))),i,n):n?n("Textures type does not support cascades."):Ae.Warn("Texture loader does not support cascades."):this._loadFile(e,(e=>a(new Uint8Array(e))),void 0,void 0,!0,b)}));else{if(!i||0===i.length)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(t,g,((e,t)=>{_&&_(e,t)}),i,n)}return this._internalTexturesCache.push(g),g};class Ia extends An{set boundingBoxSize(e){if(this._boundingBoxSize&&this._boundingBoxSize.equals(e))return;this._boundingBoxSize=e;const t=this.getScene();t&&t.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag)}get boundingBoxSize(){return this._boundingBoxSize}set rotationY(e){this._rotationY=e,this.setReflectionTextureMatrix(j.RotationY(this._rotationY))}get rotationY(){return this._rotationY}get noMipmap(){return this._noMipmap}get forcedExtension(){return this._forcedExtension}static CreateFromImages(e,t,i){let s="";return e.forEach((e=>s+=e)),new Ia(s,t,null,i,e)}static CreateFromPrefilteredData(e,t,i=null,s=!0){const r=t.useDelayedTextureLoading;t.useDelayedTextureLoading=!1;const n=new Ia(e,t,null,!1,null,null,null,void 0,!0,i,s);return t.useDelayedTextureLoading=r,n}constructor(e,t,i=null,s=!1,r=null,n=null,a=null,o=Ve.TEXTUREFORMAT_RGBA,h=!1,l=null,c=!1,u=.8,d=0,_,f){super(t),this.onLoadObservable=new A,this.boundingBoxPosition=X.Zero(),this._rotationY=0,this._files=null,this._forcedExtension=null,this._extensions=null,this._textureMatrixRefraction=new j,this._buffer=null,this.name=e,this.url=e,this._noMipmap=s,this.hasAlpha=!1,this.isCube=!0,this._textureMatrix=j.Identity(),this.coordinatesMode=bn.CUBIC_MODE;let p=null,g=null;null===i||Array.isArray(i)?(this._noMipmap=s,this._format=o,this._createPolynomials=c,p=i,this._loaderOptions=_,this._useSRGBBuffer=f,this._lodScale=u,this._lodOffset=d):(p=i.extensions??null,this._noMipmap=i.noMipmap??!1,r=i.files??null,g=i.buffer??null,this._format=i.format??Ve.TEXTUREFORMAT_RGBA,h=i.prefiltered??!1,l=i.forcedExtension??null,this._createPolynomials=i.createPolynomials??!1,this._lodScale=i.lodScale??.8,this._lodOffset=i.lodOffset??0,this._loaderOptions=i.loaderOptions,this._useSRGBBuffer=i.useSRGBBuffer,n=i.onLoad??null,a=i.onError??null),(e||r)&&this.updateURL(e,l,n,h,a,p,this.getScene()?.useDelayedTextureLoading,r,g)}getClassName(){return"CubeTexture"}updateURL(e,t=null,i=null,s=!1,r=null,n=null,a=!1,o=null,h=null){this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,t&&(this._forcedExtension=t);const l=e.lastIndexOf("."),c=t||(l>-1?e.substring(l).toLowerCase():""),u=0===c.indexOf(".dds"),d=0===c.indexOf(".env"),_=0===c.indexOf(".basis");if(d?(this.gammaSpace=!1,this._prefiltered=!1,this.anisotropicFilteringLevel=1):(this._prefiltered=s,s&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1)),o)this._files=o;else if(_||d||u||n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),this._files=this._files||[],this._files.length=0,n){for(let t=0;t<n.length;t++)this._files.push(e+n[t]);this._extensions=n}this._buffer=h,a?(this.delayLoadState=Ve.DELAYLOADSTATE_NOTLOADED,this._delayedOnLoad=i,this._delayedOnError=r):this._loadTexture(i,r)}delayLoad(e){this.delayLoadState===Ve.DELAYLOADSTATE_NOTLOADED&&(e&&(this._forcedExtension=e),this.delayLoadState=Ve.DELAYLOADSTATE_LOADED,this._loadTexture(this._delayedOnLoad,this._delayedOnError))}getReflectionTextureMatrix(){return this._textureMatrix}setReflectionTextureMatrix(e){if(e.updateFlag===this._textureMatrix.updateFlag)return;if(e.isIdentity()!==this._textureMatrix.isIdentity()&&this.getScene()?.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag,(e=>-1!==e.getActiveTextures().indexOf(this))),this._textureMatrix=e,!this.getScene()?.useRightHandedSystem)return;const t=J.Vector3[0],i=J.Quaternion[0],s=J.Vector3[1];this._textureMatrix.decompose(t,i,s),i.z*=-1,i.w*=-1,j.ComposeToRef(t,i,s,this._textureMatrixRefraction)}getRefractionTextureMatrix(){return this.getScene()?.useRightHandedSystem?this._textureMatrixRefraction:this._textureMatrix}_loadTexture(e=null,t=null){const i=this.getScene(),s=this._texture;this._texture=this._getFromCache(this.url,this._noMipmap,void 0,void 0,this._useSRGBBuffer,this.isCube);const r=()=>{this.onLoadObservable.notifyObservers(this),s&&(s.dispose(),this.getScene()?.markAllMaterialsAsDirty(Ve.MATERIAL_TextureDirtyFlag)),e&&e()},n=(e,i)=>{this._loadingError=!0,this._errorObject={message:e,exception:i},t&&t(e,i),bn.OnTextureLoadErrorObservable.notifyObservers(this)};this._texture?this._texture.isReady?pi.SetImmediate((()=>r())):this._texture.onLoadedObservable.add((()=>r())):(this._prefiltered?this._texture=this._getEngine().createPrefilteredCubeTexture(this.url,i,this._lodScale,this._lodOffset,e,n,this._format,this._forcedExtension,this._createPolynomials):this._texture=this._getEngine().createCubeTexture(this.url,i,this._files,this._noMipmap,e,n,this._format,this._forcedExtension,!1,this._lodScale,this._lodOffset,null,this._loaderOptions,!!this._useSRGBBuffer,this._buffer),this._texture?.onLoadedObservable.add((()=>this.onLoadObservable.notifyObservers(this))))}static Parse(e,t,i){const s=de.Parse((()=>{let s=!1;return e.prefiltered&&(s=e.prefiltered),new Ia(i+(e.url??e.name),t,e.extensions,!1,e.files||null,null,null,void 0,s,e.forcedExtension)}),e,t);if(e.boundingBoxPosition&&(s.boundingBoxPosition=X.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(s.boundingBoxSize=X.FromArray(e.boundingBoxSize)),e.animations)for(let t=0;t<e.animations.length;t++){const i=e.animations[t],r=C("BABYLON.Animation");r&&s.animations.push(r.Parse(i))}return s}clone(){let e=0;const t=de.Clone((()=>{const t=new Ia(this.url,this.getScene()||this._getEngine(),this._extensions,this._noMipmap,this._files);return e=t.uniqueId,t}),this);return t.uniqueId=e,t}}function Ma(e,t,i){const s=e.getVerticesData(wi.PositionKind);if(!s)return!1;const r=3*t,n=[s[r+0],s[r+1],s[r+2]];if(n.some((e=>isNaN(e??Number.NaN))))return!1;if(e.morphTargetManager)for(let t=0;t<3;t++){let i=n[t];for(let n=0;n<e.morphTargetManager.numTargets;n++){const a=e.morphTargetManager.getTarget(n),o=a.influence;if(0!==o){const e=a.getPositions();e&&(i+=(e[r+t]-s[r+t])*o)}}n[t]=i}if(i.fromArray(n),e.skeleton){const s=e.getVerticesData(wi.MatricesIndicesKind),r=e.getVerticesData(wi.MatricesWeightsKind);if(r&&s){const a=e.numBoneInfluencers>4,o=a?e.getVerticesData(wi.MatricesIndicesExtraKind):null,h=a?e.getVerticesData(wi.MatricesWeightsExtraKind):null,l=e.skeleton.getTransformMatrices(e),c=J.Matrix[0],u=J.Matrix[1];c.reset();const d=4*t;let _,f;for(_=0;_<4;_++)f=r[d+_],f>0&&(j.FromFloat32ArrayToRefScaled(l,Math.floor(16*s[d+_]),f,u),c.addToSelf(u));if(o&&h)for(_=0;_<4;_++)f=h[d+_],f>0&&(j.FromFloat32ArrayToRefScaled(l,Math.floor(16*o[d+_]),f,u),c.addToSelf(u));X.TransformCoordinatesFromFloatsToRef(n[0],n[1],n[2],c,i)}}return!0}e([a()],Ia.prototype,"url",void 0),e([u()],Ia.prototype,"boundingBoxPosition",void 0),e([u()],Ia.prototype,"boundingBoxSize",null),e([a("rotationY")],Ia.prototype,"rotationY",null),e([a("files")],Ia.prototype,"_files",void 0),e([a("forcedExtension")],Ia.prototype,"_forcedExtension",void 0),e([a("extensions")],Ia.prototype,"_extensions",void 0),e([f("textureMatrix")],Ia.prototype,"_textureMatrix",void 0),e([f("textureMatrixRefraction")],Ia.prototype,"_textureMatrixRefraction",void 0),bn._CubeTextureParser=Ia.Parse,S("BABYLON.CubeTexture",Ia),Qs._GroundMeshParser=(e,t)=>va.Parse(e,t);class va extends Qs{constructor(e,t){super(e,t),this.generateOctree=!1}getClassName(){return"GroundMesh"}get subdivisions(){return Math.min(this._subdivisionsX,this._subdivisionsY)}get subdivisionsX(){return this._subdivisionsX}get subdivisionsY(){return this._subdivisionsY}optimize(e,t=32){this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);const i=this;i.createOrUpdateSubmeshesOctree&&i.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){const i=this.getWorldMatrix(),s=J.Matrix[5];i.invertToRef(s);const r=J.Vector3[8];if(X.TransformCoordinatesFromFloatsToRef(e,0,t,s,r),e=r.x,t=r.z,e<this._minX||e>=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());const n=this._getFacetAt(e,t),a=-(n.x*e+n.z*t+n.w)/n.y;return X.TransformCoordinatesFromFloatsToRef(0,a,0,i,r),r.y}getNormalAtCoordinates(e,t){const i=new X(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){const s=this.getWorldMatrix(),r=J.Matrix[5];s.invertToRef(r);const n=J.Vector3[8];if(X.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());const a=this._getFacetAt(e,t);return X.TransformNormalFromFloatsToRef(a.x,a.y,a.z,s,i),this}updateCoordinateHeights(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){const i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),s=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[s*this._subdivisionsX+i];let n;return n=t<r.slope.x*e+r.slope.y?r.facet1:r.facet2,n}_initHeightQuads(){const e=this._subdivisionsX,t=this._subdivisionsY;this._heightQuads=new Array;for(let i=0;i<t;i++)for(let t=0;t<e;t++){const s={slope:Y.Zero(),facet1:new Q(0,0,0,0),facet2:new Q(0,0,0,0)};this._heightQuads[i*e+t]=s}return this}_computeHeightQuads(){const e=this.getVerticesData(wi.PositionKind);if(!e)return this;const t=J.Vector3[3],i=J.Vector3[2],s=J.Vector3[1],r=J.Vector3[0],n=J.Vector3[4],a=J.Vector3[5],o=J.Vector3[6],h=J.Vector3[7],l=J.Vector3[8];let c=0,u=0,d=0,_=0,f=0,p=0,g=0;const m=this._subdivisionsX,T=this._subdivisionsY;for(let A=0;A<T;A++)for(let T=0;T<m;T++){c=3*T,u=A*(m+1)*3,d=(A+1)*(m+1)*3,t.x=e[u+c],t.y=e[u+c+1],t.z=e[u+c+2],i.x=e[u+c+3],i.y=e[u+c+4],i.z=e[u+c+5],s.x=e[d+c],s.y=e[d+c+1],s.z=e[d+c+2],r.x=e[d+c+3],r.y=e[d+c+4],r.z=e[d+c+5],_=(r.z-t.z)/(r.x-t.x),f=t.z-_*t.x,i.subtractToRef(t,n),s.subtractToRef(t,a),r.subtractToRef(t,o),X.CrossToRef(o,a,h),X.CrossToRef(n,o,l),h.normalize(),l.normalize(),p=-(h.x*t.x+h.y*t.y+h.z*t.z),g=-(l.x*i.x+l.y*i.y+l.z*i.z);const E=this._heightQuads[A*m+T];E.slope.copyFromFloats(_,f),E.facet1.copyFromFloats(h.x,h.y,h.z,p),E.facet2.copyFromFloats(l.x,l.y,l.z,g)}return this}serialize(e){super.serialize(e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height}static Parse(e,t){const i=new va(e.name,t);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i}}function xa(e){const t=[],i=[],s=[],r=[];let n,a;const o=e.width||e.size||1,h=e.height||e.size||1,l=0|(e.subdivisionsX||e.subdivisions||1),c=0|(e.subdivisionsY||e.subdivisions||1);for(n=0;n<=c;n++)for(a=0;a<=l;a++){const e=new X(a*o/l-o/2,0,(c-n)*h/c-h/2),t=new X(0,1,0);i.push(e.x,e.y,e.z),s.push(t.x,t.y,t.z),r.push(a/l,1-n/c)}for(n=0;n<c;n++)for(a=0;a<l;a++)t.push(a+1+(n+1)*(l+1)),t.push(a+1+n*(l+1)),t.push(a+n*(l+1)),t.push(a+(n+1)*(l+1)),t.push(a+1+(n+1)*(l+1)),t.push(a+n*(l+1));const u=new qi;return u.indices=t,u.positions=i,u.normals=s,u.uvs=r,u}function Sa(e){const t=void 0!==e.xmin&&null!==e.xmin?e.xmin:-1,i=void 0!==e.zmin&&null!==e.zmin?e.zmin:-1,s=void 0!==e.xmax&&null!==e.xmax?e.xmax:1,r=void 0!==e.zmax&&null!==e.zmax?e.zmax:1,n=e.subdivisions||{w:1,h:1},a=e.precision||{w:1,h:1},o=[],h=[],l=[],c=[];let u,d,_,f;n.h=n.h<1?1:n.h,n.w=n.w<1?1:n.w,a.w=a.w<1?1:a.w,a.h=a.h<1?1:a.h;const p=(s-t)/n.w,g=(r-i)/n.h;function m(e,t,i,s){const r=h.length/3,n=a.w+1;for(u=0;u<a.h;u++)for(d=0;d<a.w;d++){const e=[r+d+u*n,r+(d+1)+u*n,r+(d+1)+(u+1)*n,r+d+(u+1)*n];o.push(e[1]),o.push(e[2]),o.push(e[3]),o.push(e[0]),o.push(e[1]),o.push(e[3])}const _=X.Zero(),f=new X(0,1,0);for(u=0;u<=a.h;u++)for(_.z=u*(s-t)/a.h+t,d=0;d<=a.w;d++)_.x=d*(i-e)/a.w+e,_.y=0,h.push(_.x,_.y,_.z),l.push(f.x,f.y,f.z),c.push(d/a.w,u/a.h)}for(_=0;_<n.h;_++)for(f=0;f<n.w;f++)m(t+f*p,i+_*g,t+(f+1)*p,i+(_+1)*g);const T=new qi;return T.indices=o,T.positions=h,T.normals=l,T.uvs=c,T}function Ca(e){const t=[],i=[],s=[],r=[];let n,a;const o=e.colorFilter||new he(.3,.59,.11),h=e.alphaFilter||0;let l=!1;if(e.minHeight>e.maxHeight){l=!0;const t=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=t}for(n=0;n<=e.subdivisions;n++)for(a=0;a<=e.subdivisions;a++){const t=new X(a*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-n)*e.height/e.subdivisions-e.height/2),c=4*(((t.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(t.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth);let u=e.buffer[c]/255,d=e.buffer[c+1]/255,_=e.buffer[c+2]/255;const f=e.buffer[c+3]/255;l&&(u=1-u,d=1-d,_=1-_);const p=u*o.r+d*o.g+_*o.b;t.y=f>=h?e.minHeight+(e.maxHeight-e.minHeight)*p:e.minHeight-R,e.heightBuffer&&(e.heightBuffer[n*(e.subdivisions+1)+a]=t.y),i.push(t.x,t.y,t.z),s.push(0,0,0),r.push(a/e.subdivisions,1-n/e.subdivisions)}for(n=0;n<e.subdivisions;n++)for(a=0;a<e.subdivisions;a++){const s=a+1+(n+1)*(e.subdivisions+1),r=a+1+n*(e.subdivisions+1),o=a+n*(e.subdivisions+1),h=a+(n+1)*(e.subdivisions+1),l=i[3*s+1]>=e.minHeight,c=i[3*r+1]>=e.minHeight,u=i[3*o+1]>=e.minHeight;l&&c&&u&&(t.push(s),t.push(r),t.push(o));i[3*h+1]>=e.minHeight&&l&&u&&(t.push(h),t.push(s),t.push(o))}qi.ComputeNormals(i,t,s);const c=new qi;return c.indices=t,c.positions=i,c.normals=s,c.uvs=r,c}function Pa(e){let t=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23];const i=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],s=[];let r=[];const n=e.width||e.size||1,a=e.height||e.size||1,o=e.depth||e.size||1,h=e.wrap||!1;let l=void 0===e.topBaseAt?1:e.topBaseAt,c=void 0===e.bottomBaseAt?0:e.bottomBaseAt;l=(l+4)%4,c=(c+4)%4;let u=[2,0,3,1][l],d=[2,0,1,3][c],_=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(h){t=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],_=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];let e=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],i=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const s=[17,18,19,16],r=[22,23,20,21];for(;u>0;)e.unshift(e.pop()),s.unshift(s.pop()),u--;for(;d>0;)i.unshift(i.pop()),r.unshift(r.pop()),d--;e=e.flat(),i=i.flat(),_=_.concat(e).concat(i),t.push(s[0],s[2],s[3],s[0],s[1],s[2]),t.push(r[0],r[2],r[3],r[0],r[1],r[2])}const f=[n/2,a/2,o/2];r=_.reduce(((e,t,i)=>e.concat(t*f[i%3])),[]);const p=0===e.sideOrientation?0:e.sideOrientation||qi.DEFAULTSIDE,g=e.faceUV||new Array(6),m=e.faceColors,T=[];for(let e=0;e<6;e++)void 0===g[e]&&(g[e]=new Q(0,0,1,1)),m&&void 0===m[e]&&(m[e]=new le(1,1,1,1));for(let e=0;e<6;e++)if(s.push(g[e].z,g[e].w),s.push(g[e].x,g[e].w),s.push(g[e].x,g[e].y),s.push(g[e].z,g[e].y),m)for(let t=0;t<4;t++)T.push(m[e].r,m[e].g,m[e].b,m[e].a);qi._ComputeSides(p,r,t,i,s,e.frontUVs,e.backUVs);const A=new qi;if(A.indices=t,A.positions=r,A.normals=i,A.uvs=s,m){const e=p===qi.DOUBLESIDE?T.concat(T):T;A.colors=e}return A}function Oa(e,t={},i=null){const s=new Qs(e,i);t.sideOrientation=Qs._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation;return Pa(t).applyToMesh(s,t.updatable),s}function Da(e){const t=e.minimum.x,i=e.minimum.y,s=e.minimum.z,r=e.maximum.x,n=e.maximum.y,a=e.maximum.z;return[new X(t,i,s),new X(r,n,a),new X(r,i,s),new X(t,n,s),new X(t,i,a),new X(r,n,s),new X(t,n,a),new X(r,i,a)]}qi.CreateGround=xa,qi.CreateTiledGround=Sa,qi.CreateGroundFromHeightMap=Ca,Qs.CreateGround=(e,t,i,s,r,n)=>function(e,t={},i){const s=new va(e,i);return s._setReady(!1),s._subdivisionsX=t.subdivisionsX||t.subdivisions||1,s._subdivisionsY=t.subdivisionsY||t.subdivisions||1,s._width=t.width||1,s._height=t.height||1,s._maxX=s._width/2,s._maxZ=s._height/2,s._minX=-s._maxX,s._minZ=-s._maxZ,xa(t).applyToMesh(s,t.updatable),s._setReady(!0),s}(e,{width:t,height:i,subdivisions:s,updatable:n},r),Qs.CreateTiledGround=(e,t,i,s,r,n,a,o,h)=>function(e,t,i=null){const s=new Qs(e,i);return Sa(t).applyToMesh(s,t.updatable),s}(e,{xmin:t,zmin:i,xmax:s,zmax:r,subdivisions:n,precision:a,updatable:h},o),Qs.CreateGroundFromHeightMap=(e,t,i,s,r,n,a,o,h,l,c)=>function(e,t,i={},s=null){const r=i.width||10,n=i.height||10,a=i.subdivisions||1,o=i.minHeight||0,h=i.maxHeight||1,l=i.colorFilter||new he(.3,.59,.11),c=i.alphaFilter||0,u=i.updatable,d=i.onReady;s=s||O.LastCreatedScene;const _=new va(e,s);let f;_._subdivisionsX=a,_._subdivisionsY=a,_._width=r,_._height=n,_._maxX=_._width/2,_._maxZ=_._height/2,_._minX=-_._maxX,_._minZ=-_._maxZ,_._setReady(!1),i.passHeightBufferInCallback&&(f=new Float32Array((a+1)*(a+1)));const p=(e,t,i)=>{Ca({width:r,height:n,subdivisions:a,minHeight:o,maxHeight:h,colorFilter:l,buffer:e,bufferWidth:t,bufferHeight:i,alphaFilter:c,heightBuffer:f}).applyToMesh(_,u),d&&d(_,f),_._setReady(!0)};if("string"==typeof t){const e=e=>{const t=e.width,i=e.height;if(s.isDisposed)return;const r=s?.getEngine().resizeImageBitmap(e,t,i);p(r,t,i)};pi.LoadImage(t,e,i.onError?i.onError:()=>{},s.offlineProvider)}else p(t.data,t.width,t.height);return _}(e,t,{width:i,height:s,subdivisions:r,minHeight:n,maxHeight:a,updatable:h,onReady:l,alphaFilter:c},o),qi.CreateBox=Pa,Qs.CreateBox=(e,t,i=null,s,r)=>Oa(e,{size:t,sideOrientation:r,updatable:s},i);class La{get resolve(){return this._resolve}get reject(){return this._reject}constructor(){this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}}class Fa{constructor(){this._currentOperation=Promise.resolve()}lockAsync(e,t){t?.throwIfAborted();const i=t?()=>(t.throwIfAborted(),e()):e,s=this._currentOperation.then(i);return this._currentOperation=new Promise((e=>s.then((()=>e()),e))),s}static async LockAsync(e,t,i){if(i?.throwIfAborted(),0===t.length)return await e();const s=new La;let r=0;return t.forEach((n=>n.lockAsync((async()=>(r++,r===t.length&&s.resolve(await e()),s.promise)),i).catch((e=>s.reject(e))))),s.promise}}function wa(...e){const t=e=>!!e&&"object"==typeof e;return e.reduce(((e,i)=>(Object.keys(i).forEach((s=>{const r=e[s],n=i[s];Array.isArray(r)&&Array.isArray(n)?e[s]=r.concat(...n):t(r)&&t(n)?e[s]=wa(r,n):e[s]=n})),e)),{})}class Na{constructor(e,t){this._disableRenderingRefCount=0,this._currentPerformancePriorityMode=0,this._scene=e,this._engine=e.getEngine(),this._engine.isWebGPU&&(this._options={morphTargetsNumMaxInfluences:20,...t},this._engine.snapshotRenderingMode=Ve.SNAPSHOTRENDERING_FAST,this.fixMeshes(),this._onResizeObserver=this._engine.onResizeObservable.add((()=>{this.disableSnapshotRendering(),this.enableSnapshotRendering()})),this._scene.onBeforeRenderObservable.add((()=>{if(this._fastSnapshotRenderingEnabled){e.skeletons.forEach((e=>e.prepare(!0)));for(const t of e.meshes)if(t.infiniteDistance&&t.transferToEffect(t.computeWorldMatrix(!0)),t.skeleton&&t.transferToEffect(t.computeWorldMatrix(!0)),"GaussianSplattingMesh"===t.getClassName()&&t._postToWorker(),t.morphTargetManager&&t.subMeshes)for(const e of t.subMeshes){const i=e._drawWrapper,s=i.effect;if(s){const e=i.drawContext.buffers.LeftOver,r=s._pipelineContext?.uniformBuffer;e&&r&&r.setDataBuffer(e)&&(t.morphTargetManager._bind(s),As(t,s),r.update())}}}})))}enableSnapshotRendering(){this._engine.isWebGPU&&(--this._disableRenderingRefCount>0||(this._disableRenderingRefCount=0,this._currentPerformancePriorityMode=this._pendingCurrentPerformancePriorityMode??this._scene.performancePriority,this._pendingCurrentPerformancePriorityMode=void 0,this._scene.performancePriority=0,this._scene.executeWhenReady((()=>{this._disableRenderingRefCount>0||this._executeAtFrame(this._engine.frameId+2,(()=>{this._engine.snapshotRendering=!0}))}))))}disableSnapshotRendering(){this._engine.isWebGPU&&(0===this._disableRenderingRefCount&&(this._scene.performancePriority=0,0!==this._currentPerformancePriorityMode&&(this._pendingCurrentPerformancePriorityMode=this._currentPerformancePriorityMode,this._scene.executeWhenReady((()=>{this._executeAtFrame(this._engine.frameId+2,(()=>{this._disableRenderingRefCount>0&&void 0!==this._pendingCurrentPerformancePriorityMode&&(this._scene.performancePriority=this._pendingCurrentPerformancePriorityMode),this._pendingCurrentPerformancePriorityMode=void 0}),!0)})))),this._engine.snapshotRendering=!1,this._disableRenderingRefCount++)}fixMeshes(e){if(this._engine.isWebGPU){e=e||this._scene.meshes;for(const t of e)t.ignoreCameraMaxZ=!1,t.morphTargetManager&&(t.morphTargetManager.numMaxInfluencers=Math.min(t.morphTargetManager.numTargets,this._options.morphTargetsNumMaxInfluences))}}updateMesh(e){if(this._fastSnapshotRenderingEnabled)if(Array.isArray(e))for(const t of e)t.transferToEffect(t.computeWorldMatrix(!0));else e.transferToEffect(e.computeWorldMatrix(!0))}updateMeshesForEffectLayer(e,t=!0){if(!this._engine.isWebGPU)return;const i=e.mainTexture.renderPassId;t?this._onBeforeRenderObserverUpdateLayer=this._scene.onBeforeRenderObservable.add((()=>{this._updateMeshMatricesForRenderPassId(i)})):this._updateMeshMatricesForRenderPassId(i)}dispose(){this._engine.isWebGPU&&(this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserverUpdateLayer),this._engine.onResizeObservable.remove(this._onResizeObserver))}get _fastSnapshotRenderingEnabled(){return this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===Ve.SNAPSHOTRENDERING_FAST}_updateMeshMatricesForRenderPassId(e){if(!this._fastSnapshotRenderingEnabled)return;const t=this._scene.getTransformMatrix();for(let i=0;i<this._scene.meshes.length;++i){const s=this._scene.meshes[i];if(s.subMeshes)for(let i=0;i<s.subMeshes.length;++i){const r=s.subMeshes[i]._getDrawWrapper(e),n=r?.effect;if(n){const e=r.drawContext.buffers.LeftOver,i=n._pipelineContext?.uniformBuffer;e&&i&&i.setDataBuffer(e)&&(n.setMatrix("viewProjection",t),n.setMatrix("world",s.computeWorldMatrix()),i.update())}}}}_executeAtFrame(e,t,i=!1){const s=this._engine.onEndFrameObservable.add((()=>{this._disableRenderingRefCount>0&&!i||0===this._disableRenderingRefCount&&i?this._engine.onEndFrameObservable.remove(s):this._engine.frameId>=e&&(this._engine.onEndFrameObservable.remove(s),t())}))}}const Ba="Z2xURg",Ua={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad:e=>-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+Ba)||e.startsWith("data:;base64,"+Ba)||e.startsWith("data:application/octet-stream;base64,"+Ba)||e.startsWith("data:model/gltf-binary;base64,"+Ba)},ka={name:"obj",extensions:".obj"},Va={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0},".spz":{isBinary:!0}}},za={name:"stl",extensions:{".stl":{isBinary:!0}}},Ga=new Map,Ha=Ga;function Wa(e,t,i){Ka(e)&&Ae.Warn(`Extension with the name '${e}' already exists`),Ga.set(e,{isGLTFExtension:t,factory:i})}function Ka(e){return Ga.delete(e)}function Ya(){pn({...Ua,createPlugin:async e=>{const{GLTFFileLoader:t}=await import("./glTFLoader-BNxQLfRc.esm.min.js").then((function(e){return e.g}));return new t(e[Ua.name])}}),Wa("EXT_lights_image_based",!0,(async e=>{const{EXT_lights_image_based:t}=await import("./EXT_lights_image_based-BjoWM5tf.esm.min.js");return new t(e)})),Wa("EXT_mesh_gpu_instancing",!0,(async e=>{const{EXT_mesh_gpu_instancing:t}=await import("./EXT_mesh_gpu_instancing-DbVyjoq7.esm.min.js");return new t(e)})),Wa("EXT_meshopt_compression",!0,(async e=>{const{EXT_meshopt_compression:t}=await import("./EXT_meshopt_compression-PLPAdJXy.esm.min.js");return new t(e)})),Wa("EXT_texture_avif",!0,(async e=>{const{EXT_texture_avif:t}=await import("./EXT_texture_avif-D2N-IXnv.esm.min.js");return new t(e)})),Wa("EXT_texture_webp",!0,(async e=>{const{EXT_texture_webp:t}=await import("./EXT_texture_webp-CWz2PiP_.esm.min.js");return new t(e)})),Wa("ExtrasAsMetadata",!1,(async e=>{const{ExtrasAsMetadata:t}=await import("./ExtrasAsMetadata-BpKCYcU-.esm.min.js");return new t(e)})),Wa("KHR_animation_pointer",!0,(async e=>{const{KHR_animation_pointer:t}=await import("./KHR_animation_pointer-WM3ggesH.esm.min.js");return new t(e)})),Wa("KHR_draco_mesh_compression",!0,(async e=>{const{KHR_draco_mesh_compression:t}=await import("./KHR_draco_mesh_compression-6AbT2wN8.esm.min.js");return new t(e)})),Wa("KHR_interactivity",!0,(async e=>{const{KHR_interactivity:t}=await import("./KHR_interactivity-B_CAm57j.esm.min.js");return new t(e)})),Wa("KHR_lights_punctual",!0,(async e=>{const{KHR_lights:t}=await import("./KHR_lights_punctual-DCOXnpRP.esm.min.js");return new t(e)})),Wa("EXT_lights_ies",!0,(async e=>{const{EXT_lights_ies:t}=await import("./EXT_lights_ies-Ddw_Gk8Q.esm.min.js");return new t(e)})),Wa("KHR_materials_anisotropy",!0,(async e=>{const{KHR_materials_anisotropy:t}=await import("./KHR_materials_anisotropy-I_WlXBtU.esm.min.js");return new t(e)})),Wa("KHR_materials_clearcoat",!0,(async e=>{const{KHR_materials_clearcoat:t}=await import("./KHR_materials_clearcoat-DrU2oJzb.esm.min.js");return new t(e)})),Wa("KHR_materials_diffuse_transmission",!0,(async e=>{const{KHR_materials_diffuse_transmission:t}=await import("./KHR_materials_diffuse_transmission-YyXsJa9T.esm.min.js");return new t(e)})),Wa("KHR_materials_dispersion",!0,(async e=>{const{KHR_materials_dispersion:t}=await import("./KHR_materials_dispersion-3Dk8ELun.esm.min.js");return new t(e)})),Wa("KHR_materials_emissive_strength",!0,(async e=>{const{KHR_materials_emissive_strength:t}=await import("./KHR_materials_emissive_strength-Bpd-wcN6.esm.min.js");return new t(e)})),Wa("KHR_materials_ior",!0,(async e=>{const{KHR_materials_ior:t}=await import("./KHR_materials_ior-BGPYY59r.esm.min.js");return new t(e)})),Wa("KHR_materials_iridescence",!0,(async e=>{const{KHR_materials_iridescence:t}=await import("./KHR_materials_iridescence-CvIyjrbg.esm.min.js");return new t(e)})),Wa("KHR_materials_pbrSpecularGlossiness",!0,(async e=>{const{KHR_materials_pbrSpecularGlossiness:t}=await import("./KHR_materials_pbrSpecularGlossiness-BFUvgZ3P.esm.min.js");return new t(e)})),Wa("KHR_materials_sheen",!0,(async e=>{const{KHR_materials_sheen:t}=await import("./KHR_materials_sheen-CegUHCDa.esm.min.js");return new t(e)})),Wa("KHR_materials_specular",!0,(async e=>{const{KHR_materials_specular:t}=await import("./KHR_materials_specular-CC5wN1RR.esm.min.js");return new t(e)})),Wa("KHR_materials_transmission",!0,(async e=>{const{KHR_materials_transmission:t}=await import("./KHR_materials_transmission-SU6SJMhP.esm.min.js");return new t(e)})),Wa("KHR_materials_unlit",!0,(async e=>{const{KHR_materials_unlit:t}=await import("./KHR_materials_unlit-DwCYujyL.esm.min.js");return new t(e)})),Wa("KHR_materials_variants",!0,(async e=>{const{KHR_materials_variants:t}=await import("./KHR_materials_variants-BXHHmDq_.esm.min.js");return new t(e)})),Wa("KHR_materials_volume",!0,(async e=>{const{KHR_materials_volume:t}=await import("./KHR_materials_volume-D8a4cCjx.esm.min.js");return new t(e)})),Wa("KHR_mesh_quantization",!0,(async e=>{const{KHR_mesh_quantization:t}=await import("./KHR_mesh_quantization-BJCC5tJC.esm.min.js");return new t(e)})),Wa("KHR_texture_basisu",!0,(async e=>{const{KHR_texture_basisu:t}=await import("./KHR_texture_basisu-C2OGAWY7.esm.min.js");return new t(e)})),Wa("KHR_texture_transform",!0,(async e=>{const{KHR_texture_transform:t}=await import("./KHR_texture_transform-D9MJQRee.esm.min.js");return new t(e)})),Wa("KHR_xmp_json_ld",!0,(async e=>{const{KHR_xmp_json_ld:t}=await import("./KHR_xmp_json_ld-BkiGlm_U.esm.min.js");return new t(e)})),Wa("MSFT_audio_emitter",!0,(async e=>{const{MSFT_audio_emitter:t}=await import("./MSFT_audio_emitter-B7aM8Qaz.esm.min.js");return new t(e)})),Wa("MSFT_lod",!0,(async e=>{const{MSFT_lod:t}=await import("./MSFT_lod-DIOF_rM4.esm.min.js");return new t(e)})),Wa("MSFT_minecraftMesh",!0,(async e=>{const{MSFT_minecraftMesh:t}=await import("./MSFT_minecraftMesh-EqwVrdf4.esm.min.js");return new t(e)})),Wa("MSFT_sRGBFactors",!0,(async e=>{const{MSFT_sRGBFactors:t}=await import("./MSFT_sRGBFactors-BJH-moQl.esm.min.js");return new t(e)})),Wa("KHR_node_visibility",!0,(async e=>{const{KHR_node_visibility:t}=await import("./KHR_node_visibility-CFk6SMES.esm.min.js");return new t(e)})),Wa("KHR_node_hoverability",!0,(async e=>{const{KHR_node_hoverability:t}=await import("./KHR_node_hoverability-C2Bud6ES.esm.min.js");return new t(e)})),pn({...ka,createPlugin:async()=>{const{OBJFileLoader:e}=await import("./objFileLoader-BzLe6gaH.esm.min.js");return new e}}),pn({...Va,createPlugin:async e=>{const{SPLATFileLoader:t}=await import("./splatFileLoader-CM4z7s6S.esm.min.js");return new t(e[Va.name])}}),pn({...za,createPlugin:async()=>{const{STLFileLoader:e}=await import("./stlFileLoader-BosbmaNZ.esm.min.js");return new e}})}const Xa=["none","standard","aces","neutral"];function Qa(...e){for(const t of e)t?.throwIfAborted()}function qa(e,t){e?.scaling.setAll((t.maxZ-t.minZ)/2)}const ja={lighting:!0,skybox:!0};class Za{constructor(){this.screenPosition=[NaN,NaN],this.worldPosition=[NaN,NaN,NaN],this.visibility=NaN}}class Ja{constructor(e,t){this._engine=e,this.onEnvironmentChanged=new A,this.onEnvironmentError=new A,this.onSkyboxBlurChanged=new A,this.onPostProcessingChanged=new A,this.onModelChanged=new A,this.onModelError=new A,this.onLoadingProgressChanged=new A,this.onCameraAutoOrbitChanged=new A,this.onSelectedAnimationChanged=new A,this.onAnimationSpeedChanged=new A,this.onIsAnimationPlayingChanged=new A,this.onAnimationProgressChanged=new A,this.onSelectedMaterialVariantChanged=new A,this._tempVectors=I(4,X.Zero),this._meshDataCache=new Map,this._renderLoopController=null,this._materialVariantsController=null,this._skybox=null,this._skyboxBlur=.3,this._light=null,this._suspendRenderCount=0,this._isDisposed=!1,this._loadModelLock=new Fa,this._loadModelAbortController=null,this._loadEnvironmentLock=new Fa,this._loadEnvironmentAbortController=null,this._loadSkyboxLock=new Fa,this._loadSkyboxAbortController=null,this._isLoadingModel=!1,this._modelLoadingProgress=null,this._selectedAnimation=-1,this._activeAnimationObservers=[],this._animationSpeed=1;{const e=new ln(this._engine);this._toneMappingEnabled=e.imageProcessingConfiguration.toneMappingEnabled,this._toneMappingType=e.imageProcessingConfiguration.toneMappingType,this._contrast=e.imageProcessingConfiguration.contrast,this._exposure=e.imageProcessingConfiguration.exposure,this._imageProcessingConfigurationObserver=e.imageProcessingConfiguration.onUpdateParameters.add((()=>{let t=!1;this._toneMappingEnabled!==e.imageProcessingConfiguration.toneMappingEnabled&&(this._toneMappingEnabled=e.imageProcessingConfiguration.toneMappingEnabled,t=!0),this._toneMappingType!==e.imageProcessingConfiguration.toneMappingType&&(this._toneMappingType=e.imageProcessingConfiguration.toneMappingType,t=!0),this._contrast!==e.imageProcessingConfiguration.contrast&&(this._contrast=e.imageProcessingConfiguration.contrast,t=!0),this._exposure!==e.imageProcessingConfiguration.exposure&&(this._exposure=e.imageProcessingConfiguration.exposure,t=!0),t&&this.onPostProcessingChanged.notifyObservers()}));const t=new xr("Viewer Default Camera",0,0,1,X.Zero(),e);t.useInputToRestoreState=!1,e.onPointerObservable.add((async e=>{const i=await this._pick(e.event.offsetX,e.event.offsetY);if(i?.pickedPoint){const e=i.pickedPoint.subtract(t.position).dot(t.getForwardRay().direction);t.target=t.position.add(t.getForwardRay().direction.scale(e)),t.radius=e,t.interpolateTo(void 0,void 0,void 0,i.pickedPoint)}else t.restoreState()}),qs.POINTERDOUBLETAP),this._details={viewer:this,scene:e,camera:t,model:null,suspendRendering:()=>this._suspendRendering(),pick:(e,t)=>this._pick(e,t)}}this._details.scene.skipFrustumClipping=!0,this._details.scene.skipPointerDownPicking=!0,this._details.scene.skipPointerUpPicking=!0,this._details.scene.skipPointerMovePicking=!0,this._snapshotHelper=new Na(this._details.scene,{morphTargetsNumMaxInfluences:30}),this._details.camera.attachControl(),this._updateCamera(),this._autoRotationBehavior=this._details.camera.getBehaviorByName("AutoRotation"),this.postProcessing={toneMapping:"neutral"},this.resetEnvironment().catch((()=>{})),this._beginRendering(),t?.onInitialized?.(this._details)}get cameraAutoOrbit(){return{enabled:this._details.camera.behaviors.includes(this._autoRotationBehavior),speed:this._autoRotationBehavior.idleRotationSpeed,delay:this._autoRotationBehavior.idleRotationWaitTime}}set cameraAutoOrbit(e){void 0!==e.enabled&&e.enabled!==this.cameraAutoOrbit.enabled&&(e.enabled?this._details.camera.addBehavior(this._autoRotationBehavior):this._details.camera.removeBehavior(this._autoRotationBehavior)),void 0!==e.delay&&(this._autoRotationBehavior.idleRotationWaitTime=e.delay),void 0!==e.speed&&(this._autoRotationBehavior.idleRotationSpeed=e.speed),this.onCameraAutoOrbitChanged.notifyObservers()}get skyboxBlur(){return this._skyboxBlur}set skyboxBlur(e){if(e!==this._skyboxBlur){if(this._skyboxBlur=e,this._skybox){const t=this._skybox.material;t instanceof ya&&(this._snapshotHelper.disableSnapshotRendering(),t.microSurface=1-e,this._snapshotHelper.enableSnapshotRendering())}this.onSkyboxBlurChanged.notifyObservers()}}get postProcessing(){let e;switch(this._toneMappingType){case Lr.TONEMAPPING_STANDARD:e="standard";break;case Lr.TONEMAPPING_ACES:e="aces";break;case Lr.TONEMAPPING_KHR_PBR_NEUTRAL:e="neutral";break;default:e="none"}return{toneMapping:e,contrast:this._contrast,exposure:this._exposure}}set postProcessing(e){if(this._snapshotHelper.disableSnapshotRendering(),void 0!==e.toneMapping)if("none"===e.toneMapping)this._details.scene.imageProcessingConfiguration.toneMappingEnabled=!1;else{switch(e.toneMapping){case"standard":this._details.scene.imageProcessingConfiguration.toneMappingType=Lr.TONEMAPPING_STANDARD;break;case"aces":this._details.scene.imageProcessingConfiguration.toneMappingType=Lr.TONEMAPPING_ACES;break;case"neutral":this._details.scene.imageProcessingConfiguration.toneMappingType=Lr.TONEMAPPING_KHR_PBR_NEUTRAL}this._details.scene.imageProcessingConfiguration.toneMappingEnabled=!0}void 0!==e.contrast&&(this._details.scene.imageProcessingConfiguration.contrast=e.contrast),void 0!==e.exposure&&(this._details.scene.imageProcessingConfiguration.exposure=e.exposure),this._details.scene.imageProcessingConfiguration.isEnabled=this._toneMappingEnabled||1!==this._contrast||1!==this._exposure,this._snapshotHelper.enableSnapshotRendering()}get loadingProgress(){return!!this._isLoadingModel&&(this._modelLoadingProgress??!0)}get animations(){return this._details.model?.animationGroups.map((e=>e.name))??[]}get selectedAnimation(){return this._selectedAnimation}set selectedAnimation(e){if((e=Math.round(N(e,-1,this.animations.length-1)))!==this._selectedAnimation){const t=this.isAnimationPlaying;this._activeAnimation&&(this._activeAnimationObservers.forEach((e=>e.remove())),this._activeAnimationObservers=[],this._activeAnimation.pause(),this._activeAnimation.goToFrame(0)),this._selectedAnimation=e,this._activeAnimation&&(this._activeAnimation.goToFrame(0),this._activeAnimation.play(!0),t||this.pauseAnimation(),this._activeAnimationObservers=[this._activeAnimation.onAnimationGroupPlayObservable.add((()=>{this.onIsAnimationPlayingChanged.notifyObservers()})),this._activeAnimation.onAnimationGroupPauseObservable.add((()=>{this.onIsAnimationPlayingChanged.notifyObservers()})),this._activeAnimation.onAnimationGroupEndObservable.add((()=>{this.onIsAnimationPlayingChanged.notifyObservers(),this.onAnimationProgressChanged.notifyObservers()}))],this._updateCamera(!this._isLoadingModel)),this.onSelectedAnimationChanged.notifyObservers(),this.onAnimationProgressChanged.notifyObservers()}}get isAnimationPlaying(){return this._activeAnimation?.isPlaying??!1}get animationSpeed(){return this._animationSpeed}set animationSpeed(e){this._animationSpeed=e,this._applyAnimationSpeed(),this.onAnimationSpeedChanged.notifyObservers()}get animationProgress(){return this._activeAnimation?this._activeAnimation.getCurrentFrame()/(this._activeAnimation.to-this._activeAnimation.from):0}set animationProgress(e){this._activeAnimation&&(this._activeAnimation.goToFrame(e*(this._activeAnimation.to-this._activeAnimation.from)),this.onAnimationProgressChanged.notifyObservers(),this._autoRotationBehavior.resetLastInteractionTime())}get _activeAnimation(){return this._details.model?.animationGroups[this._selectedAnimation]??null}get materialVariants(){return this._materialVariantsController?.variants??[]}get selectedMaterialVariant(){return this._materialVariantsController?.selectedVariant??null}set selectedMaterialVariant(e){e!==this.selectedMaterialVariant&&this._materialVariantsController?.variants.includes(e)&&(this._snapshotHelper.disableSnapshotRendering(),this._materialVariantsController.selectedVariant=e,this._snapshotHelper.enableSnapshotRendering(),this.onSelectedMaterialVariantChanged.notifyObservers())}async loadModel(e,t,i){await this._updateModel(e,t,i)}async resetModel(e){await this._updateModel(void 0,void 0,e)}async _updateModel(e,t,i){this._throwIfDisposedOrAborted(i);const s=t?.onProgress;delete t?.onProgress;const r=t?.pluginOptions?.gltf?.extensionOptions?.KHR_materials_variants?.onLoaded;delete t?.pluginOptions?.gltf?.extensionOptions?.KHR_materials_variants?.onLoaded;t=wa({onProgress:e=>{s?.(e),this._isLoadingModel&&(this._modelLoadingProgress=e.lengthComputable?e.loaded/e.total:null,this.onLoadingProgressChanged.notifyObservers())},pluginOptions:{gltf:{transparencyAsCoverage:!0,extensionOptions:{KHR_materials_variants:{onLoaded:e=>{r?.(e),this._materialVariantsController=e}}}}}},t??{}),this._loadModelAbortController?.abort("New model is being loaded before previous model finished loading.");const n=this._loadModelAbortController=new AbortController;await this._loadModelLock.lockAsync((async()=>{Qa(i,n.signal),this._snapshotHelper.disableSnapshotRendering(),this._details.model?.dispose(),this._details.model=null,this._meshDataCache.clear(),this._materialVariantsController=null,this.onSelectedMaterialVariantChanged.notifyObservers(),this.selectedAnimation=-1;try{e&&(this._isLoadingModel=!0,this._modelLoadingProgress=0,this.onLoadingProgressChanged.notifyObservers(),this._details.model=await mn(e,this._details.scene,t),this.onSelectedMaterialVariantChanged.notifyObservers(),this._details.model.animationGroups.forEach((e=>{e.start(!0,this.animationSpeed),e.pause()})),this.selectedAnimation=t?.defaultAnimation??0,this._snapshotHelper.fixMeshes(this._details.model.meshes),this._details.model.addAllToScene()),this._updateCamera(),this._updateLight(),this._applyAnimationSpeed(),this.onModelChanged.notifyObservers()}catch(e){throw this.onModelError.notifyObservers(e),e}finally{this._isLoadingModel=!1,this.onLoadingProgressChanged.notifyObservers(),this._snapshotHelper.enableSnapshotRendering()}}))}async loadEnvironment(e,t,i){await this._updateEnvironment(e,t,i)}async resetEnvironment(e,t){await this._updateEnvironment(void 0,e,t)}async _updateEnvironment(e,t,i){if(this._throwIfDisposedOrAborted(i),!(t=t??ja).lighting&&!t.skybox)return;const s=[];t.lighting&&(this._loadEnvironmentAbortController?.abort("New environment lighting is being loaded before previous environment lighting finished loading."),s.push(this._loadEnvironmentLock)),t.skybox&&(this._loadSkyboxAbortController?.abort("New environment skybox is being loaded before previous environment skybox finished loading."),s.push(this._loadSkyboxLock));const r=this._loadEnvironmentAbortController=t.lighting?new AbortController:null,n=this._loadSkyboxAbortController=t.skybox?new AbortController:null;await Fa.LockAsync((async()=>{Qa(i,r?.signal,n?.signal),this._snapshotHelper.disableSnapshotRendering();const s=()=>{t.lighting&&(this._details.scene.environmentTexture?.dispose(),this._details.scene.environmentTexture=null),t.skybox&&(this._skybox?.dispose(void 0,!0),this._skybox=null,this._details.scene.autoClear=!0)};s();try{if(e){const i=Ia.CreateFromPrefilteredData(e,this._details.scene);if(t.lighting&&(this._details.scene.environmentTexture=i),t.skybox){const e=t.lighting?i.clone():i;this._skybox=function(e,t,i,s){const r=Oa("hdrSkyBox",void 0,e),n=new ya("skyBox",e);return n.imageProcessingConfiguration=new Lr,n.backFaceCulling=!1,n.reflectionTexture=i,n.reflectionTexture&&(n.reflectionTexture.coordinatesMode=bn.SKYBOX_MODE),n.microSurface=1-s,n.disableLighting=!0,n.twoSidedLighting=!0,r.material=n,r.isPickable=!1,r.infiniteDistance=!0,qa(r,t),r}(this._details.scene,this._details.camera,e,this.skyboxBlur),this._snapshotHelper.fixMeshes([this._skybox]),this._details.scene.autoClear=!1}await new Promise(((e,t)=>{const s=i.onLoadObservable.addOnce((()=>{s.remove(),r.remove(),e()})),r=bn.OnTextureLoadErrorObservable.add((e=>{e===i&&(s.remove(),r.remove(),t(new Error("Failed to load environment texture.")))}))}))}this._updateLight(),this.onEnvironmentChanged.notifyObservers()}catch(e){throw s(),this.onEnvironmentError.notifyObservers(e),e}finally{this._snapshotHelper.enableSnapshotRendering()}}),s)}toggleAnimation(){this.isAnimationPlaying?this.pauseAnimation():this.playAnimation()}playAnimation(){this._activeAnimation?.play(!0)}async pauseAnimation(){this._activeAnimation?.pause()}resetCamera(){this._details.camera.restoreState()}dispose(){this.selectedAnimation=-1,this.animationProgress=0,this._loadEnvironmentAbortController?.abort("Thew viewer is being disposed."),this._loadModelAbortController?.abort("Thew viewer is being disposed."),this._renderLoopController?.dispose(),this._details.scene.dispose(),this.onEnvironmentChanged.clear(),this.onEnvironmentError.clear(),this.onSkyboxBlurChanged.clear(),this.onPostProcessingChanged.clear(),this.onModelChanged.clear(),this.onModelError.clear(),this.onCameraAutoOrbitChanged.clear(),this.onSelectedAnimationChanged.clear(),this.onAnimationSpeedChanged.clear(),this.onIsAnimationPlayingChanged.clear(),this.onAnimationProgressChanged.clear(),this.onLoadingProgressChanged.clear(),this._imageProcessingConfigurationObserver.remove(),this._isDisposed=!0}getHotSpotToRef(e,t){if(!this._details.model)return!1;const i=this._tempVectors[2],s=this._tempVectors[1],r=this._tempVectors[0];if("surface"===e.type){const t=this._details.model.meshes[e.meshIndex];if(!t)return!1;if(!function(e,t,i,s){i.set(0,0,0);for(let s=0;s<3;s++){if(!Ma(e,t.pointIndex[s],J.Vector3[s]))return!1;J.Vector3[s].scaleAndAddToRef(t.barycentric[s],i)}if(X.TransformCoordinatesToRef(i,e.getWorldMatrix(),i),s){const t=J.Vector3[0],i=J.Vector3[1],r=J.Vector3[2],n=J.Vector3[3],a=J.Vector3[4];n.copyFrom(i),n.subtractInPlace(t),a.copyFrom(r),a.subtractInPlace(t),n.normalize(),a.normalize(),X.CrossToRef(n,a,s),e.material&&e.material.sideOrientation===(e.getScene().useRightHandedSystem?Ve.MATERIAL_ClockWiseSideOrientation:Ve.MATERIAL_CounterClockWiseSideOrientation)&&s.scaleInPlace(-1),X.TransformNormalToRef(s,e.getWorldMatrix(),s),s.normalize()}return!0}(t,e,s,i))return!1}else s.copyFromFloats(e.position[0],e.position[1],e.position[2]),i.copyFromFloats(e.normal[0],e.normal[1],e.normal[2]);const n=this._engine.getRenderWidth(),a=this._engine.getRenderHeight(),o=this._details.camera.viewport.width*n,h=this._details.camera.viewport.height*a,l=this._details.scene;X.ProjectToRef(s,j.IdentityReadOnly,l.getTransformMatrix(),new Ii(0,0,o,h),r),t.screenPosition[0]=r.x,t.screenPosition[1]=r.y,t.worldPosition[0]=s.x,t.worldPosition[1]=s.y,t.worldPosition[2]=s.z;const c=this._tempVectors[3];return c.copyFrom(this._details.camera.globalPosition),c.subtractInPlace(s),c.normalize(),t.visibility=X.Dot(c,i),!0}_suspendRendering(){this._renderLoopController?.dispose(),this._suspendRenderCount++;let e=!1;return{dispose:()=>{e||(e=!0,this._suspendRenderCount--,0===this._suspendRenderCount&&this._beginRendering())}}}_beginRendering(){if(!this._renderLoopController){const e=()=>{this._details.scene.render(),this._details.camera.panningSensibility=5e3/this._details.camera.radius,this._details.camera.speed=.2*this._details.camera.radius,this.isAnimationPlaying&&(this.onAnimationProgressChanged.notifyObservers(),this._autoRotationBehavior.resetLastInteractionTime())};this._engine.runRenderLoop(e);let t=!1;this._renderLoopController={dispose:()=>{t||(t=!0,this._engine.stopRenderLoop(e),this._renderLoopController=null)}}}}_updateCamera(e=!1){this._details.camera.useFramingBehavior=!0;const t=this._details.camera.getBehaviorByName("Framing");t.framingTime=0,t.elevationReturnTime=-1,this._details.camera.useAutoRotationBehavior=!0;const i=this._details.camera.alpha,s=this._details.camera.beta,r=this._details.camera.radius,n=this._details.camera.target,a=Math.PI/2,o=Math.PI/2.4;let h=1,l=n;if(this._details.model?.meshes.length){this._details.camera.lowerRadiusLimit=null;const e=function(e,t=null,i=1/6){const s=J.Vector3[0],r=new Map,n=new Map,a=e.reduce(((e,t)=>Math.max(e,t.getTotalVertices())),0),o=Array.from({length:a},(()=>new X)),h=Array.from({length:a},(()=>new X));for(const t of e){const e=t.getVerticesData(wi.PositionKind);if(!e)continue;const i=t.getTotalVertices();o.length=Math.max(o.length,i),h.length=Math.max(o.length,i);for(let t=0,r=0;t<i;t++,r+=3)s.set(e[r],e[r+1],e[r+2]),o[t].copyFrom(s),h[t].copyFrom(s);const a=t.morphTargetManager;if(a)for(let e=0;e<a.numTargets;++e){const t=a.getTarget(e).getPositions();if(t)for(let e=0,r=0;e<i;e++,r+=3)s.set(t[r],t[r+1],t[r+2]),o[e].minimizeInPlace(s),h[e].maximizeInPlace(s)}const l=t.skeleton,c=l?t.getVerticesData(wi.MatricesWeightsKind):null,u=l?t.getVerticesData(wi.MatricesIndicesKind):null;if(c&&u){const e=t.numBoneInfluencers>4,s=e?t.getVerticesData(wi.MatricesWeightsExtraKind):null,r=e?t.getVerticesData(wi.MatricesIndicesExtraKind):null,a=n.get(t.uniqueId)||new Map;n.set(t.uniqueId,a);const l=(e,t,i,s)=>{for(let r=t;r<t+4;r++)if(i[r]>0){const t=s[r],i=a.get(t);i?(i.minimum.minimizeInPlace(o[e]),i.maximum.maximizeInPlace(h[e])):a.set(t,{minimum:o[e].clone(),maximum:h[e].clone()})}};for(let e=0,t=0;e<i;e++,t+=4)l(e,t,c,u),s&&r&&l(e,t,s,r)}else{const e=r.get(t.uniqueId)||{minimum:(new X).setAll(Number.POSITIVE_INFINITY),maximum:(new X).setAll(Number.NEGATIVE_INFINITY)};r.set(t.uniqueId,e);for(let t=0;t<i;t++)e.minimum.minimizeInPlace(o[t]),e.maximum.maximizeInPlace(h[t])}}const l=new Map,c=new Map;for(const t of e){const e=r.get(t.uniqueId);if(e)l.set(t.uniqueId,Da(e));else{const e=n.get(t.uniqueId);if(e){const i=t.skeleton.bones,s=new Map;c.set(t.uniqueId,s),e.forEach(((e,t)=>{const r=Da(e),n=i[t].getAbsoluteInverseBindMatrix();for(const e of r)X.TransformCoordinatesToRef(e,n,e);s.set(t,r)}))}}}const u=Array.from({length:e.length},(()=>({minimum:(new X).setAll(Number.POSITIVE_INFINITY),maximum:(new X).setAll(Number.NEGATIVE_INFINITY)}))),d=()=>{for(let t=0;t<e.length;t++){const i=e[t];if(!i.getVerticesData(wi.PositionKind))continue;const r=i.computeWorldMatrix(!0),n=i.skeleton;if(n){n.prepare(!0);const e=n.bones;c.get(i.uniqueId).forEach(((i,n)=>{for(const a of i){const i=e[n].getFinalMatrix().multiplyToRef(r,J.Matrix[0]);X.TransformCoordinatesToRef(a,i,s),u[t].minimum.minimizeInPlace(s),u[t].maximum.maximizeInPlace(s)}}))}else for(const e of l.get(i.uniqueId))X.TransformCoordinatesToRef(e,r,s),u[t].minimum.minimizeInPlace(s),u[t].maximum.maximizeInPlace(s)}};if(t&&t.isStarted){const e=t.getCurrentFrame(),s=i/t.getLength(0,1);for(let e=t.from;e<=t.to;e+=s)t.goToFrame(e),d();t.goToFrame(e)}else d();return u}(this._details.model.meshes,this._activeAnimation),i={min:new X(Math.min(...e.map((e=>e.minimum.x))),Math.min(...e.map((e=>e.minimum.y))),Math.min(...e.map((e=>e.minimum.z)))),max:new X(Math.max(...e.map((e=>e.maximum.x))),Math.max(...e.map((e=>e.maximum.y))),Math.max(...e.map((e=>e.maximum.z))))};t.zoomOnBoundingInfo(i.min,i.max);const s=i.max.subtract(i.min),r=i.min.add(s.scale(.5));h=1.1*s.length(),isFinite(h)||(h=1,r.copyFromFloats(0,0,0)),l=r}this._details.camera.alpha=Math.PI/2,this._details.camera.beta=Math.PI/2.4,this._details.camera.radius=h,this._details.camera.target=l,this._details.camera.lowerRadiusLimit=.001*h,this._details.camera.upperRadiusLimit=5*h,this._details.camera.minZ=.001*h,this._details.camera.maxZ=1e3*h,this._details.camera.wheelDeltaPercentage=.01,this._details.camera.useNaturalPinchZoom=!0,this._details.camera.restoreStateInterpolationFactor=.1,this._details.camera.storeState(),e&&(this._details.camera.alpha=i,this._details.camera.beta=s,this._details.camera.radius=r,this._details.camera.target=n,this._details.camera.interpolateTo(a,o,h,l)),qa(this._skybox,this._details.camera)}_updateLight(){let e;if(this._details.model){const t=this._details.model.lights.length>0,i=!!this._details.scene.environmentTexture,s=this._details.model.materials.length>0,r=this._details.model.materials.some((e=>!(e instanceof ya)));e=!t&&(!i||!s||r)}else e=!1;e?this._light||(this._light=new Cr("defaultLight",X.Up(),this._details.scene)):(this._light?.dispose(),this._light=null)}_applyAnimationSpeed(){this._details.model?.animationGroups.forEach((e=>e.speedRatio=this._animationSpeed))}async _pick(e,t){if(await import("./ray-VbeIB6un.esm.min.js"),this._details.model){const i=this._details.model;i.meshes.forEach((e=>{let t=this._meshDataCache.get(e);t||(t={},this._meshDataCache.set(e,t)),e.refreshBoundingInfo({applyMorph:!0,applySkeleton:!0,cache:t})}));const s=this._details.scene.pick(e,t,(e=>i.meshes.includes(e)));if(s.hit)return s}return null}_throwIfDisposedOrAborted(...e){if(this._isDisposed)throw new Error("Viewer is disposed.");Qa(...e)}}Ya();
2
- /**
3
- * @license
4
- * Copyright 2019 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- const $a=globalThis,eo=$a.ShadowRoot&&(void 0===$a.ShadyCSS||$a.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,to=Symbol(),io=new WeakMap;let so=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==to)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(eo&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=io.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&io.set(t,e))}return e}toString(){return this.cssText}};const ro=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new so(i,e,to)},no=eo?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new so("string"==typeof e?e:e+"",void 0,to))(t)})(e):e
8
- /**
9
- * @license
10
- * Copyright 2017 Google LLC
11
- * SPDX-License-Identifier: BSD-3-Clause
12
- */,{is:ao,defineProperty:oo,getOwnPropertyDescriptor:ho,getOwnPropertyNames:lo,getOwnPropertySymbols:co,getPrototypeOf:uo}=Object,_o=globalThis,fo=_o.trustedTypes,po=fo?fo.emptyScript:"",go=_o.reactiveElementPolyfillSupport,mo=(e,t)=>e,To={toAttribute(e,t){switch(t){case Boolean:e=e?po:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},Ao=(e,t)=>!ao(e,t),Eo={attribute:!0,type:String,converter:To,reflect:!1,hasChanged:Ao};Symbol.metadata??=Symbol("metadata"),_o.litPropertyMetadata??=new WeakMap;class bo extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Eo){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);void 0!==s&&oo(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:r}=ho(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get(){return s?.call(this)},set(t){const n=s?.call(this);r.call(this,t),this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Eo}static _$Ei(){if(this.hasOwnProperty(mo("elementProperties")))return;const e=uo(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(mo("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(mo("properties"))){const e=this.properties,t=[...lo(e),...co(e)];for(const i of t)this.createProperty(i,e[i])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,i]of t)this.elementProperties.set(e,i)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const i=this._$Eu(e,t);void 0!==i&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(no(e))}else void 0!==e&&t.push(no(e));return t}static _$Eu(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(eo)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),s=$a.litNonce;void 0!==s&&t.setAttribute("nonce",s),t.textContent=i.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EC(e,t){const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(void 0!==s&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:To).toAttribute(t,i.type);this._$Em=e,null==r?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(e,t){const i=this.constructor,s=i._$Eh.get(e);if(void 0!==s&&this._$Em!==s){const e=i.getPropertyOptions(s),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:To;this._$Em=s,this[s]=r.fromAttribute(t,e.type),this._$Em=null}}requestUpdate(e,t,i){if(void 0!==e){if(i??=this.constructor.getPropertyOptions(e),!(i.hasChanged??Ao)(this[e],t))return;this.P(e,t,i)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$Em!==e&&(this._$Ej??=new Set).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,i]of e)!0!==i.wrapped||this._$AL.has(t)||void 0===this[t]||this.P(t,this[t],i)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach((e=>e.hostUpdate?.())),this.update(t)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&=this._$Ej.forEach((e=>this._$EC(e,this[e]))),this._$EU()}updated(e){}firstUpdated(e){}}bo.elementStyles=[],bo.shadowRootOptions={mode:"open"},bo[mo("elementProperties")]=new Map,bo[mo("finalized")]=new Map,go?.({ReactiveElement:bo}),(_o.reactiveElementVersions??=[]).push("2.0.4");
13
- /**
14
- * @license
15
- * Copyright 2017 Google LLC
16
- * SPDX-License-Identifier: BSD-3-Clause
17
- */
18
- const Ro=globalThis,yo=Ro.trustedTypes,Io=yo?yo.createPolicy("lit-html",{createHTML:e=>e}):void 0,Mo="$lit$",vo=`lit$${Math.random().toFixed(9).slice(2)}$`,xo="?"+vo,So=`<${xo}>`,Co=document,Po=()=>Co.createComment(""),Oo=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Do=Array.isArray,Lo="[ \t\n\f\r]",Fo=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,wo=/-->/g,No=/>/g,Bo=RegExp(`>|${Lo}(?:([^\\s"'>=/]+)(${Lo}*=${Lo}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Uo=/'/g,ko=/"/g,Vo=/^(?:script|style|textarea|title)$/i,zo=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),Go=Symbol.for("lit-noChange"),Ho=Symbol.for("lit-nothing"),Wo=new WeakMap,Ko=Co.createTreeWalker(Co,129);function Yo(e,t){if(!Do(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Io?Io.createHTML(t):t}const Xo=(e,t)=>{const i=e.length-1,s=[];let r,n=2===t?"<svg>":3===t?"<math>":"",a=Fo;for(let t=0;t<i;t++){const i=e[t];let o,h,l=-1,c=0;for(;c<i.length&&(a.lastIndex=c,h=a.exec(i),null!==h);)c=a.lastIndex,a===Fo?"!--"===h[1]?a=wo:void 0!==h[1]?a=No:void 0!==h[2]?(Vo.test(h[2])&&(r=RegExp("</"+h[2],"g")),a=Bo):void 0!==h[3]&&(a=Bo):a===Bo?">"===h[0]?(a=r??Fo,l=-1):void 0===h[1]?l=-2:(l=a.lastIndex-h[2].length,o=h[1],a=void 0===h[3]?Bo:'"'===h[3]?ko:Uo):a===ko||a===Uo?a=Bo:a===wo||a===No?a=Fo:(a=Bo,r=void 0);const u=a===Bo&&e[t+1].startsWith("/>")?" ":"";n+=a===Fo?i+So:l>=0?(s.push(o),i.slice(0,l)+Mo+i.slice(l)+vo+u):i+vo+(-2===l?t:u)}return[Yo(e,n+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class Qo{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,n=0;const a=e.length-1,o=this.parts,[h,l]=Xo(e,t);if(this.el=Qo.createElement(h,i),Ko.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=Ko.nextNode())&&o.length<a;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(Mo)){const t=l[n++],i=s.getAttribute(e).split(vo),a=/([.?@])?(.*)/.exec(t);o.push({type:1,index:r,name:a[2],strings:i,ctor:"."===a[1]?$o:"?"===a[1]?eh:"@"===a[1]?th:Jo}),s.removeAttribute(e)}else e.startsWith(vo)&&(o.push({type:6,index:r}),s.removeAttribute(e));if(Vo.test(s.tagName)){const e=s.textContent.split(vo),t=e.length-1;if(t>0){s.textContent=yo?yo.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],Po()),Ko.nextNode(),o.push({type:2,index:++r});s.append(e[t],Po())}}}else if(8===s.nodeType)if(s.data===xo)o.push({type:2,index:r});else{let e=-1;for(;-1!==(e=s.data.indexOf(vo,e+1));)o.push({type:7,index:r}),e+=vo.length-1}r++}}static createElement(e,t){const i=Co.createElement("template");return i.innerHTML=e,i}}function qo(e,t,i=e,s){if(t===Go)return t;let r=void 0!==s?i._$Co?.[s]:i._$Cl;const n=Oo(t)?void 0:t._$litDirective$;return r?.constructor!==n&&(r?._$AO?.(!1),void 0===n?r=void 0:(r=new n(e),r._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=r:i._$Cl=r),void 0!==r&&(t=qo(e,r._$AS(e,t.values),r,s)),t}class jo{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??Co).importNode(t,!0);Ko.currentNode=s;let r=Ko.nextNode(),n=0,a=0,o=i[0];for(;void 0!==o;){if(n===o.index){let t;2===o.type?t=new Zo(r,r.nextSibling,this,e):1===o.type?t=new o.ctor(r,o.name,o.strings,this,e):6===o.type&&(t=new ih(r,this,e)),this._$AV.push(t),o=i[++a]}n!==o?.index&&(r=Ko.nextNode(),n++)}return Ko.currentNode=Co,s}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class Zo{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Ho,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=qo(this,e,t),Oo(e)?e===Ho||null==e||""===e?(this._$AH!==Ho&&this._$AR(),this._$AH=Ho):e!==this._$AH&&e!==Go&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>Do(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Ho&&Oo(this._$AH)?this._$AA.nextSibling.data=e:this.T(Co.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=Qo.createElement(Yo(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new jo(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=Wo.get(e.strings);return void 0===t&&Wo.set(e.strings,t=new Qo(e)),t}k(e){Do(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const r of e)s===t.length?t.push(i=new Zo(this.O(Po()),this.O(Po()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class Jo{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Ho,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Ho}_$AI(e,t=this,i,s){const r=this.strings;let n=!1;if(void 0===r)e=qo(this,e,t,0),n=!Oo(e)||e!==this._$AH&&e!==Go,n&&(this._$AH=e);else{const s=e;let a,o;for(e=r[0],a=0;a<r.length-1;a++)o=qo(this,s[i+a],t,a),o===Go&&(o=this._$AH[a]),n||=!Oo(o)||o!==this._$AH[a],o===Ho?e=Ho:e!==Ho&&(e+=(o??"")+r[a+1]),this._$AH[a]=o}n&&!s&&this.j(e)}j(e){e===Ho?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class $o extends Jo{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ho?void 0:e}}class eh extends Jo{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ho)}}class th extends Jo{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=qo(this,e,t,0)??Ho)===Go)return;const i=this._$AH,s=e===Ho&&i!==Ho||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Ho&&(i===Ho||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class ih{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){qo(this,e)}}const sh=Ro.litHtmlPolyfillSupport;sh?.(Qo,Zo),(Ro.litHtmlVersions??=[]).push("3.2.1");
19
- /**
20
- * @license
21
- * Copyright 2017 Google LLC
22
- * SPDX-License-Identifier: BSD-3-Clause
23
- */
24
- let rh=class extends bo{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{const s=i?.renderBefore??t;let r=s._$litPart$;if(void 0===r){const e=i?.renderBefore??null;s._$litPart$=r=new Zo(t.insertBefore(Po(),e),e,void 0,i??{})}return r._$AI(e),r})(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Go}};rh._$litElement$=!0,rh.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:rh});const nh=globalThis.litElementPolyfillSupport;nh?.({LitElement:rh}),(globalThis.litElementVersions??=[]).push("4.1.1");
25
- /**
26
- * @license
27
- * Copyright 2017 Google LLC
28
- * SPDX-License-Identifier: BSD-3-Clause
29
- */
30
- const ah=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)})):customElements.define(e,t)}
31
- /**
32
- * @license
33
- * Copyright 2017 Google LLC
34
- * SPDX-License-Identifier: BSD-3-Clause
35
- */,oh={attribute:!0,type:String,converter:To,reflect:!1,hasChanged:Ao},hh=(e=oh,t,i)=>{const{kind:s,metadata:r}=i;let n=globalThis.litPropertyMetadata.get(r);if(void 0===n&&globalThis.litPropertyMetadata.set(r,n=new Map),n.set(i.name,e),"accessor"===s){const{name:s}=i;return{set(i){const r=t.get.call(this);t.set.call(this,i),this.requestUpdate(s,r,e)},init(t){return void 0!==t&&this.P(s,void 0,e),t}}}if("setter"===s){const{name:s}=i;return function(i){const r=this[s];t.call(this,i),this.requestUpdate(s,r,e)}}throw Error("Unsupported decorator location: "+s)};function lh(e){return(t,i)=>"object"==typeof i?hh(e,t,i):((e,t,i)=>{const s=t.hasOwnProperty(i);return t.constructor.createProperty(i,s?{...e,wrapped:!0}:e),s?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)
36
- /**
37
- * @license
38
- * Copyright 2017 Google LLC
39
- * SPDX-License-Identifier: BSD-3-Clause
40
- */}function ch(e){return lh({...e,state:!0,attribute:!1})}
41
- /**
42
- * @license
43
- * Copyright 2017 Google LLC
44
- * SPDX-License-Identifier: BSD-3-Clause
45
- */
46
- /**
47
- * @license
48
- * Copyright 2017 Google LLC
49
- * SPDX-License-Identifier: BSD-3-Clause
50
- */
51
- function uh(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,i),i))(t,i,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}const dh={};async function _h(e,t){const i={...dh,...t},s=[];let r=!1;const n=new ResizeObserver((()=>r=!0));let a;switch(n.observe(e),s.push((()=>n.disconnect())),i.engine??"WebGL"){case"WebGL":{const{Engine:i}=await import("./engine-CBJrzwFS.esm.min.js");a=new i(e,void 0,t);break}case"WebGPU":{const{WebGPUEngine:i}=await import("./webgpuEngine-BW5Z2CFp.esm.min.js"),s=new i(e,t);await s.initAsync(),a=s;break}}const o=i.onInitialized;i.onInitialized=t=>{const i=t.scene.onBeforeRenderObservable.add((()=>{r&&(a.resize(),r=!1)}));s.push((()=>i.remove()));let n=null;const h=new IntersectionObserver((e=>{e.length>0&&(e[e.length-1].isIntersecting?(n?.dispose(),n=null):n=t.suspendRendering())}));h.observe(e),s.push((()=>h.disconnect())),o?.(t)};const h=new Ja(a,i);return s.push(h.dispose.bind(h)),s.push((()=>a.dispose())),h.dispose=()=>s.forEach((e=>e())),h}var fh;const ph=[.5,1,1.5,2];let gh=fh=class extends rh{constructor(){super(...arguments),this._viewerLock=new Fa,this._propertyBindings=[this._createPropertyBinding("clearColor",(e=>e.scene.onClearColorChangedObservable),(e=>e.scene.clearColor=this.clearColor??new le(0,0,0,0)),(e=>this.clearColor=e.scene.clearColor)),this._createPropertyBinding("skyboxBlur",(e=>e.viewer.onSkyboxBlurChanged),(e=>e.viewer.skyboxBlur=this.skyboxBlur??e.viewer.skyboxBlur),(e=>this.skyboxBlur=e.viewer.skyboxBlur)),this._createPropertyBinding("toneMapping",(e=>e.viewer.onPostProcessingChanged),(e=>{this.toneMapping&&(e.viewer.postProcessing={toneMapping:this.toneMapping})}),(e=>this.toneMapping=e.viewer.postProcessing?.toneMapping)),this._createPropertyBinding("contrast",(e=>e.viewer.onPostProcessingChanged),(e=>e.viewer.postProcessing={contrast:this.contrast??void 0}),(e=>this.contrast=e.viewer.postProcessing.contrast)),this._createPropertyBinding("exposure",(e=>e.viewer.onPostProcessingChanged),(e=>e.viewer.postProcessing={exposure:this.exposure??void 0}),(e=>this.exposure=e.viewer.postProcessing.exposure)),this._createPropertyBinding("cameraAutoOrbit",(e=>e.viewer.onCameraAutoOrbitChanged),(e=>e.viewer.cameraAutoOrbit={enabled:this.cameraAutoOrbit}),(e=>this.cameraAutoOrbit=e.viewer.cameraAutoOrbit.enabled)),this._createPropertyBinding("cameraAutoOrbitSpeed",(e=>e.viewer.onCameraAutoOrbitChanged),(e=>e.viewer.cameraAutoOrbit={speed:this.cameraAutoOrbitSpeed??void 0}),(e=>this.cameraAutoOrbitSpeed=e.viewer.cameraAutoOrbit.speed)),this._createPropertyBinding("cameraAutoOrbitDelay",(e=>e.viewer.onCameraAutoOrbitChanged),(e=>e.viewer.cameraAutoOrbit={delay:this.cameraAutoOrbitDelay??void 0}),(e=>this.cameraAutoOrbitDelay=e.viewer.cameraAutoOrbit.delay)),this._createPropertyBinding("animationSpeed",(e=>e.viewer.onAnimationSpeedChanged),(e=>e.viewer.animationSpeed=this.animationSpeed),(e=>{let t=e.viewer.animationSpeed;t=ph.reduce(((e,i)=>Math.abs(i-t)<Math.abs(e-t)?i:e)),this.animationSpeed=t,this._dispatchCustomEvent("animationspeedchange",(e=>new Event(e)))})),this._createPropertyBinding("selectedAnimation",(e=>e.viewer.onSelectedAnimationChanged),(e=>e.viewer.selectedAnimation=this.selectedAnimation??e.viewer.selectedAnimation),(e=>this.selectedAnimation=e.viewer.selectedAnimation)),this._createPropertyBinding("selectedMaterialVariant",(e=>e.viewer.onSelectedMaterialVariantChanged),(e=>e.viewer.selectedMaterialVariant=this.selectedMaterialVariant??e.viewer.selectedMaterialVariant??""),(e=>this.selectedMaterialVariant=e.viewer.selectedMaterialVariant))],this.engine="WebGL",this.source=null,this.extension=null,this.environmentLighting=null,this.environmentSkybox=null,this._loadingProgress=!1,this.skyboxBlur=null,this.toneMapping=null,this.contrast=null,this.exposure=null,this.clearColor=null,this.cameraAutoOrbit=!1,this.cameraAutoOrbitSpeed=null,this.cameraAutoOrbitDelay=null,this._cameraOrbitCoercer=null,this._cameraTargetCoercer=null,this.hotSpots={},this.animationAutoPlay=!1,this.selectedAnimation=null,this.animationSpeed=1,this.animationProgress=0,this._animations=[],this._isAnimationPlaying=!1,this.selectedMaterialVariant=null}get viewerDetails(){return this._viewerDetails}queryHotSpot(e,t){return null!=this._queryHotSpot(e,t)}_queryHotSpot(e,t){if(this._viewerDetails){const i=this.hotSpots?.[e];if(i&&this._viewerDetails.viewer.getHotSpotToRef(i,t))return i}return null}focusHotSpot(e){const t=new Za,i=this._queryHotSpot(e,t);if(i&&this._viewerDetails){this._viewerDetails.viewer.pauseAnimation();const e=i.cameraOrbit??[void 0,void 0,void 0];return this._viewerDetails.camera.interpolateTo(e[0],e[1],e[2],new X(t.worldPosition[0],t.worldPosition[1],t.worldPosition[2])),!0}return!1}get environment(){return{lighting:this.environmentLighting,skybox:this.environmentSkybox}}set environment(e){this.environmentLighting=e,this.environmentSkybox=e}get loadingProgress(){return this._loadingProgress}get _hasHotSpots(){return Object.keys(this.hotSpots).length>0}get animations(){return this._animations}get _hasAnimations(){return this._animations.length>0}get isAnimationPlaying(){return this._isAnimationPlaying}get materialVariants(){return this._viewerDetails?.viewer.materialVariants??[]}toggleAnimation(){this._viewerDetails?.viewer.toggleAnimation()}resetCamera(){this._viewerDetails?.viewer.resetCamera()}connectedCallback(){super.connectedCallback(),this._setupViewer()}disconnectedCallback(){super.disconnectedCallback(),this._tearDownViewer()}update(e){super.update(e),this._materialSelect&&(this._materialSelect.value=""),e.get("engine")?(this._tearDownViewer(),this._setupViewer()):(this._propertyBindings.filter((t=>e.has(t.property))).forEach((e=>e.updateViewer())),e.has("source")&&this._updateModel(),(e.has("environmentLighting")||e.has("environmentSkybox"))&&this._updateEnv({lighting:e.has("environmentLighting"),skybox:e.has("environmentSkybox")}))}render(){const e=!1!==this.loadingProgress,t="boolean"==typeof this.loadingProgress?0:100*this.loadingProgress,i=!0===this.loadingProgress,s=zo`<div part="progress-bar" class="bar loading-progress-outer ${e?"":"loading-progress-outer-inactive"}" aria-label="Loading Progress"><div class="loading-progress-inner ${i?"loading-progress-inner-indeterminate":""}" style="${i?"":`width: ${t}%`}"></div></div>`;let r=[];if(null!=this._viewerDetails?.model){this._hasAnimations&&r.push(zo`<div class="animation-timeline"><button aria-label="${this.isAnimationPlaying?"Pause":"Play"}" @click="${this.toggleAnimation}">${this.isAnimationPlaying?zo`<svg viewBox="0 0 24 24"><path d="${"M5.74609 3C4.7796 3 3.99609 3.7835 3.99609 4.75V19.25C3.99609 20.2165 4.7796 21 5.74609 21H9.24609C10.2126 21 10.9961 20.2165 10.9961 19.25V4.75C10.9961 3.7835 10.2126 3 9.24609 3H5.74609ZM14.7461 3C13.7796 3 12.9961 3.7835 12.9961 4.75V19.25C12.9961 20.2165 13.7796 21 14.7461 21H18.2461C19.2126 21 19.9961 20.2165 19.9961 19.25V4.75C19.9961 3.7835 19.2126 3 18.2461 3H14.7461Z"}" fill="currentColor"></path></svg>`:zo`<svg viewBox="0 0 24 24"><path d="${"M5 5.27368C5 3.56682 6.82609 2.48151 8.32538 3.2973L20.687 10.0235C22.2531 10.8756 22.2531 13.124 20.687 13.9762L8.32538 20.7024C6.82609 21.5181 5 20.4328 5 18.726V5.27368Z"}" fill="currentColor"></path></svg>`}</button> <input aria-label="Animation Progress" class="animation-timeline-input" type="range" min="0" max="1" step="0.0001" .value="${this.animationProgress}" @input="${this._onAnimationTimelineChanged}" @pointerdown="${this._onAnimationTimelinePointerDown}"></div><select aria-label="Select Animation Speed" @change="${this._onAnimationSpeedChanged}">${ph.map((e=>zo`<option value="${e}" .selected="${this.animationSpeed===e}">${e}x</option>`))}</select> ${this.animations.length>1?zo`<select aria-label="Select Animation" @change="${this._onSelectedAnimationChanged}">${this.animations.map(((e,t)=>zo`<option value="${t}" .selected="${this.selectedAnimation===t}">${e}</option>`))}</select>`:""}`),this.materialVariants.length>1&&r.push(zo`<select aria-label="Select Material Variant" @change="${this._onMaterialVariantChanged}">${this.materialVariants.map((e=>zo`<option value="${e}" .selected="${this.selectedMaterialVariant===e}">${e}</option>`))}</select>`),r.push(zo`<button aria-label="Reset Camera Pose" @click="${this.resetCamera}"><svg viewBox="0 0 24 24"><path d="${"M7.20711 2.54289C7.59763 2.93342 7.59763 3.56658 7.20711 3.95711L5.41421 5.75H13.25C17.6683 5.75 21.25 9.33172 21.25 13.75C21.25 18.1683 17.6683 21.75 13.25 21.75C8.83172 21.75 5.25 18.1683 5.25 13.75C5.25 13.1977 5.69772 12.75 6.25 12.75C6.80228 12.75 7.25 13.1977 7.25 13.75C7.25 17.0637 9.93629 19.75 13.25 19.75C16.5637 19.75 19.25 17.0637 19.25 13.75C19.25 10.4363 16.5637 7.75 13.25 7.75H5.41421L7.20711 9.54289C7.59763 9.93342 7.59763 10.5666 7.20711 10.9571C6.81658 11.3476 6.18342 11.3476 5.79289 10.9571L2.29289 7.45711C1.90237 7.06658 1.90237 6.43342 2.29289 6.04289L5.79289 2.54289C6.18342 2.15237 6.81658 2.15237 7.20711 2.54289Z"}" fill="currentColor"></path></svg></button>`),this._hasHotSpots&&r.push(zo`<div class="select-container"><select id="materialSelect" aria-label="Select HotSpot" @change="${this._onHotSpotsChanged}">${Object.keys(this.hotSpots).map((e=>zo`<option value="${e}">${e}  </option>`))}</select> <button style="pointer-events:none"><svg viewBox="0 0 24 24"><path d="${"M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14ZM6 12C6 8.68629 8.68629 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12ZM12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8ZM2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4Z"}" fill="currentColor"></path></svg></button></div>`);const e=r.length,t=zo`<div class="divider"></div>`;r=r.reduce(((i,s,r)=>r<e-1?[...i,s,t]:[...i,s]),new Array)}return zo`<div class="full-size"><div id="canvasContainer" class="full-size"></div><slot class="full-size children-slot"></slot><slot name="progress-bar">${s}</slot>${0===r.length?"":zo`<slot name="tool-bar"><div part="tool-bar" class="bar ${this._hasAnimations?"":"bar-min"} tool-bar">${r}</div></slot>`}</div>`}addEventListener(e,t,i){super.addEventListener(e,t,i)}_dispatchCustomEvent(e,t){this.dispatchEvent(t(e))}_onSelectedAnimationChanged(e){const t=e.target;this.selectedAnimation=Number(t.value)}_onAnimationSpeedChanged(e){const t=e.target;this.animationSpeed=Number(t.value)}_onAnimationTimelineChanged(e){if(this._viewerDetails){const t=e.target,i=Number(t.value);i!==this.animationProgress&&(this._viewerDetails.viewer.animationProgress=i)}}_onAnimationTimelinePointerDown(e){if(this._viewerDetails?.viewer.isAnimationPlaying){this._viewerDetails.viewer.pauseAnimation();e.target.addEventListener("pointerup",(()=>this._viewerDetails?.viewer.playAnimation()),{once:!0})}}_onMaterialVariantChanged(e){const t=e.target;this.selectedMaterialVariant=t.value}_onHotSpotsChanged(e){const t=e.target,i=t.value;t.value="",this.focusHotSpot(i)}_createPropertyBinding(e,t,i,s){return{property:e,onInitialized:e=>{t(e).add((()=>{s(e)})),i(e)},updateViewer:()=>{this._viewerDetails&&i(this._viewerDetails)},syncToAttribute:()=>{const t=fh.elementProperties.get(e);if(t&&t.attribute){const i=!0===t.attribute?e:t.attribute;if(this.hasAttribute(i)){const s=this.getAttribute(i),r="function"==typeof t.converter?t.converter:void 0!==t.converter?.fromAttribute?t.converter.fromAttribute:To.fromAttribute;this[e]=r?r(s,t.type):s}}}}}async _setupViewer(){await this._viewerLock.lockAsync((async()=>{if(this._canvasContainer||await this.updateComplete,this._canvasContainer&&!this._viewerDetails){const e=document.createElement("canvas");e.className="full-size canvas",e.setAttribute("touch-action","none"),this._canvasContainer.appendChild(e),await _h(e,{engine:this.engine,onInitialized:e=>{this._viewerDetails=e,e.viewer.onEnvironmentChanged.add((()=>{this._dispatchCustomEvent("environmentchange",(e=>new Event(e)))})),e.viewer.onEnvironmentError.add((e=>{this._dispatchCustomEvent("environmenterror",(t=>new ErrorEvent(t,{error:e})))})),e.viewer.onModelChanged.add((()=>{this._animations=[...e.viewer.animations],this._propertyBindings.forEach((e=>e.syncToAttribute())),this._cameraOrbitCoercer?.(e.camera),this._cameraTargetCoercer?.(e.camera),this.animationAutoPlay&&e.viewer.playAnimation(),this._dispatchCustomEvent("modelchange",(e=>new Event(e)))})),e.viewer.onModelError.add((t=>{this._animations=[...e.viewer.animations],this._dispatchCustomEvent("modelerror",(e=>new ErrorEvent(e,{error:t})))})),e.viewer.onLoadingProgressChanged.add((()=>{this._loadingProgress=e.viewer.loadingProgress,this._dispatchCustomEvent("loadingprogresschange",(e=>new Event(e)))})),e.viewer.onIsAnimationPlayingChanged.add((()=>{this._isAnimationPlaying=e.viewer.isAnimationPlaying??!1,this._dispatchCustomEvent("animationplayingchange",(e=>new Event(e)))})),e.viewer.onAnimationProgressChanged.add((()=>{this.animationProgress=e.viewer.animationProgress??0,this._dispatchCustomEvent("animationprogresschange",(e=>new Event(e)))})),e.scene.onAfterRenderCameraObservable.add((()=>{this._dispatchCustomEvent("viewerrender",(e=>new Event(e)))})),this._updateModel(),this._updateEnv({lighting:!0,skybox:!0}),this._propertyBindings.forEach((t=>t.onInitialized(e))),this._dispatchCustomEvent("viewerready",(e=>new Event(e)))}})}}))}async _tearDownViewer(){await this._viewerLock.lockAsync((async()=>{this._viewerDetails&&(this._viewerDetails.viewer.dispose(),this._viewerDetails=void 0),this._canvasContainer&&this._canvasContainer.firstElementChild&&this._canvasContainer.removeChild(this._canvasContainer.firstElementChild)}))}async _updateModel(){if(this._viewerDetails)try{this.source?await this._viewerDetails.viewer.loadModel(this.source,{pluginExtension:this.extension??void 0,defaultAnimation:this.selectedAnimation??0}):await this._viewerDetails.viewer.resetModel()}catch(e){Ae.Log(e)}}async _updateEnv(e){if(this._viewerDetails)try{const t=[];e.lighting&&e.skybox&&this.environmentLighting===this.environmentSkybox?t.push([this.environmentLighting,{lighting:!0,skybox:!0}]):(e.lighting&&t.push([this.environmentLighting,{lighting:!0}]),e.skybox&&t.push([this.environmentSkybox,{skybox:!0}])),t.forEach((async([e,t])=>{e?await(this._viewerDetails?.viewer.loadEnvironment(e,t)):await(this._viewerDetails?.viewer.resetEnvironment(t))}))}catch(e){Ae.Log(e)}}};gh.styles=ro`:host{--ui-foreground-color:white;--ui-background-hue:233;--ui-background-saturation:8%;--ui-background-lightness:39%;--ui-background-opacity:0.75;--ui-background-color:hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), var(--ui-background-opacity));--ui-background-color-hover:hsla(
52
- var(--ui-background-hue),
53
- var(--ui-background-saturation),
54
- calc(var(--ui-background-lightness) - 10%),
55
- calc(var(--ui-background-opacity) - 0.1)
56
- );all:inherit;overflow:hidden}.full-size{display:block;position:relative;width:100%;height:100%}.canvas{outline:0}.children-slot{position:absolute;top:0;background:0 0;pointer-events:none}.bar{position:absolute;width:calc(100% - 24px);min-width:150px;max-width:1280px;left:50%;transform:translateX(-50%);background-color:var(--ui-background-color)}.bar-min{width:unset;min-width:unset;max-width:unset}.loading-progress-outer{height:4px;border-radius:4px;border:1px solid var(--ui-background-color);outline:0;top:12px;pointer-events:none;transition:opacity .5s ease}.loading-progress-outer-inactive{opacity:0;background-color:var(--ui-foreground-color)}.loading-progress-inner{width:0;height:100%;border-radius:inherit;background-color:var(--ui-foreground-color);transition:width .3s linear}@keyframes indeterminate{0%{left:0;width:0%}23%{left:0;width:30%}77%{left:70%;width:30%}100%{left:100%;width:0%}}.loading-progress-inner-indeterminate{position:absolute;animation:indeterminate 1.5s infinite;animation-timing-function:linear}.tool-bar{display:flex;flex-direction:row;align-items:center;border-radius:12px;border-color:var(--ui-foreground-color);height:48px;bottom:12px;color:var(--ui-foreground-color);-webkit-tap-highlight-color:transparent}.tool-bar *{height:100%;min-width:48px}.tool-bar .divider{min-width:1px;margin:0 6px;height:66%;background-color:var(--ui-foreground-color)}.tool-bar select{background:0 0;min-width:52px;max-width:128px;border:1px solid transparent;border-radius:inherit;color:inherit;font-size:14px;padding:0 12px;cursor:pointer;outline:0;appearance:none;-webkit-appearance:none}.tool-bar .select-container{position:relative;display:flex;border-radius:inherit;border-width:0;padding:0}.tool-bar .select-container select{position:absolute;min-width:0;width:100%}.tool-bar .select-container button{position:absolute;border-width:0}.tool-bar select:focus,.tool-bar select:hover{background-color:var(--ui-background-color-hover)}.tool-bar select option{background-color:var(--ui-background-color);color:var(--ui-foreground-color)}.tool-bar select:focus-visible{border-color:inherit}.tool-bar button{background:0 0;border:1px solid transparent;border-radius:inherit;color:inherit;padding:0;cursor:pointer;outline:0}.tool-bar button:hover{background-color:var(--ui-background-color-hover)}.tool-bar button:focus-visible{border-color:inherit}.tool-bar button svg{width:32px;height:32px}.animation-timeline{display:flex;flex:1;position:relative;overflow:hidden;cursor:pointer;align-items:center;border-radius:inherit;border-color:inherit}.animation-timeline-input{-webkit-appearance:none;cursor:pointer;width:100%;height:100%;outline:0;border:1px solid transparent;border-radius:inherit;padding:0 12px;background-color:transparent}.animation-timeline-input:focus-visible{border-color:inherit}.animation-timeline-input::-webkit-slider-thumb{-webkit-appearance:none;width:20px;height:20px;border:2px solid;color:var(--ui-foreground-color);border-radius:50%;background:hsla(var(--ui-background-hue),var(--ui-background-saturation),var(--ui-background-lightness),1);margin-top:-10px}.animation-timeline-input::-webkit-slider-runnable-track{height:2px;-webkit-appearance:none;background-color:var(--ui-foreground-color)}.animation-timeline-input::-moz-range-progress{height:2px;background-color:var(--ui-foreground-color)}.animation-timeline-input::-moz-range-thumb{width:16px;height:16px;border:2px solid var(--ui-foreground-color);border-radius:50%;background:hsla(var(--ui-background-hue),var(--ui-background-saturation),var(--ui-background-lightness),1)}.animation-timeline-input::-moz-range-track{height:2px;background:var(--ui-foreground-color)}`,e([lh({converter:e=>"WebGL"===e||"WebGPU"===e?e:"WebGL"})],gh.prototype,"engine",void 0),e([lh()],gh.prototype,"source",void 0),e([lh()],gh.prototype,"extension",void 0),e([lh({hasChanged:(e,t)=>e.lighting!==t.lighting||e.skybox!==t.skybox})],gh.prototype,"environment",null),e([lh({attribute:"environment-lighting"})],gh.prototype,"environmentLighting",void 0),e([lh({attribute:"environment-skybox"})],gh.prototype,"environmentSkybox",void 0),e([ch()],gh.prototype,"_loadingProgress",void 0),e([lh({attribute:"skybox-blur"})],gh.prototype,"skyboxBlur",void 0),e([lh({attribute:"tone-mapping",converter:e=>e&&function(e){return Xa.includes(e)}(e)?e:"neutral"})],gh.prototype,"toneMapping",void 0),e([lh()],gh.prototype,"contrast",void 0),e([lh()],gh.prototype,"exposure",void 0),e([lh({attribute:"clear-color",reflect:!0,converter:{fromAttribute:function(e){if(!e)return null;const t=document.createElement("canvas");t.width=t.height=1;const i=t.getContext("2d");if(!i)throw new Error("Unable to get 2d context for parseColor");i.clearRect(0,0,1,1),i.fillStyle=e,i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;return new le(s[0]/255,s[1]/255,s[2]/255,s[3]/255)},toAttribute:e=>e?e.toHexString():null}})],gh.prototype,"clearColor",void 0),e([lh({attribute:"camera-auto-orbit",type:Boolean})],gh.prototype,"cameraAutoOrbit",void 0),e([lh({attribute:"camera-auto-orbit-speed",type:Number})],gh.prototype,"cameraAutoOrbitSpeed",void 0),e([lh({attribute:"camera-auto-orbit-delay",type:Number})],gh.prototype,"cameraAutoOrbitDelay",void 0),e([lh({attribute:"camera-orbit",converter:e=>{if(!e)return null;const t=e.split(/\s+/);if(3!==t.length)throw new Error("cameraOrbit should be defined as 'alpha beta radius'");return e=>{for(const[i,s]of["alpha","beta","radius"].entries()){const r=t[i];"auto"!==r&&(e[s]=Number(r))}}}})],gh.prototype,"_cameraOrbitCoercer",void 0),e([lh({attribute:"camera-target",converter:e=>{if(!e)return null;const t=e.split(/\s+/);if(3!==t.length)throw new Error("cameraTarget should be defined as 'x y z'");return e=>{const i=e.target;for(const[e,s]of["x","y","z"].entries()){const r=t[e];"auto"!==r&&(i[s]=Number(r))}e.target=i.clone()}}})],gh.prototype,"_cameraTargetCoercer",void 0),e([lh({attribute:"hotspots",converter:e=>e?JSON.parse(e):{}})],gh.prototype,"hotSpots",void 0),e([lh({attribute:"animation-auto-play",reflect:!0,type:Boolean})],gh.prototype,"animationAutoPlay",void 0),e([lh({attribute:"selected-animation",type:Number})],gh.prototype,"selectedAnimation",void 0),e([lh({attribute:"animation-speed"})],gh.prototype,"animationSpeed",void 0),e([lh({attribute:!1})],gh.prototype,"animationProgress",void 0),e([ch()],gh.prototype,"_animations",void 0),e([ch()],gh.prototype,"_isAnimationPlaying",void 0),e([lh({attribute:"material-variant"})],gh.prototype,"selectedMaterialVariant",void 0),e([uh("#canvasContainer")],gh.prototype,"_canvasContainer",void 0),e([uh("#materialSelect")],gh.prototype,"_materialSelect",void 0),gh=fh=e([ah("babylon-viewer")],gh);let mh=class extends rh{constructor(){super(...arguments),this._internals=this.attachInternals(),this._viewerAttachment=null,this.hotSpot=""}connectedCallback(){if(super.connectedCallback(),this._internals.states?.add("invalid"),!(this.parentElement instanceof gh))return void console.warn("The babylon-viewer-annotation element must be a child of a babylon-viewer element.");const e=this.parentElement,t=new Za,i=()=>{if(this.hotSpot)if(e.queryHotSpot(this.hotSpot,t)){const[e,i]=t.screenPosition;this.style.transform=`translate(${e}px, ${i}px)`,this._internals.states?.delete("invalid"),t.visibility<=0?this._internals.states?.add("back-facing"):this._internals.states?.delete("back-facing")}else this._internals.states?.add("invalid")};e.addEventListener("viewerrender",i),this._viewerAttachment={dispose(){e.removeEventListener("viewerrender",i)}}}disconnectedCallback(){super.disconnectedCallback(),this._viewerAttachment?.dispose(),this._viewerAttachment=null,this._internals.states?.add("invalid")}render(){return zo`<slot></slot>`}};mh.styles=ro`:host{display:inline-block;position:absolute;transition:opacity .25s}:host([hidden]){display:none}:host(:state(back-facing)){opacity:.2}:host(:state(invalid)){display:none}`,e([lh({attribute:"hotspot"})],mh.prototype,"hotSpot",void 0),mh=e([ah("babylon-viewer-annotation")],mh);export{gs as $,Wt as A,An as B,Ve as C,Si as D,O as E,it as F,fi as G,Ut as H,kt as I,Cs as J,Ds as K,Ae as L,Qs as M,Ls as N,ka as O,rn as P,xs as Q,S as R,ia as S,pi as T,rs as U,wi as V,Us as W,ds as X,xi as Y,_s as Z,ms as _,li as a,Ge as a$,de as a0,Vn as a1,W as a2,H as a3,j as a4,Xi as a5,J as a6,bi as a7,wn as a8,Ei as a9,Aa as aA,Es as aB,Ss as aC,vs as aD,Ts as aE,Rs as aF,Lr as aG,ys as aH,bs as aI,Ms as aJ,As as aK,jn as aL,na as aM,Ia as aN,ta as aO,Ka as aP,Wa as aQ,Hi as aR,ur as aS,hi as aT,A as aU,qs as aV,fe as aW,Sr as aX,u as aY,as as aZ,ya as a_,Ti as aa,q as ab,Q as ac,L as ad,Va as ae,y as af,R as ag,Ni as ah,ss as ai,en as aj,ln as ak,za as al,e as am,o as an,n as ao,h as ap,a as aq,l as ar,Ri as as,ma as at,Qn as au,ks as av,Ps as aw,Fs as ax,Ns as ay,ws as az,Ke as b,pt as b0,ft as b1,We as b2,gt as b3,mt as b4,Tt as b5,bt as b6,Rt as b7,At as b8,Et as b9,Sn as bA,On as bB,te as bC,zs as bD,F as bE,ra as bF,lr as bG,hr as bH,or as bI,ar as bJ,nr as bK,rr as bL,se as bM,Ja as bN,Za as bO,gh as bP,_h as bQ,mh as bR,vt as ba,Nt as bb,Mt as bc,gr as bd,Er as be,Ir as bf,mr as bg,fr as bh,ir as bi,be as bj,C as bk,Se as bl,Ua as bm,Ba as bn,ri as bo,xe as bp,ve as bq,Ha as br,$i as bs,wa as bt,La as bu,ii as bv,Yt as bw,Cn as bx,N as by,xn as bz,k as c,et as d,tt as e,Nn as f,Ot as g,Pt as h,ct as i,Fi as j,Bt as k,ls as l,le as m,Ct as n,Re as o,pe as p,me as q,xt as r,he as s,bn as t,Y as u,X as v,Zi as w,qi as x,pn as y,qn as z};
57
- //# sourceMappingURL=index-j2tloO6T.esm.min.js.map