@spiffcommerce/preview 3.6.2-rc.5 → 3.6.2-rc.6

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 (490) hide show
  1. package/dist/index.esm.js +79094 -9
  2. package/dist/index.umd.js +54 -54
  3. package/package.json +2 -3
  4. package/dist/lib/assetCache.esm.js +0 -21
  5. package/dist/lib/configuration.esm.js +0 -98
  6. package/dist/lib/core.esm.js +0 -417
  7. package/dist/lib/dynamicTexture.esm.js +0 -51
  8. package/dist/lib/glbLoaderExtensions.esm.js +0 -137
  9. package/dist/lib/glowLayerManager.esm.js +0 -19
  10. package/dist/lib/guid.esm.js +0 -7
  11. package/dist/lib/material.esm.js +0 -50
  12. package/dist/lib/modelContainer.esm.js +0 -351
  13. package/dist/lib/productAnimations.esm.js +0 -123
  14. package/dist/lib/productCamera.esm.js +0 -113
  15. package/dist/lib/renderConstants.esm.js +0 -103
  16. package/dist/lib/renderingPipeline.esm.js +0 -99
  17. package/dist/lib/types.esm.js +0 -5
  18. package/dist/lib/variants.esm.js +0 -112
  19. package/dist/node_modules/@babylonjs/core/Actions/abstractActionManager.esm.js +0 -41
  20. package/dist/node_modules/@babylonjs/core/Actions/action.esm.js +0 -122
  21. package/dist/node_modules/@babylonjs/core/Actions/actionEvent.esm.js +0 -59
  22. package/dist/node_modules/@babylonjs/core/Actions/actionManager.esm.js +0 -335
  23. package/dist/node_modules/@babylonjs/core/Actions/condition.esm.js +0 -193
  24. package/dist/node_modules/@babylonjs/core/Actions/directActions.esm.js +0 -354
  25. package/dist/node_modules/@babylonjs/core/Animations/animatable.esm.js +0 -478
  26. package/dist/node_modules/@babylonjs/core/Animations/animation.esm.js +0 -866
  27. package/dist/node_modules/@babylonjs/core/Animations/animationEvent.esm.js +0 -18
  28. package/dist/node_modules/@babylonjs/core/Animations/animationGroup.esm.js +0 -470
  29. package/dist/node_modules/@babylonjs/core/Animations/animationKey.esm.js +0 -7
  30. package/dist/node_modules/@babylonjs/core/Animations/animationRange.esm.js +0 -21
  31. package/dist/node_modules/@babylonjs/core/Animations/easing.esm.js +0 -93
  32. package/dist/node_modules/@babylonjs/core/Animations/runtimeAnimation.esm.js +0 -281
  33. package/dist/node_modules/@babylonjs/core/Audio/sound.esm.js +0 -568
  34. package/dist/node_modules/@babylonjs/core/Audio/weightedsound.esm.js +0 -117
  35. package/dist/node_modules/@babylonjs/core/Behaviors/Cameras/autoRotationBehavior.esm.js +0 -145
  36. package/dist/node_modules/@babylonjs/core/Behaviors/Cameras/bouncingBehavior.esm.js +0 -93
  37. package/dist/node_modules/@babylonjs/core/Behaviors/Cameras/framingBehavior.esm.js +0 -295
  38. package/dist/node_modules/@babylonjs/core/Bones/bone.esm.js +0 -701
  39. package/dist/node_modules/@babylonjs/core/Bones/skeleton.esm.js +0 -478
  40. package/dist/node_modules/@babylonjs/core/Buffers/buffer.esm.js +0 -433
  41. package/dist/node_modules/@babylonjs/core/Buffers/dataBuffer.esm.js +0 -18
  42. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/BaseCameraMouseWheelInput.esm.js +0 -67
  43. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/BaseCameraPointersInput.esm.js +0 -191
  44. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.esm.js +0 -93
  45. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/arcRotateCameraMouseWheelInput.esm.js +0 -119
  46. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/arcRotateCameraPointersInput.esm.js +0 -119
  47. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/freeCameraKeyboardMoveInput.esm.js +0 -108
  48. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/freeCameraMouseInput.esm.js +0 -114
  49. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/freeCameraMouseWheelInput.esm.js +0 -249
  50. package/dist/node_modules/@babylonjs/core/Cameras/Inputs/freeCameraTouchInput.esm.js +0 -103
  51. package/dist/node_modules/@babylonjs/core/Cameras/arcRotateCamera.esm.js +0 -589
  52. package/dist/node_modules/@babylonjs/core/Cameras/arcRotateCameraInputsManager.esm.js +0 -37
  53. package/dist/node_modules/@babylonjs/core/Cameras/camera.esm.js +0 -686
  54. package/dist/node_modules/@babylonjs/core/Cameras/cameraInputsManager.esm.js +0 -147
  55. package/dist/node_modules/@babylonjs/core/Cameras/freeCamera.esm.js +0 -236
  56. package/dist/node_modules/@babylonjs/core/Cameras/freeCameraInputsManager.esm.js +0 -66
  57. package/dist/node_modules/@babylonjs/core/Cameras/targetCamera.esm.js +0 -214
  58. package/dist/node_modules/@babylonjs/core/Collisions/intersectionInfo.esm.js +0 -8
  59. package/dist/node_modules/@babylonjs/core/Collisions/meshCollisionData.esm.js +0 -9
  60. package/dist/node_modules/@babylonjs/core/Collisions/pickingInfo.esm.js +0 -59
  61. package/dist/node_modules/@babylonjs/core/Compat/compatibilityOptions.esm.js +0 -6
  62. package/dist/node_modules/@babylonjs/core/Culling/boundingBox.esm.js +0 -174
  63. package/dist/node_modules/@babylonjs/core/Culling/boundingInfo.esm.js +0 -159
  64. package/dist/node_modules/@babylonjs/core/Culling/boundingSphere.esm.js +0 -114
  65. package/dist/node_modules/@babylonjs/core/DeviceInput/InputDevices/deviceEnums.esm.js +0 -37
  66. package/dist/node_modules/@babylonjs/core/DeviceInput/InputDevices/deviceSource.esm.js +0 -23
  67. package/dist/node_modules/@babylonjs/core/DeviceInput/InputDevices/deviceSourceManager.esm.js +0 -106
  68. package/dist/node_modules/@babylonjs/core/DeviceInput/eventFactory.esm.js +0 -118
  69. package/dist/node_modules/@babylonjs/core/DeviceInput/internalDeviceSourceManager.esm.js +0 -46
  70. package/dist/node_modules/@babylonjs/core/DeviceInput/nativeDeviceInputSystem.esm.js +0 -50
  71. package/dist/node_modules/@babylonjs/core/DeviceInput/webDeviceInputSystem.esm.js +0 -354
  72. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.alpha.esm.js +0 -101
  73. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.cubeTexture.esm.js +0 -103
  74. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.dynamicBuffer.esm.js +0 -11
  75. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.dynamicTexture.esm.js +0 -14
  76. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.multiRender.esm.js +0 -111
  77. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.rawTexture.esm.js +0 -109
  78. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.readTexture.esm.js +0 -76
  79. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.renderTarget.esm.js +0 -69
  80. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.renderTargetCube.esm.js +0 -15
  81. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.uniformBuffer.esm.js +0 -29
  82. package/dist/node_modules/@babylonjs/core/Engines/Extensions/engine.views.esm.js +0 -85
  83. package/dist/node_modules/@babylonjs/core/Engines/Processors/Expressions/Operators/shaderDefineAndOperator.esm.js +0 -9
  84. package/dist/node_modules/@babylonjs/core/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.esm.js +0 -36
  85. package/dist/node_modules/@babylonjs/core/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.esm.js +0 -13
  86. package/dist/node_modules/@babylonjs/core/Engines/Processors/Expressions/Operators/shaderDefineOrOperator.esm.js +0 -9
  87. package/dist/node_modules/@babylonjs/core/Engines/Processors/Expressions/shaderDefineExpression.esm.js +0 -88
  88. package/dist/node_modules/@babylonjs/core/Engines/Processors/shaderCodeConditionNode.esm.js +0 -14
  89. package/dist/node_modules/@babylonjs/core/Engines/Processors/shaderCodeCursor.esm.js +0 -44
  90. package/dist/node_modules/@babylonjs/core/Engines/Processors/shaderCodeNode.esm.js +0 -31
  91. package/dist/node_modules/@babylonjs/core/Engines/Processors/shaderCodeTestNode.esm.js +0 -9
  92. package/dist/node_modules/@babylonjs/core/Engines/Processors/shaderProcessor.esm.js +0 -230
  93. package/dist/node_modules/@babylonjs/core/Engines/WebGL/webGL2ShaderProcessors.esm.js +0 -30
  94. package/dist/node_modules/@babylonjs/core/Engines/WebGL/webGLHardwareTexture.esm.js +0 -34
  95. package/dist/node_modules/@babylonjs/core/Engines/WebGL/webGLPipelineContext.esm.js +0 -388
  96. package/dist/node_modules/@babylonjs/core/Engines/WebGL/webGLRenderTargetWrapper.esm.js +0 -87
  97. package/dist/node_modules/@babylonjs/core/Engines/WebGL/webGLShaderProcessors.esm.js +0 -16
  98. package/dist/node_modules/@babylonjs/core/Engines/constants.esm.js +0 -254
  99. package/dist/node_modules/@babylonjs/core/Engines/engine.esm.js +0 -1120
  100. package/dist/node_modules/@babylonjs/core/Engines/engineStore.esm.js +0 -23
  101. package/dist/node_modules/@babylonjs/core/Engines/nullEngine.esm.js +0 -697
  102. package/dist/node_modules/@babylonjs/core/Engines/performanceConfigurator.esm.js +0 -22
  103. package/dist/node_modules/@babylonjs/core/Engines/renderTargetWrapper.esm.js +0 -273
  104. package/dist/node_modules/@babylonjs/core/Engines/shaderStore.esm.js +0 -36
  105. package/dist/node_modules/@babylonjs/core/Engines/thinEngine.esm.js +0 -2921
  106. package/dist/node_modules/@babylonjs/core/Events/deviceInputEvents.esm.js +0 -13
  107. package/dist/node_modules/@babylonjs/core/Events/keyboardEvents.esm.js +0 -41
  108. package/dist/node_modules/@babylonjs/core/Events/pointerEvents.esm.js +0 -63
  109. package/dist/node_modules/@babylonjs/core/Inputs/pointerPickingConfiguration.esm.js +0 -8
  110. package/dist/node_modules/@babylonjs/core/Inputs/scene.inputManager.esm.js +0 -418
  111. package/dist/node_modules/@babylonjs/core/Layers/effectLayer.esm.js +0 -437
  112. package/dist/node_modules/@babylonjs/core/Layers/effectLayerSceneComponent.esm.js +0 -141
  113. package/dist/node_modules/@babylonjs/core/Layers/glowLayer.esm.js +0 -343
  114. package/dist/node_modules/@babylonjs/core/Layers/highlightLayer.esm.js +0 -396
  115. package/dist/node_modules/@babylonjs/core/Lights/directionalLight.esm.js +0 -224
  116. package/dist/node_modules/@babylonjs/core/Lights/hemisphericLight.esm.js +0 -92
  117. package/dist/node_modules/@babylonjs/core/Lights/light.esm.js +0 -476
  118. package/dist/node_modules/@babylonjs/core/Lights/lightConstants.esm.js +0 -30
  119. package/dist/node_modules/@babylonjs/core/Lights/pointLight.esm.js +0 -153
  120. package/dist/node_modules/@babylonjs/core/Lights/shadowLight.esm.js +0 -196
  121. package/dist/node_modules/@babylonjs/core/Lights/spotLight.esm.js +0 -287
  122. package/dist/node_modules/@babylonjs/core/Loading/sceneLoader.esm.js +0 -551
  123. package/dist/node_modules/@babylonjs/core/Loading/sceneLoaderFlags.esm.js +0 -48
  124. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrAnisotropicConfiguration.esm.js +0 -112
  125. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrBRDFConfiguration.esm.js +0 -48
  126. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrBaseMaterial.esm.js +0 -568
  127. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrClearCoatConfiguration.esm.js +0 -139
  128. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrIridescenceConfiguration.esm.js +0 -97
  129. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrMaterial.esm.js +0 -496
  130. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrSheenConfiguration.esm.js +0 -106
  131. package/dist/node_modules/@babylonjs/core/Materials/PBR/pbrSubSurfaceConfiguration.esm.js +0 -270
  132. package/dist/node_modules/@babylonjs/core/Materials/Textures/Filtering/hdrFiltering.esm.js +0 -103
  133. package/dist/node_modules/@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader.esm.js +0 -53
  134. package/dist/node_modules/@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.esm.js +0 -51
  135. package/dist/node_modules/@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader.esm.js +0 -81
  136. package/dist/node_modules/@babylonjs/core/Materials/Textures/baseTexture.esm.js +0 -542
  137. package/dist/node_modules/@babylonjs/core/Materials/Textures/baseTexture.polynomial.esm.js +0 -23
  138. package/dist/node_modules/@babylonjs/core/Materials/Textures/cubeTexture.esm.js +0 -244
  139. package/dist/node_modules/@babylonjs/core/Materials/Textures/dynamicTexture.esm.js +0 -134
  140. package/dist/node_modules/@babylonjs/core/Materials/Textures/equiRectangularCubeTexture.esm.js +0 -89
  141. package/dist/node_modules/@babylonjs/core/Materials/Textures/hdrCubeTexture.esm.js +0 -175
  142. package/dist/node_modules/@babylonjs/core/Materials/Textures/internalTexture.esm.js +0 -150
  143. package/dist/node_modules/@babylonjs/core/Materials/Textures/ktx2decoderTypes.esm.js +0 -17
  144. package/dist/node_modules/@babylonjs/core/Materials/Textures/mirrorTexture.esm.js +0 -138
  145. package/dist/node_modules/@babylonjs/core/Materials/Textures/multiRenderTarget.esm.js +0 -223
  146. package/dist/node_modules/@babylonjs/core/Materials/Textures/rawCubeTexture.esm.js +0 -58
  147. package/dist/node_modules/@babylonjs/core/Materials/Textures/rawTexture.esm.js +0 -156
  148. package/dist/node_modules/@babylonjs/core/Materials/Textures/rawTexture2DArray.esm.js +0 -53
  149. package/dist/node_modules/@babylonjs/core/Materials/Textures/renderTargetTexture.esm.js +0 -605
  150. package/dist/node_modules/@babylonjs/core/Materials/Textures/texture.esm.js +0 -421
  151. package/dist/node_modules/@babylonjs/core/Materials/Textures/textureSampler.esm.js +0 -101
  152. package/dist/node_modules/@babylonjs/core/Materials/Textures/thinTexture.esm.js +0 -170
  153. package/dist/node_modules/@babylonjs/core/Materials/clipPlaneMaterialHelper.esm.js +0 -28
  154. package/dist/node_modules/@babylonjs/core/Materials/colorCurves.esm.js +0 -397
  155. package/dist/node_modules/@babylonjs/core/Materials/drawWrapper.esm.js +0 -22
  156. package/dist/node_modules/@babylonjs/core/Materials/effect.esm.js +0 -890
  157. package/dist/node_modules/@babylonjs/core/Materials/effectFallbacks.esm.js +0 -73
  158. package/dist/node_modules/@babylonjs/core/Materials/effectRenderer.esm.js +0 -132
  159. package/dist/node_modules/@babylonjs/core/Materials/imageProcessingConfiguration.esm.js +0 -428
  160. package/dist/node_modules/@babylonjs/core/Materials/material.detailMapConfiguration.esm.js +0 -90
  161. package/dist/node_modules/@babylonjs/core/Materials/material.esm.js +0 -906
  162. package/dist/node_modules/@babylonjs/core/Materials/materialDefines.esm.js +0 -161
  163. package/dist/node_modules/@babylonjs/core/Materials/materialFlags.esm.js +0 -226
  164. package/dist/node_modules/@babylonjs/core/Materials/materialHelper.esm.js +0 -501
  165. package/dist/node_modules/@babylonjs/core/Materials/materialPluginBase.esm.js +0 -226
  166. package/dist/node_modules/@babylonjs/core/Materials/materialPluginEvent.esm.js +0 -7
  167. package/dist/node_modules/@babylonjs/core/Materials/materialPluginManager.esm.js +0 -212
  168. package/dist/node_modules/@babylonjs/core/Materials/materialStencilState.esm.js +0 -145
  169. package/dist/node_modules/@babylonjs/core/Materials/multiMaterial.esm.js +0 -164
  170. package/dist/node_modules/@babylonjs/core/Materials/prePassConfiguration.esm.js +0 -38
  171. package/dist/node_modules/@babylonjs/core/Materials/pushMaterial.esm.js +0 -48
  172. package/dist/node_modules/@babylonjs/core/Materials/shaderLanguage.esm.js +0 -7
  173. package/dist/node_modules/@babylonjs/core/Materials/shaderMaterial.esm.js +0 -838
  174. package/dist/node_modules/@babylonjs/core/Materials/standardMaterial.esm.js +0 -934
  175. package/dist/node_modules/@babylonjs/core/Materials/uniformBuffer.esm.js +0 -541
  176. package/dist/node_modules/@babylonjs/core/Maths/math.axis.esm.js +0 -19
  177. package/dist/node_modules/@babylonjs/core/Maths/math.color.esm.js +0 -903
  178. package/dist/node_modules/@babylonjs/core/Maths/math.constants.esm.js +0 -6
  179. package/dist/node_modules/@babylonjs/core/Maths/math.frustum.esm.js +0 -91
  180. package/dist/node_modules/@babylonjs/core/Maths/math.functions.esm.js +0 -43
  181. package/dist/node_modules/@babylonjs/core/Maths/math.path.esm.js +0 -9
  182. package/dist/node_modules/@babylonjs/core/Maths/math.plane.esm.js +0 -145
  183. package/dist/node_modules/@babylonjs/core/Maths/math.scalar.esm.js +0 -284
  184. package/dist/node_modules/@babylonjs/core/Maths/math.size.esm.js +0 -124
  185. package/dist/node_modules/@babylonjs/core/Maths/math.vector.esm.js +0 -4915
  186. package/dist/node_modules/@babylonjs/core/Maths/math.viewport.esm.js +0 -41
  187. package/dist/node_modules/@babylonjs/core/Maths/sphericalPolynomial.esm.js +0 -177
  188. package/dist/node_modules/@babylonjs/core/Meshes/Builders/boxBuilder.esm.js +0 -260
  189. package/dist/node_modules/@babylonjs/core/Meshes/Compression/dracoCompression.esm.js +0 -233
  190. package/dist/node_modules/@babylonjs/core/Meshes/Compression/meshoptCompression.esm.js +0 -47
  191. package/dist/node_modules/@babylonjs/core/Meshes/WebGL/webGLDataBuffer.esm.js +0 -12
  192. package/dist/node_modules/@babylonjs/core/Meshes/abstractMesh.esm.js +0 -1448
  193. package/dist/node_modules/@babylonjs/core/Meshes/geometry.esm.js +0 -729
  194. package/dist/node_modules/@babylonjs/core/Meshes/instancedMesh.esm.js +0 -455
  195. package/dist/node_modules/@babylonjs/core/Meshes/mesh.esm.js +0 -2526
  196. package/dist/node_modules/@babylonjs/core/Meshes/mesh.vertexData.esm.js +0 -865
  197. package/dist/node_modules/@babylonjs/core/Meshes/meshLODLevel.esm.js +0 -13
  198. package/dist/node_modules/@babylonjs/core/Meshes/subMesh.esm.js +0 -422
  199. package/dist/node_modules/@babylonjs/core/Meshes/thinInstanceMesh.esm.js +0 -129
  200. package/dist/node_modules/@babylonjs/core/Meshes/transformNode.esm.js +0 -796
  201. package/dist/node_modules/@babylonjs/core/Misc/HighDynamicRange/cubemapToSphericalPolynomial.esm.js +0 -111
  202. package/dist/node_modules/@babylonjs/core/Misc/HighDynamicRange/hdr.esm.js +0 -122
  203. package/dist/node_modules/@babylonjs/core/Misc/HighDynamicRange/panoramaToCubemap.esm.js +0 -78
  204. package/dist/node_modules/@babylonjs/core/Misc/andOrNotEvaluator.esm.js +0 -41
  205. package/dist/node_modules/@babylonjs/core/Misc/arrayTools.esm.js +0 -52
  206. package/dist/node_modules/@babylonjs/core/Misc/assetsManager.esm.js +0 -561
  207. package/dist/node_modules/@babylonjs/core/Misc/brdfTextureTools.esm.js +0 -31
  208. package/dist/node_modules/@babylonjs/core/Misc/copyTools.esm.js +0 -44
  209. package/dist/node_modules/@babylonjs/core/Misc/coroutine.esm.js +0 -53
  210. package/dist/node_modules/@babylonjs/core/Misc/dataReader.esm.js +0 -55
  211. package/dist/node_modules/@babylonjs/core/Misc/dds.esm.js +0 -329
  212. package/dist/node_modules/@babylonjs/core/Misc/decorators.esm.js +0 -332
  213. package/dist/node_modules/@babylonjs/core/Misc/deepCopier.esm.js +0 -52
  214. package/dist/node_modules/@babylonjs/core/Misc/deferred.esm.js +0 -25
  215. package/dist/node_modules/@babylonjs/core/Misc/devTools.esm.js +0 -6
  216. package/dist/node_modules/@babylonjs/core/Misc/domManagement.esm.js +0 -21
  217. package/dist/node_modules/@babylonjs/core/Misc/dumpTools.esm.js +0 -117
  218. package/dist/node_modules/@babylonjs/core/Misc/environmentTextureTools.esm.js +0 -187
  219. package/dist/node_modules/@babylonjs/core/Misc/error.esm.js +0 -40
  220. package/dist/node_modules/@babylonjs/core/Misc/fileTools.esm.js +0 -339
  221. package/dist/node_modules/@babylonjs/core/Misc/filesInputStore.esm.js +0 -6
  222. package/dist/node_modules/@babylonjs/core/Misc/guid.esm.js +0 -9
  223. package/dist/node_modules/@babylonjs/core/Misc/instantiationTools.esm.js +0 -26
  224. package/dist/node_modules/@babylonjs/core/Misc/khronosTextureContainer.esm.js +0 -79
  225. package/dist/node_modules/@babylonjs/core/Misc/khronosTextureContainer2.esm.js +0 -281
  226. package/dist/node_modules/@babylonjs/core/Misc/logger.esm.js +0 -77
  227. package/dist/node_modules/@babylonjs/core/Misc/observable.esm.js +0 -231
  228. package/dist/node_modules/@babylonjs/core/Misc/perfCounter.esm.js +0 -99
  229. package/dist/node_modules/@babylonjs/core/Misc/performanceMonitor.esm.js +0 -144
  230. package/dist/node_modules/@babylonjs/core/Misc/precisionDate.esm.js +0 -12
  231. package/dist/node_modules/@babylonjs/core/Misc/retryStrategy.esm.js +0 -14
  232. package/dist/node_modules/@babylonjs/core/Misc/rgbdTextureTools.esm.js +0 -51
  233. package/dist/node_modules/@babylonjs/core/Misc/screenshotTools.esm.js +0 -92
  234. package/dist/node_modules/@babylonjs/core/Misc/smartArray.esm.js +0 -118
  235. package/dist/node_modules/@babylonjs/core/Misc/stringDictionary.esm.js +0 -129
  236. package/dist/node_modules/@babylonjs/core/Misc/stringTools.esm.js +0 -26
  237. package/dist/node_modules/@babylonjs/core/Misc/tags.esm.js +0 -97
  238. package/dist/node_modules/@babylonjs/core/Misc/textureTools.esm.js +0 -41
  239. package/dist/node_modules/@babylonjs/core/Misc/timingTools.esm.js +0 -13
  240. package/dist/node_modules/@babylonjs/core/Misc/tools.esm.js +0 -929
  241. package/dist/node_modules/@babylonjs/core/Misc/typeStore.esm.js +0 -11
  242. package/dist/node_modules/@babylonjs/core/Misc/uniqueIdGenerator.esm.js +0 -13
  243. package/dist/node_modules/@babylonjs/core/Misc/webRequest.esm.js +0 -135
  244. package/dist/node_modules/@babylonjs/core/Misc/workerPool.esm.js +0 -80
  245. package/dist/node_modules/@babylonjs/core/Morph/morphTarget.esm.js +0 -187
  246. package/dist/node_modules/@babylonjs/core/Morph/morphTargetManager.esm.js +0 -249
  247. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.esm.js +0 -349
  248. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.esm.js +0 -306
  249. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.esm.js +0 -161
  250. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.esm.js +0 -589
  251. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.esm.js +0 -512
  252. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/postProcessRenderEffect.esm.js +0 -114
  253. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/postProcessRenderPipeline.esm.js +0 -139
  254. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.esm.js +0 -99
  255. package/dist/node_modules/@babylonjs/core/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.esm.js +0 -48
  256. package/dist/node_modules/@babylonjs/core/PostProcesses/bloomEffect.esm.js +0 -76
  257. package/dist/node_modules/@babylonjs/core/PostProcesses/bloomMergePostProcess.esm.js +0 -40
  258. package/dist/node_modules/@babylonjs/core/PostProcesses/blurPostProcess.esm.js +0 -165
  259. package/dist/node_modules/@babylonjs/core/PostProcesses/chromaticAberrationPostProcess.esm.js +0 -61
  260. package/dist/node_modules/@babylonjs/core/PostProcesses/circleOfConfusionPostProcess.esm.js +0 -62
  261. package/dist/node_modules/@babylonjs/core/PostProcesses/depthOfFieldBlurPostProcess.esm.js +0 -58
  262. package/dist/node_modules/@babylonjs/core/PostProcesses/depthOfFieldEffect.esm.js +0 -131
  263. package/dist/node_modules/@babylonjs/core/PostProcesses/depthOfFieldMergePostProcess.esm.js +0 -48
  264. package/dist/node_modules/@babylonjs/core/PostProcesses/extractHighlightsPostProcess.esm.js +0 -27
  265. package/dist/node_modules/@babylonjs/core/PostProcesses/fxaaPostProcess.esm.js +0 -41
  266. package/dist/node_modules/@babylonjs/core/PostProcesses/grainPostProcess.esm.js +0 -46
  267. package/dist/node_modules/@babylonjs/core/PostProcesses/imageProcessingPostProcess.esm.js +0 -359
  268. package/dist/node_modules/@babylonjs/core/PostProcesses/motionBlurPostProcess.esm.js +0 -178
  269. package/dist/node_modules/@babylonjs/core/PostProcesses/passPostProcess.esm.js +0 -40
  270. package/dist/node_modules/@babylonjs/core/PostProcesses/postProcess.esm.js +0 -457
  271. package/dist/node_modules/@babylonjs/core/PostProcesses/postProcessManager.esm.js +0 -94
  272. package/dist/node_modules/@babylonjs/core/PostProcesses/screenSpaceReflectionPostProcess.esm.js +0 -147
  273. package/dist/node_modules/@babylonjs/core/PostProcesses/sharpenPostProcess.esm.js +0 -46
  274. package/dist/node_modules/@babylonjs/core/Probes/reflectionProbe.esm.js +0 -184
  275. package/dist/node_modules/@babylonjs/core/Rendering/boundingBoxRenderer.esm.js +0 -170
  276. package/dist/node_modules/@babylonjs/core/Rendering/depthRenderer.esm.js +0 -185
  277. package/dist/node_modules/@babylonjs/core/Rendering/depthRendererSceneComponent.esm.js +0 -65
  278. package/dist/node_modules/@babylonjs/core/Rendering/geometryBufferRenderer.esm.js +0 -353
  279. package/dist/node_modules/@babylonjs/core/Rendering/geometryBufferRendererSceneComponent.esm.js +0 -55
  280. package/dist/node_modules/@babylonjs/core/Rendering/motionBlurConfiguration.esm.js +0 -8
  281. package/dist/node_modules/@babylonjs/core/Rendering/renderingGroup.esm.js +0 -223
  282. package/dist/node_modules/@babylonjs/core/Rendering/renderingManager.esm.js +0 -185
  283. package/dist/node_modules/@babylonjs/core/Rendering/screenSpaceReflections2Configuration.esm.js +0 -8
  284. package/dist/node_modules/@babylonjs/core/Rendering/screenSpaceReflectionsConfiguration.esm.js +0 -8
  285. package/dist/node_modules/@babylonjs/core/Rendering/ssao2Configuration.esm.js +0 -8
  286. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimation.esm.js +0 -48
  287. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.esm.js +0 -24
  288. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bonesDeclaration.esm.js +0 -35
  289. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bonesVertex.esm.js +0 -56
  290. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/boundingBoxRendererFragmentDeclaration.esm.js +0 -4
  291. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/boundingBoxRendererUboDeclaration.esm.js +0 -19
  292. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/boundingBoxRendererVertexDeclaration.esm.js +0 -8
  293. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bumpFragment.esm.js +0 -67
  294. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bumpFragmentFunctions.esm.js +0 -58
  295. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bumpFragmentMainFunctions.esm.js +0 -93
  296. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bumpVertex.esm.js +0 -11
  297. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/bumpVertexDeclaration.esm.js +0 -8
  298. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.esm.js +0 -42
  299. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.esm.js +0 -21
  300. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.esm.js +0 -21
  301. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertexDeclaration.esm.js +0 -27
  302. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/decalFragment.esm.js +0 -12
  303. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/decalFragmentDeclaration.esm.js +0 -6
  304. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/decalVertexDeclaration.esm.js +0 -7
  305. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/defaultFragmentDeclaration.esm.js +0 -86
  306. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/defaultUboDeclaration.esm.js +0 -50
  307. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/defaultVertexDeclaration.esm.js +0 -46
  308. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/depthPrePass.esm.js +0 -7
  309. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/fogFragment.esm.js +0 -10
  310. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.esm.js +0 -34
  311. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/fogVertex.esm.js +0 -6
  312. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.esm.js +0 -6
  313. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/fresnelFunction.esm.js +0 -10
  314. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/geometryUboDeclaration.esm.js +0 -5
  315. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/geometryVertexDeclaration.esm.js +0 -4
  316. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/harmonicsFunctions.esm.js +0 -42
  317. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/hdrFilteringFunctions.esm.js +0 -139
  318. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/helperFunctions.esm.js +0 -166
  319. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/imageProcessingDeclaration.esm.js +0 -32
  320. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/imageProcessingFunctions.esm.js +0 -129
  321. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/importanceSampling.esm.js +0 -22
  322. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.esm.js +0 -31
  323. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/instancesVertex.esm.js +0 -20
  324. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/kernelBlurFragment.esm.js +0 -15
  325. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/kernelBlurFragment2.esm.js +0 -15
  326. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/kernelBlurVaryingDeclaration.esm.js +0 -3
  327. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/kernelBlurVertex.esm.js +0 -3
  328. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/lightFragment.esm.js +0 -278
  329. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.esm.js +0 -82
  330. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.esm.js +0 -81
  331. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/lightVxFragmentDeclaration.esm.js +0 -35
  332. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/lightVxUboDeclaration.esm.js +0 -34
  333. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.esm.js +0 -93
  334. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.esm.js +0 -7
  335. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/logDepthFragment.esm.js +0 -6
  336. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/logDepthVertex.esm.js +0 -7
  337. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/mainUVVaryingDeclaration.esm.js +0 -6
  338. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/meshUboDeclaration.esm.js +0 -15
  339. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/morphTargetsVertex.esm.js +0 -32
  340. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/morphTargetsVertexDeclaration.esm.js +0 -17
  341. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/morphTargetsVertexGlobal.esm.js +0 -8
  342. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.esm.js +0 -19
  343. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/mrtFragmentDeclaration.esm.js +0 -6
  344. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/oitDeclaration.esm.js +0 -13
  345. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/oitFragment.esm.js +0 -40
  346. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/packingFunctions.esm.js +0 -15
  347. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBRDFFunctions.esm.js +0 -268
  348. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.esm.js +0 -83
  349. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockAlphaFresnel.esm.js +0 -37
  350. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockAmbientOcclusion.esm.js +0 -32
  351. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockAnisotropic.esm.js +0 -50
  352. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockClearcoat.esm.js +0 -276
  353. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockDirectLighting.esm.js +0 -19
  354. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockFinalColorComposition.esm.js +0 -45
  355. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockFinalLitComponents.esm.js +0 -100
  356. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.esm.js +0 -27
  357. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockGeometryInfo.esm.js +0 -30
  358. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockImageProcessing.esm.js +0 -14
  359. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockIridescence.esm.js +0 -63
  360. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockLightmapInit.esm.js +0 -13
  361. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockNormalFinal.esm.js +0 -13
  362. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockNormalGeometric.esm.js +0 -13
  363. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockReflectance.esm.js +0 -24
  364. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockReflectance0.esm.js +0 -14
  365. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockReflection.esm.js +0 -270
  366. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockReflectivity.esm.js +0 -131
  367. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockSheen.esm.js +0 -197
  368. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrBlockSubSurface.esm.js +0 -337
  369. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrDebug.esm.js +0 -176
  370. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.esm.js +0 -64
  371. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrDirectLightingFunctions.esm.js +0 -130
  372. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.esm.js +0 -53
  373. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrFragmentDeclaration.esm.js +0 -179
  374. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.esm.js +0 -18
  375. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.esm.js +0 -101
  376. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrHelperFunctions.esm.js +0 -83
  377. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrIBLFunctions.esm.js +0 -35
  378. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrUboDeclaration.esm.js +0 -65
  379. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pbrVertexDeclaration.esm.js +0 -151
  380. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/pointCloudVertex.esm.js +0 -6
  381. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/prePassDeclaration.esm.js +0 -13
  382. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/prePassVertex.esm.js +0 -37
  383. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/prePassVertexDeclaration.esm.js +0 -13
  384. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/reflectionFunction.esm.js +0 -116
  385. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/samplerFragmentAlternateDeclaration.esm.js +0 -20
  386. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/samplerFragmentDeclaration.esm.js +0 -21
  387. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/samplerVertexDeclaration.esm.js +0 -6
  388. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/samplerVertexImplementation.esm.js +0 -39
  389. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/sceneUboDeclaration.esm.js +0 -13
  390. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/screenSpaceRayTrace.esm.js +0 -208
  391. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.esm.js +0 -614
  392. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.esm.js +0 -23
  393. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/subSurfaceScatteringFunctions.esm.js +0 -6
  394. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/uvAttributeDeclaration.esm.js +0 -6
  395. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/uvVariableDeclaration.esm.js +0 -9
  396. package/dist/node_modules/@babylonjs/core/Shaders/ShadersInclude/vertexColorMixing.esm.js +0 -16
  397. package/dist/node_modules/@babylonjs/core/Shaders/bloomMerge.fragment.esm.js +0 -14
  398. package/dist/node_modules/@babylonjs/core/Shaders/boundingBoxRenderer.fragment.esm.js +0 -11
  399. package/dist/node_modules/@babylonjs/core/Shaders/boundingBoxRenderer.vertex.esm.js +0 -22
  400. package/dist/node_modules/@babylonjs/core/Shaders/chromaticAberration.fragment.esm.js +0 -34
  401. package/dist/node_modules/@babylonjs/core/Shaders/circleOfConfusion.fragment.esm.js +0 -19
  402. package/dist/node_modules/@babylonjs/core/Shaders/default.fragment.esm.js +0 -387
  403. package/dist/node_modules/@babylonjs/core/Shaders/default.vertex.esm.js +0 -171
  404. package/dist/node_modules/@babylonjs/core/Shaders/depth.fragment.esm.js +0 -47
  405. package/dist/node_modules/@babylonjs/core/Shaders/depth.vertex.esm.js +0 -72
  406. package/dist/node_modules/@babylonjs/core/Shaders/depthOfField.fragment.esm.js +0 -137
  407. package/dist/node_modules/@babylonjs/core/Shaders/depthOfFieldMerge.fragment.esm.js +0 -54
  408. package/dist/node_modules/@babylonjs/core/Shaders/extractHighlights.fragment.esm.js +0 -15
  409. package/dist/node_modules/@babylonjs/core/Shaders/fxaa.fragment.esm.js +0 -211
  410. package/dist/node_modules/@babylonjs/core/Shaders/fxaa.vertex.esm.js +0 -29
  411. package/dist/node_modules/@babylonjs/core/Shaders/geometry.fragment.esm.js +0 -147
  412. package/dist/node_modules/@babylonjs/core/Shaders/geometry.vertex.esm.js +0 -164
  413. package/dist/node_modules/@babylonjs/core/Shaders/glowBlurPostProcess.fragment.esm.js +0 -39
  414. package/dist/node_modules/@babylonjs/core/Shaders/glowMapGeneration.fragment.esm.js +0 -73
  415. package/dist/node_modules/@babylonjs/core/Shaders/glowMapGeneration.vertex.esm.js +0 -94
  416. package/dist/node_modules/@babylonjs/core/Shaders/glowMapMerge.fragment.esm.js +0 -29
  417. package/dist/node_modules/@babylonjs/core/Shaders/glowMapMerge.vertex.esm.js +0 -12
  418. package/dist/node_modules/@babylonjs/core/Shaders/grain.fragment.esm.js +0 -19
  419. package/dist/node_modules/@babylonjs/core/Shaders/hdrFiltering.fragment.esm.js +0 -19
  420. package/dist/node_modules/@babylonjs/core/Shaders/hdrFiltering.vertex.esm.js +0 -15
  421. package/dist/node_modules/@babylonjs/core/Shaders/imageProcessing.fragment.esm.js +0 -26
  422. package/dist/node_modules/@babylonjs/core/Shaders/kernelBlur.fragment.esm.js +0 -49
  423. package/dist/node_modules/@babylonjs/core/Shaders/kernelBlur.vertex.esm.js +0 -17
  424. package/dist/node_modules/@babylonjs/core/Shaders/lensHighlights.fragment.esm.js +0 -115
  425. package/dist/node_modules/@babylonjs/core/Shaders/motionBlur.fragment.esm.js +0 -74
  426. package/dist/node_modules/@babylonjs/core/Shaders/pass.fragment.esm.js +0 -13
  427. package/dist/node_modules/@babylonjs/core/Shaders/passCube.fragment.esm.js +0 -27
  428. package/dist/node_modules/@babylonjs/core/Shaders/pbr.fragment.esm.js +0 -648
  429. package/dist/node_modules/@babylonjs/core/Shaders/pbr.vertex.esm.js +0 -236
  430. package/dist/node_modules/@babylonjs/core/Shaders/postprocess.vertex.esm.js +0 -13
  431. package/dist/node_modules/@babylonjs/core/Shaders/rgbdDecode.fragment.esm.js +0 -11
  432. package/dist/node_modules/@babylonjs/core/Shaders/rgbdEncode.fragment.esm.js +0 -11
  433. package/dist/node_modules/@babylonjs/core/Shaders/screenSpaceReflection.fragment.esm.js +0 -136
  434. package/dist/node_modules/@babylonjs/core/Shaders/screenSpaceReflection2.fragment.esm.js +0 -215
  435. package/dist/node_modules/@babylonjs/core/Shaders/screenSpaceReflection2Blur.fragment.esm.js +0 -52
  436. package/dist/node_modules/@babylonjs/core/Shaders/screenSpaceReflection2BlurCombiner.fragment.esm.js +0 -59
  437. package/dist/node_modules/@babylonjs/core/Shaders/sharpen.fragment.esm.js +0 -18
  438. package/dist/node_modules/@babylonjs/core/Shaders/ssao.fragment.esm.js +0 -55
  439. package/dist/node_modules/@babylonjs/core/Shaders/ssao2.fragment.esm.js +0 -165
  440. package/dist/node_modules/@babylonjs/core/Shaders/ssaoCombine.fragment.esm.js +0 -15
  441. package/dist/node_modules/@babylonjs/core/Shaders/standard.fragment.esm.js +0 -339
  442. package/dist/node_modules/@babylonjs/core/States/alphaCullingState.esm.js +0 -35
  443. package/dist/node_modules/@babylonjs/core/States/depthCullingState.esm.js +0 -69
  444. package/dist/node_modules/@babylonjs/core/States/stencilState.esm.js +0 -62
  445. package/dist/node_modules/@babylonjs/core/States/stencilStateComposer.esm.js +0 -70
  446. package/dist/node_modules/@babylonjs/core/abstractScene.esm.js +0 -71
  447. package/dist/node_modules/@babylonjs/core/assetContainer.esm.js +0 -425
  448. package/dist/node_modules/@babylonjs/core/node.esm.js +0 -536
  449. package/dist/node_modules/@babylonjs/core/scene.esm.js +0 -2809
  450. package/dist/node_modules/@babylonjs/core/sceneComponent.esm.js +0 -102
  451. package/dist/node_modules/@babylonjs/core/tslib.es6.esm.js +0 -12
  452. package/dist/node_modules/@babylonjs/loaders/glTF/1.0/glTFBinaryExtension.esm.js +0 -37
  453. package/dist/node_modules/@babylonjs/loaders/glTF/1.0/glTFLoader.esm.js +0 -902
  454. package/dist/node_modules/@babylonjs/loaders/glTF/1.0/glTFLoaderInterfaces.esm.js +0 -42
  455. package/dist/node_modules/@babylonjs/loaders/glTF/1.0/glTFLoaderUtils.esm.js +0 -195
  456. package/dist/node_modules/@babylonjs/loaders/glTF/1.0/glTFMaterialsCommonExtension.esm.js +0 -75
  457. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/EXT_lights_image_based.esm.js +0 -77
  458. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.esm.js +0 -53
  459. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/EXT_meshopt_compression.esm.js +0 -31
  460. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/EXT_texture_webp.esm.js +0 -29
  461. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/ExtrasAsMetadata.esm.js +0 -47
  462. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.esm.js +0 -173
  463. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_animation_pointer.esm.js +0 -82
  464. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression.esm.js +0 -68
  465. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_lights_punctual.esm.js +0 -60
  466. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_anisotropy.esm.js +0 -39
  467. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_clearcoat.esm.js +0 -42
  468. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_emissive_strength.esm.js +0 -32
  469. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_ior.esm.js +0 -35
  470. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_iridescence.esm.js +0 -41
  471. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.esm.js +0 -41
  472. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_sheen.esm.js +0 -41
  473. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_specular.esm.js +0 -41
  474. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_translucency.esm.js +0 -41
  475. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_transmission.esm.js +0 -136
  476. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_unlit.esm.js +0 -37
  477. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_variants.esm.js +0 -178
  478. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_volume.esm.js +0 -40
  479. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_mesh_quantization.esm.js +0 -17
  480. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_texture_basisu.esm.js +0 -29
  481. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_texture_transform.esm.js +0 -29
  482. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/KHR_xmp_json_ld.esm.js +0 -31
  483. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/MSFT_audio_emitter.esm.js +0 -149
  484. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/MSFT_lod.esm.js +0 -170
  485. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/MSFT_minecraftMesh.esm.js +0 -29
  486. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/Extensions/MSFT_sRGBFactors.esm.js +0 -29
  487. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/glTFLoader.esm.js +0 -1562
  488. package/dist/node_modules/@babylonjs/loaders/glTF/2.0/glTFLoaderAnimation.esm.js +0 -66
  489. package/dist/node_modules/@babylonjs/loaders/glTF/glTFFileLoader.esm.js +0 -462
  490. package/dist/node_modules/@babylonjs/loaders/glTF/glTFValidation.esm.js +0 -81
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(_i,Ji){typeof exports=="object"&&typeof module<"u"?Ji(exports):typeof define=="function"&&define.amd?define(["exports"],Ji):(_i=typeof globalThis<"u"?globalThis:_i||self,Ji(_i.Preview={}))})(this,function(_i){"use strict";var Ji=(l=>(l[l.Orbit=0]="Orbit",l[l.Pan=1]="Pan",l))(Ji||{}),Xr=(l=>(l.None="None",l.RemoveWhenSelected="RemoveWhenSelected",l.ApplyWhenSelected="ApplyWhenSelected",l))(Xr||{});function g(l,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,t,i);else for(var a=l.length-1;a>=0;a--)(n=l[a])&&(r=(s<3?n(r):s>3?n(e,t,r):n(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}class ms{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),ms._HandleParenthesisContent(i,t))):e=ms._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:ms.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(r=>r==="true");let i;const s=e.split("||");for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){let n=ms._SimplifyNegation(s[r].trim());const a=n.split("&&");if(a.length>1)for(let o=0;o<a.length;++o){const h=ms._SimplifyNegation(a[o].trim());if(h!=="true"&&h!=="false"?h[0]==="!"?i=!t(h.substring(1)):i=t(h):i=h==="true",!i){n="false";break}}if(i||n==="true"){i=!0;break}n!=="true"&&n!=="false"?n[0]==="!"?i=!t(n.substring(1)):i=t(n):i=n==="true"}return i?"true":"false"}static _SimplifyNegation(e){return e=e.replace(/^[\s!]+/,t=>(t=t.replace(/[\s]/g,()=>""),t.length%2?"!":"")),e=e.trim(),e==="!true"?e="false":e==="!false"&&(e="true"),e}}class xe{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>xe.HasTags(e),e.addTags=t=>xe.AddTagsTo(e,t),e.removeTags=t=>xe.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>xe.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 i in t)if(Object.prototype.hasOwnProperty.call(t,i))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const i=[];for(const s in e._tags)Object.prototype.hasOwnProperty.call(e._tags,s)&&e._tags[s]===!0&&i.push(s);return i.join(" ")}else return e._tags}static AddTagsTo(e,t){if(!t||typeof t!="string")return;t.split(" ").forEach(function(s){xe._AddTagTo(e,s)})}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(xe.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!xe.HasTags(e))return;const i=t.split(" ");for(const s in i)xe._RemoveTagFrom(e,i[s])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?xe.HasTags(e):ms.Eval(t,i=>xe.HasTags(e)&&e._tags[i])}}class ${static WithinEpsilon(e,t,i=1401298e-51){return Math.abs(e-t)<=i}static ToHex(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}static Sign(e){return e=+e,e===0||isNaN(e)?e:e>0?1:-1}static Clamp(e,t=0,i=1){return Math.min(i,Math.max(t,e))}static Log2(e){return Math.log(e)*Math.LOG2E}static ILog2(e){if(Math.log2)return Math.floor(Math.log2(e));if(e<0)return NaN;if(e===0)return-1/0;let t=0;if(e<1){for(;e<1;)t++,e=e*2;t=-t}else if(e>1)for(;e>1;)t++,e=Math.floor(e/2);return t}static Repeat(e,t){return e-Math.floor(e/t)*t}static Normalize(e,t,i){return(e-t)/(i-t)}static Denormalize(e,t,i){return e*(i-t)+t}static DeltaAngle(e,t){let i=$.Repeat(t-e,360);return i>180&&(i-=360),i}static PingPong(e,t){const i=$.Repeat(e,t*2);return t-Math.abs(i-t)}static SmoothStep(e,t,i){let s=$.Clamp(i);return s=-2*s*s*s+3*s*s,t*s+e*(1-s)}static MoveTowards(e,t,i){let s=0;return Math.abs(t-e)<=i?s=t:s=e+$.Sign(t-e)*i,s}static MoveTowardsAngle(e,t,i){const s=$.DeltaAngle(e,t);let r=0;return-i<s&&s<i?r=t:(t=e+s,r=$.MoveTowards(e,t,i)),r}static Lerp(e,t,i){return e+(t-e)*i}static LerpAngle(e,t,i){let s=$.Repeat(t-e,360);return s>180&&(s-=360),e+s*$.Clamp(i)}static InverseLerp(e,t,i){let s=0;return e!=t?s=$.Clamp((i-e)/(t-e)):s=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,c=a-2*n+r,u=a-n;return e*o+i*h+t*c+s*u}static Hermite1stDerivative(e,t,i,s,r){const n=r*r;return(n-r)*6*e+(3*n-4*r+1)*t+(-n+r)*6*i+(3*n-2*r)*s}static RandomRange(e,t){return e===t?e:Math.random()*(t-e)+e}static RangeToPercent(e,t,i){return(e-t)/(i-t)}static PercentToRange(e,t,i){return(i-t)*e+t}static NormalizeRadians(e){return e-=$.TwoPi*Math.floor((e+Math.PI)/$.TwoPi),e}static HCF(e,t){const i=e%t;return i===0?t:$.HCF(t,i)}}$.TwoPi=Math.PI*2;const fr=1/2.2,Yr=2.2,ke=.001;class At{static BuildArray(e,t){const i=[];for(let s=0;s<e;++s)i.push(t());return i}static BuildTuple(e,t){return At.BuildArray(e,t)}}function Jl(l,e,t){const i=l[e];if(typeof i!="function")return null;const s=function(){const r=l.length,n=s.previous.apply(l,arguments);return t(e,r),n};return i.next=s,s.previous=i,l[e]=s,()=>{const r=s.previous;if(!r)return;const n=s.next;n?(r.next=n,n.previous=r):(r.next=void 0,l[e]=r),s.next=void 0,s.previous=void 0}}const eh=["push","splice","pop","shift","unshift"];function ja(l,e){const t=eh.map(i=>Jl(l,i,e));return()=>{t.forEach(i=>{i==null||i()})}}const qa={};function Re(l,e){qa[l]=e}function Ri(l){return qa[l]}class ft{static SetMatrixPrecision(e){if(ft.MatrixTrackPrecisionChange=!1,e&&!ft.MatrixUse64Bits&&ft.MatrixTrackedMatrices)for(let t=0;t<ft.MatrixTrackedMatrices.length;++t){const i=ft.MatrixTrackedMatrices[t],s=i._m;i._m=new Array(16);for(let r=0;r<16;++r)i._m[r]=s[r]}ft.MatrixUse64Bits=e,ft.MatrixCurrentType=ft.MatrixUse64Bits?Array:Float32Array,ft.MatrixTrackedMatrices=null}}ft.MatrixUse64Bits=!1,ft.MatrixTrackPrecisionChange=!0,ft.MatrixCurrentType=Float32Array,ft.MatrixTrackedMatrices=[];class th{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 ih{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 B{static FromPromise(e,t){const i=new B;return e.then(s=>{i.notifyObservers(s)}).catch(s=>{if(t)t.notifyObservers(s);else throw s}),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 th(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const n=new ih(e,t,s);return n.unregisterOnNextCall=r,i?this._observers.unshift(n):this._observers.push(n),this._onObserverAdded&&this._onObserverAdded(n),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(n,this._lastNotifiedValue),n._remove=()=>{this.remove(n)},n}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return e?(e._remove=null,this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1):!1}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 i!==-1?(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0):!1}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 a of this._observers)if(!a._willBeUnregistered&&(a.mask&t&&(a.unregisterOnNextCall&&this._deferUnregister(a),a.scope?n.lastReturnValue=a.callback.apply(a.scope,[e,n]):n.lastReturnValue=a.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 B;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}}class Ee{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}Ee.Instances=new Array,Ee.OnEnginesDisposedObservable=new B,Ee._LastCreatedScene=null,Ee.UseFallbackTexture=!0,Ee.FallbackTexture="";const Gt=l=>parseInt(l.toString().replace(/\W/g,""));class ae{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){const e=Gt(this.x),t=Gt(this.y);let i=e;return i=i*397^t,i}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return ae.FromArrayToRef(e,t,this),this}asArray(){const e=new Array;return this.toArray(e,0),e}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)}add(e){return new this.constructor(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}addVector3(e){return new this.constructor(this.x+e.x,this.y+e.y)}subtract(e){return new this.constructor(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 this.constructor(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 this.constructor(this.x*e,this.y*t)}divide(e){return new this.constructor(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.divideToRef(e,this)}negate(){return new this.constructor(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.copyFromFloats(this.x*-1,this.y*-1)}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){const t=new this.constructor(0,0);return this.scaleToRef(e,t),t}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=ke){return e&&$.WithinEpsilon(this.x,e.x,t)&&$.WithinEpsilon(this.y,e.y,t)}floor(){return new this.constructor(Math.floor(this.x),Math.floor(this.y))}fract(){return new this.constructor(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}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 ae.NormalizeToRef(this,this),this}clone(){return new this.constructor(this.x,this.y)}static Zero(){return new ae(0,0)}static One(){return new ae(1,1)}static Random(e=0,t=1){return new ae($.RandomRange(e,t),$.RandomRange(e,t))}static get ZeroReadOnly(){return ae._ZeroReadOnly}static FromArray(e,t=0){return new ae(e[t],e[t+1])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],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 e.constructor(o,h)}static Clamp(e,t,i){let s=e.x;s=s>i.x?i.x:s,s=s<t.x?t.x:s;let r=e.y;return r=r>i.y?i.y:r,r=r<t.y?t.y:r,new e.constructor(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,c=a-2*n+r,u=a-n,f=e.x*o+i.x*h+t.x*c+s.x*u,d=e.y*o+i.y*h+t.y*c+s.y*u;return new e.constructor(f,d)}static Hermite1stDerivative(e,t,i,s,r){const n=new e.constructor;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=(a-r)*6*e.x+(3*a-4*r+1)*t.x+(-a+r)*6*i.x+(3*a-2*r)*s.x,n.y=(a-r)*6*e.y+(3*a-4*r+1)*t.y+(-a+r)*6*i.y+(3*a-2*r)*s.y,n}static Lerp(e,t,i){const s=e.x+(t.x-e.x)*i,r=e.y+(t.y-e.y)*i;return new e.constructor(s,r)}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){const t=new e.constructor;return this.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){const i=e.length();return i===0||(t.x=e.x/i,t.y=e.y/i),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 e.constructor(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 e.constructor(i,s)}static Transform(e,t){const i=new e.constructor;return ae.TransformToRef(e,t,i),i}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(ae.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){const i=new e.constructor;return ae.CenterToRef(e,t,i)}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=ae.DistanceSquared(t,i);if(s===0)return ae.Distance(e,t);const r=i.subtract(t),n=Math.max(0,Math.min(1,ae.Dot(e.subtract(t),r)/s)),a=t.add(r.multiplyByFloats(n,n));return ae.Distance(e,a)}}ae._ZeroReadOnly=ae.Zero();class E{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(){const e=Gt(this._x),t=Gt(this._y),i=Gt(this._z);let s=e;return s=s*397^t,s=s*397^i,s}asArray(){const e=[];return this.toArray(e,0),e}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 E.FromArrayToRef(e,t,this),this}toQuaternion(){return K.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this.addInPlaceFromFloats(e._x,e._y,e._z)}addInPlaceFromFloats(e,t,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this}add(e){return new this.constructor(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,t){return t.copyFromFloats(this._x+e._x,this._y+e._y,this._z+e._z)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new this.constructor(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 this.constructor(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,s){return s.copyFromFloats(this._x-e,this._y-t,this._z-i)}negate(){return new this.constructor(-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.copyFromFloats(this._x*-1,this._y*-1,this._z*-1)}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new this.constructor(this._x*e,this._y*e,this._z*e)}scaleToRef(e,t){return t.copyFromFloats(this._x*e,this._y*e,this._z*e)}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,c=2*(a*r-o*s),u=2*(o*i-n*r),f=2*(n*s-a*i);return t._x=i+h*c+a*f-o*u,t._y=s+h*u+o*c-n*f,t._z=r+h*f+n*u-a*c,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new this.constructor)}scaleAndAddToRef(e,t){return t.addInPlaceFromFloats(this._x*e,this._y*e,this._z*e)}projectOnPlane(e,t){const i=new this.constructor;return this.projectOnPlaneToRef(e,t,i),i}projectOnPlaneToRef(e,t,i){const s=e.normal,r=e.d,n=oe.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=E.Dot(n,s);if(Math.abs(a)<Math.pow(10,-10))i.setAll(1/0);else{const o=-(E.Dot(t,s)+r)/a,h=n.scaleInPlace(o);t.addToRef(h,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=ke){return e&&$.WithinEpsilon(this._x,e._x,t)&&$.WithinEpsilon(this._y,e._y,t)&&$.WithinEpsilon(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.copyFromFloats(this._x*e._x,this._y*e._y,this._z*e._z)}multiplyByFloats(e,t,i){return new this.constructor(this._x*e,this._y*t,this._z*i)}divide(e){return new this.constructor(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,t){return t.copyFromFloats(this._x/e._x,this._y/e._y,this._z/e._z)}divideInPlace(e){return this.divideToRef(e,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(!$.WithinEpsilon(t,i,e))return!0;const s=Math.abs(this._z);return!$.WithinEpsilon(t,s,e)||!$.WithinEpsilon(i,s,e)}get isNonUniform(){const e=Math.abs(this._x),t=Math.abs(this._y);if(e!==t)return!0;const i=Math.abs(this._z);return e!==i}floor(){return new this.constructor(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fract(){return new this.constructor(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}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){return e=e.toLowerCase(),e==="xyz"?this:(oe.Vector3[0].copyFrom(this),["x","y","z"].forEach((t,i)=>{this[t]=oe.Vector3[0][e[i]]}),this)}rotateByQuaternionToRef(e,t){return e.toRotationMatrix(oe.Matrix[0]),E.TransformCoordinatesToRef(this,oe.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,oe.Vector3[0]),oe.Vector3[0].rotateByQuaternionToRef(e,oe.Vector3[0]),t.addToRef(oe.Vector3[0],i),i}cross(e){const t=new this.constructor;return E.CrossToRef(this,e,t)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new this.constructor(0,0,0);return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return t===0||t===1?e.copyFromFloats(this._x,this._y,this._z):this.scaleToRef(1/t,e)}clone(){return new this.constructor(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=E.Dot(e,i)-s,n=E.Dot(t,i)-s;return r/(r-n)}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef(oe.Vector3[1]),r=t.normalizeToRef(oe.Vector3[2]);let n=E.Dot(s,r);n=$.Clamp(n,-1,1);const a=Math.acos(n),o=oe.Vector3[3];return E.CrossToRef(s,r,o),E.Dot(o,i)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,i){oe.Vector3[0].copyFrom(e);const s=oe.Vector3[0];oe.Vector3[1].copyFrom(t);const r=oe.Vector3[1];oe.Vector3[2].copyFrom(i);const n=oe.Vector3[2],a=oe.Vector3[3],o=oe.Vector3[4];s.normalize(),r.normalize(),n.normalize(),E.CrossToRef(n,s,a),E.CrossToRef(a,n,o);const h=Math.atan2(E.Dot(r,a),E.Dot(r,o));return $.NormalizeRadians(h)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=D.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=E.Zero();return E.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=$.Clamp(i,0,1);const r=oe.Vector3[0],n=oe.Vector3[1];r.copyFrom(e);const a=r.length();r.normalizeFromLength(a),n.copyFrom(t);const o=n.length();n.normalizeFromLength(o);const h=E.Dot(r,n);let c,u;if(h<1-ke){const f=Math.acos(h),d=1/Math.sin(f);c=Math.sin((1-i)*f)*d,u=Math.sin(i*f)*d}else c=1-i,u=i;return r.scaleInPlace(c),n.scaleInPlace(u),s.copyFrom(r).addInPlace(n),s.scaleInPlace($.Lerp(a,o,i)),s}static SmoothToRef(e,t,i,s,r){return E.SlerpToRef(e,t,s===0?1:i/s,r),r}static FromArray(e,t=0){return new E(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return E.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 E.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new E(0,0,0)}static One(){return new E(1,1,1)}static Up(){return new E(0,1,0)}static get UpReadOnly(){return E._UpReadOnly}static get DownReadOnly(){return E._DownReadOnly}static get RightReadOnly(){return E._RightReadOnly}static get LeftReadOnly(){return E._LeftReadOnly}static get LeftHandedForwardReadOnly(){return E._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return E._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return E._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return E._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return E._ZeroReadOnly}static get OneReadOnly(){return E._OneReadOnly}static Down(){return new E(0,-1,0)}static Forward(e=!1){return new E(0,0,e?-1:1)}static Backward(e=!1){return new E(0,0,e?1:-1)}static Right(){return new E(1,0,0)}static Left(){return new E(-1,0,0)}static Random(e=0,t=1){return new E($.RandomRange(e,t),$.RandomRange(e,t),$.RandomRange(e,t))}static TransformCoordinates(e,t){const i=E.Zero();return E.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return E.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],c=1/(e*n[3]+t*n[7]+i*n[11]+n[15]);return r._x=a*c,r._y=o*c,r._z=h*c,r._isDirty=!0,r}static TransformNormal(e,t){const i=E.Zero();return E.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),c=.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 e.constructor(o,h,c)}static Clamp(e,t,i){const s=new e.constructor;return E.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,c=a-2*n+r,u=a-n,f=e._x*o+i._x*h+t._x*c+s._x*u,d=e._y*o+i._y*h+t._y*c+s._y*u,_=e._z*o+i._z*h+t._z*c+s._z*u;return new e.constructor(f,d,_)}static Hermite1stDerivative(e,t,i,s,r){const n=new e.constructor;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=(a-r)*6*e._x+(3*a-4*r+1)*t._x+(-a+r)*6*i._x+(3*a-2*r)*s._x,n._y=(a-r)*6*e._y+(3*a-4*r+1)*t._y+(-a+r)*6*i._y+(3*a-2*r)*s._y,n._z=(a-r)*6*e._z+(3*a-4*r+1)*t._z+(-a+r)*6*i._z+(3*a-2*r)*s._z,n._isDirty=!0,n}static Lerp(e,t,i){const s=new e.constructor(0,0,0);return E.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}static Cross(e,t){const i=new e.constructor;return E.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=E.Zero();return E.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const r=new e.constructor;return E.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,c=oe.Matrix[1];M.FromValuesToRef(n/2,0,0,0,0,-a/2,0,0,0,0,.5,0,o+n/2,a/2+h,.5,1,c);const u=oe.Matrix[0];return t.multiplyToRef(i,u),u.multiplyToRef(c,u),E.TransformCoordinatesToRef(e,u,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new E)}static ReflectToRef(e,t,i){const s=D.Vector3[0];return s.copyFrom(t).scaleInPlace(2*E.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static _UnprojectFromInvertedMatrixToRef(e,t,i){E.TransformCoordinatesToRef(e,t,i);const s=t.m,r=e._x*s[3]+e._y*s[7]+e._z*s[11]+s[15];return $.WithinEpsilon(r,1)&&i.scaleInPlace(1/r),i}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,M.IdentityReadOnly)}static Unproject(e,t,i,s,r,n){const a=new e.constructor;return E.UnprojectToRef(e,t,i,s,r,n,a),a}static UnprojectToRef(e,t,i,s,r,n,a){return E.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){var c;const u=oe.Matrix[0];n.multiplyToRef(a,u),u.multiplyToRef(o,u),u.invert();const f=oe.Vector3[0];return f.x=e/s*2-1,f.y=-(t/r*2-1),!((c=Ee.LastCreatedEngine)===null||c===void 0)&&c.isNDCHalfZRange?f.z=i:f.z=2*i-1,E._UnprojectFromInvertedMatrixToRef(f,u,h),h}static Minimize(e,t){const i=new e.constructor;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new e.constructor;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(E.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=oe.Vector3[0],a=oe.Vector3[1],o=oe.Vector3[2],h=oe.Vector3[3],c=oe.Vector3[4];i.subtractToRef(t,n),s.subtractToRef(t,a),s.subtractToRef(i,o);const u=n.length(),f=a.length(),d=o.length();if(u<ke||f<ke||d<ke)return r.copyFrom(t),E.Distance(e,t);e.subtractToRef(t,c),E.CrossToRef(n,a,h);const _=h.length();if(_<ke)return r.copyFrom(t),E.Distance(e,t);h.normalizeFromLength(_);let p=c.length();if(p<ke)return r.copyFrom(t),0;c.normalizeFromLength(p);const m=E.Dot(h,c),T=oe.Vector3[5],S=oe.Vector3[6];T.copyFrom(h).scaleInPlace(-p*m),S.copyFrom(e).addInPlace(T);const x=oe.Vector3[4],b=oe.Vector3[5],I=oe.Vector3[7],R=oe.Vector3[8];x.copyFrom(n).scaleInPlace(1/u),R.copyFrom(a).scaleInPlace(1/f),x.addInPlace(R).scaleInPlace(-1),b.copyFrom(n).scaleInPlace(-1/u),R.copyFrom(o).scaleInPlace(1/d),b.addInPlace(R).scaleInPlace(-1),I.copyFrom(o).scaleInPlace(-1/d),R.copyFrom(a).scaleInPlace(-1/f),I.addInPlace(R).scaleInPlace(-1);const C=oe.Vector3[9];let y;C.copyFrom(S).subtractInPlace(t),E.CrossToRef(x,C,R),y=E.Dot(R,h);const w=y;C.copyFrom(S).subtractInPlace(i),E.CrossToRef(b,C,R),y=E.Dot(R,h);const G=y;C.copyFrom(S).subtractInPlace(s),E.CrossToRef(I,C,R),y=E.Dot(R,h);const te=y,Q=oe.Vector3[10];let Te,he;w>0&&G<0?(Q.copyFrom(n),Te=t,he=i):G>0&&te<0?(Q.copyFrom(o),Te=i,he=s):(Q.copyFrom(a).scaleInPlace(-1),Te=s,he=t);const ve=oe.Vector3[9],le=oe.Vector3[4];if(Te.subtractToRef(S,R),he.subtractToRef(S,ve),E.CrossToRef(R,ve,le),!(E.Dot(le,h)<0))return r.copyFrom(S),Math.abs(p*m);const ye=oe.Vector3[5];E.CrossToRef(Q,le,ye),ye.normalize();const Ye=oe.Vector3[9];Ye.copyFrom(Te).subtractInPlace(S);const et=Ye.length();if(et<ke)return r.copyFrom(Te),E.Distance(e,Te);Ye.normalizeFromLength(et);const Ne=E.Dot(ye,Ye),pt=oe.Vector3[7];pt.copyFrom(S).addInPlace(ye.scaleInPlace(et*Ne)),R.copyFrom(pt).subtractInPlace(Te),p=Q.length(),Q.normalizeFromLength(p);let Si=E.Dot(R,Q)/Math.max(p,ke);return Si=$.Clamp(Si,0,1),pt.copyFrom(Te).addInPlace(Q.scaleInPlace(Si*p)),r.copyFrom(pt),E.Distance(e,pt)}static Center(e,t){return E.CenterToRef(e,t,E.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 e.constructor;return E.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const r=oe.Quaternion[0];return K.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(s),s}}E._UpReadOnly=E.Up(),E._DownReadOnly=E.Down(),E._LeftHandedForwardReadOnly=E.Forward(!1),E._RightHandedForwardReadOnly=E.Forward(!0),E._LeftHandedBackwardReadOnly=E.Backward(!1),E._RightHandedBackwardReadOnly=E.Backward(!0),E._RightReadOnly=E.Right(),E._LeftReadOnly=E.Left(),E._ZeroReadOnly=E.Zero(),E._OneReadOnly=E.One();class He{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(){const e=Gt(this.x),t=Gt(this.y),i=Gt(this.z),s=Gt(this.w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}asArray(){const e=new Array;return this.toArray(e,0),e}toArray(e,t){return t===void 0&&(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 He.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}add(e){return new this.constructor(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 this.constructor(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 this.constructor(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 this.constructor(-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.copyFromFloats(this.x*-1,this.y*-1,this.z*-1,this.w*-1)}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new this.constructor(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=ke){return e&&$.WithinEpsilon(this.x,e.x,t)&&$.WithinEpsilon(this.y,e.y,t)&&$.WithinEpsilon(this.z,e.z,t)&&$.WithinEpsilon(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 this.constructor(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 this.constructor(this.x*e,this.y*t,this.z*i,this.w*s)}divide(e){return new this.constructor(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}floor(){return new this.constructor(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))}fract(){return new this.constructor(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(){const e=this.length();return e===0?this:this.scaleInPlace(1/e)}toVector3(){return new E(this.x,this.y,this.z)}clone(){return new this.constructor(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}static FromArray(e,t){return t||(t=0),new He(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 He.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 He(0,0,0,0)}static One(){return new He(1,1,1,1)}static Random(e=0,t=1){return new He($.RandomRange(e,t),$.RandomRange(e,t),$.RandomRange(e,t),$.RandomRange(e,t))}static get ZeroReadOnly(){return He._ZeroReadOnly}static Normalize(e){const t=He.Zero();return He.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return t.copyFrom(e),t.normalize(),t}static Minimize(e,t){const i=new e.constructor;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new e.constructor;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(He.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 He.CenterToRef(e,t,He.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)}static TransformCoordinates(e,t){const i=He.Zero();return He.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return He.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],c=e*n[3]+t*n[7]+i*n[11]+n[15];return r.x=a,r.y=o,r.z=h,r.w=c,r}static TransformNormal(e,t){const i=new e.constructor;return He.TransformNormalToRef(e,t,i),i}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 He(e._x,e._y,e._z,t)}}He._ZeroReadOnly=He.Zero();class K{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(){const e=Gt(this._x),t=Gt(this._y),i=Gt(this._z),s=Gt(this._w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}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}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,t=ke){return e&&$.WithinEpsilon(this._x,e._x,t)&&$.WithinEpsilon(this._y,e._y,t)&&$.WithinEpsilon(this._z,e._z,t)&&$.WithinEpsilon(this._w,e._w,t)}clone(){return new this.constructor(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)}add(e){return new this.constructor(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}subtract(e){return new this.constructor(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 this.constructor(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 this.constructor(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),this}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 this.constructor(-this._x,-this._y,-this._z,this._w)}invert(){const e=this.conjugate(),t=this.lengthSquared();return t==0||t==1||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();const e=this.lengthSquared();return e==0||e==1?this:(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(){const e=this.length();if(e===0)return this;const t=1/e;return this.scaleInPlace(t),this}normalizeToNew(){const e=this.length();if(e===0)return this.clone();const t=1/e;return this.scale(t)}toEulerAngles(){const e=E.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 o=r*r,h=t*t,c=i*i,u=s*s;e._z=Math.atan2(2*(i*s+t*r),-h-c+u+o),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*i+s*r),h-c-u+o),e._isDirty=!0}return e}toRotationMatrix(e){return M.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return K.FromRotationMatrixToRef(e,this),this}static FromRotationMatrix(e){const t=new K;return K.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],c=i[2],u=i[6],f=i[10],d=s+o+f;let _;return d>0?(_=.5/Math.sqrt(d+1),t._w=.25/_,t._x=(u-h)*_,t._y=(n-c)*_,t._z=(a-r)*_,t._isDirty=!0):s>o&&s>f?(_=2*Math.sqrt(1+s-o-f),t._w=(u-h)/_,t._x=.25*_,t._y=(r+a)/_,t._z=(n+c)/_,t._isDirty=!0):o>f?(_=2*Math.sqrt(1+o-s-f),t._w=(n-c)/_,t._x=(r+a)/_,t._y=.25*_,t._z=(h+u)/_,t._isDirty=!0):(_=2*Math.sqrt(1+f-s-o),t._w=(a-r)/_,t._x=(n+c)/_,t._y=(h+u)/_,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=K.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let n=s===0?1:i/s;return n=$.Clamp(n,0,1),K.SlerpToRef(e,t,n,r),r}static Zero(){return new K(0,0,0,0)}static Inverse(e){return new e.constructor(-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 K(0,0,0,1)}static IsIdentity(e){return e&&e._x===0&&e._y===0&&e._z===0&&e._w===1}static RotationAxis(e,t){return K.RotationAxisToRef(e,t,new K)}static RotationAxisToRef(e,t,i){const s=Math.sin(t/2);return e.normalize(),i._w=Math.cos(t/2),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 K(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 FromEulerAngles(e,t,i){const s=new K;return K.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return K.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new K;return K.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return K.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=ke){const r=E.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):(E.CrossToRef(e,t,D.Vector3[0]),i.set(D.Vector3[0].x,D.Vector3[0].y,D.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new K;return K.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const r=i*.5,n=t*.5,a=e*.5,o=Math.sin(r),h=Math.cos(r),c=Math.sin(n),u=Math.cos(n),f=Math.sin(a),d=Math.cos(a);return s._x=d*c*h+f*u*o,s._y=f*u*h-d*c*o,s._z=d*u*o-f*c*h,s._w=d*u*h+f*c*o,s._isDirty=!0,s}static RotationAlphaBetaGamma(e,t,i){const s=new K;return K.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const r=(i+e)*.5,n=(i-e)*.5,a=t*.5;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 K(0,0,0,0);return K.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=oe.Matrix[0];return M.FromXYZAxesToRef(e.normalize(),t.normalize(),i.normalize(),r),K.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new K;return K.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=oe.Matrix[0];return M.LookDirectionLHToRef(e,t,s),K.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new K;return K.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=oe.Matrix[0];return M.LookDirectionRHToRef(e,t,s),K.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=K.Identity();return K.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 h=Math.acos(a),c=1/Math.sin(h);n=Math.sin((1-i)*h)*c,r=o?-Math.sin(i*h)*c:Math.sin(i*h)*c}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,c=a-2*n+r,u=a-n,f=e._x*o+i._x*h+t._x*c+s._x*u,d=e._y*o+i._y*h+t._y*c+s._y*u,_=e._z*o+i._z*h+t._z*c+s._z*u,p=e._w*o+i._w*h+t._w*c+s._w*u;return new e.constructor(f,d,_,p)}static Hermite1stDerivative(e,t,i,s,r){const n=new e.constructor;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=(a-r)*6*e._x+(3*a-4*r+1)*t._x+(-a+r)*6*i._x+(3*a-2*r)*s._x,n._y=(a-r)*6*e._y+(3*a-4*r+1)*t._y+(-a+r)*6*i._y+(3*a-2*r)*s._y,n._z=(a-r)*6*e._z+(3*a-4*r+1)*t._z+(-a+r)*6*i._z+(3*a-2*r)*s._z,n._w=(a-r)*6*e._w+(3*a-4*r+1)*t._w+(-a+r)*6*i._w+(3*a-2*r)*s._w,n._isDirty=!0,n}}class M{static get Use64Bits(){return ft.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=M._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?!1:t,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:s}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,ft.MatrixTrackPrecisionChange&&ft.MatrixTrackedMatrices.push(this),this._m=new ft.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;const e=this._m;this._isIdentity=e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1?this._isIdentity3x2=!1: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]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(this._isIdentity===!0)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],c=e[8],u=e[9],f=e[10],d=e[11],_=e[12],p=e[13],m=e[14],T=e[15],S=f*T-m*d,x=u*T-p*d,b=u*m-p*f,I=c*T-_*d,R=c*m-f*_,C=c*p-_*u,y=+(a*S-o*x+h*b),w=-(n*S-o*I+h*R),G=+(n*x-a*I+h*C),te=-(n*b-a*R+o*C);return t*y+i*w+s*G+r*te}toArray(){return this._m}asArray(){return this._m}invert(){return this.invertToRef(this),this}reset(){return M.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 this.constructor;return this.addToRef(e,t),t}addToRef(e,t){const i=this._m,s=t._m,r=e.m;for(let n=0;n<16;n++)s[n]=i[n]+r[n];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]+=i[s];return this.markAsUpdated(),this}invertToRef(e){if(this._isIdentity===!0)return M.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],c=t[7],u=t[8],f=t[9],d=t[10],_=t[11],p=t[12],m=t[13],T=t[14],S=t[15],x=d*S-T*_,b=f*S-m*_,I=f*T-m*d,R=u*S-p*_,C=u*T-d*p,y=u*m-p*f,w=+(o*x-h*b+c*I),G=-(a*x-h*R+c*C),te=+(a*b-o*R+c*y),Q=-(a*I-o*C+h*y),Te=i*w+s*G+r*te+n*Q;if(Te===0)return e.copyFrom(this),e;const he=1/Te,ve=h*S-T*c,le=o*S-m*c,be=o*T-m*h,ye=a*S-p*c,Ye=a*T-p*h,et=a*m-p*o,Ne=h*_-d*c,pt=o*_-f*c,Si=o*d-f*h,Os=a*_-u*c,ur=a*d-u*h,ot=a*f-u*o,Ds=-(s*x-r*b+n*I),Ls=+(i*x-r*R+n*C),Ns=-(i*b-s*R+n*y),Fs=+(i*I-s*C+r*y),za=+(s*ve-r*le+n*be),Xa=-(i*ve-r*ye+n*Ye),qi=+(i*le-s*ye+n*et),Zi=-(i*be-s*Ye+r*et),Qi=-(s*Ne-r*pt+n*Si),$i=+(i*Ne-r*Os+n*ur),lT=-(i*pt-s*Os+n*ot),hT=+(i*Si-s*ur+r*ot);return M.FromValuesToRef(w*he,Ds*he,za*he,Qi*he,G*he,Ls*he,Xa*he,$i*he,te*he,Ns*he,qi*he,lT*he,Q*he,Fs*he,Zi*he,hT*he,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 E(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 M.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),this}multiply(e){const t=new this.constructor;return this.multiplyToRef(e,t),t}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}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],c=s[4],u=s[5],f=s[6],d=s[7],_=s[8],p=s[9],m=s[10],T=s[11],S=s[12],x=s[13],b=s[14],I=s[15],R=r[0],C=r[1],y=r[2],w=r[3],G=r[4],te=r[5],Q=r[6],Te=r[7],he=r[8],ve=r[9],le=r[10],be=r[11],ye=r[12],Ye=r[13],et=r[14],Ne=r[15];return t[i]=n*R+a*G+o*he+h*ye,t[i+1]=n*C+a*te+o*ve+h*Ye,t[i+2]=n*y+a*Q+o*le+h*et,t[i+3]=n*w+a*Te+o*be+h*Ne,t[i+4]=c*R+u*G+f*he+d*ye,t[i+5]=c*C+u*te+f*ve+d*Ye,t[i+6]=c*y+u*Q+f*le+d*et,t[i+7]=c*w+u*Te+f*be+d*Ne,t[i+8]=_*R+p*G+m*he+T*ye,t[i+9]=_*C+p*te+m*ve+T*Ye,t[i+10]=_*y+p*Q+m*le+T*et,t[i+11]=_*w+p*Te+m*be+T*Ne,t[i+12]=S*R+x*G+b*he+I*ye,t[i+13]=S*C+x*te+b*ve+I*Ye,t[i+14]=S*y+x*Q+b*le+I*et,t[i+15]=S*w+x*Te+b*be+I*Ne,this}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]}clone(){const e=new this.constructor;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=Gt(this._m[0]);for(let t=1;t<16;t++)e=e*397^Gt(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new K,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,s){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const r=this._m;if(i&&i.copyFromFloats(r[12],r[13],r[14]),e=e||oe.Vector3[0],e.x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),e.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),e.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),s){const n=s.scaling.x<0?-1:1,a=s.scaling.y<0?-1:1,o=s.scaling.z<0?-1:1;e.x*=n,e.y*=a,e.z*=o}else this.determinant()<=0&&(e.y*=-1);if(e._x===0||e._y===0||e._z===0)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const n=1/e._x,a=1/e._y,o=1/e._z;M.FromValuesToRef(r[0]*n,r[1]*n,r[2]*n,0,r[4]*a,r[5]*a,r[6]*a,0,r[8]*o,r[9]*o,r[10]*o,0,0,0,0,1,oe.Matrix[0]),K.FromRotationMatrixToRef(oe.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=e*4;return new He(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=e*4;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 this.constructor;return M.TransposeToRef(this,e),e}transposeToRef(e){return M.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,s,r){if(e<0||e>3)return this;const n=e*4;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 this.constructor;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}toNormalMatrix(e){const t=oe.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return M.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 this.constructor;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=oe.Vector3[0];if(!this.decompose(t))return M.IdentityToRef(e),e;const i=this._m,s=1/t._x,r=1/t._y,n=1/t._z;return M.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 M;return M.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){for(let r=0;r<16;r++)s._m[r]=e[r+t]*i;return s.markAsUpdated(),s}static get IdentityReadOnly(){return M._IdentityReadOnly}static FromValuesToRef(e,t,i,s,r,n,a,o,h,c,u,f,d,_,p,m,T){const S=T._m;S[0]=e,S[1]=t,S[2]=i,S[3]=s,S[4]=r,S[5]=n,S[6]=a,S[7]=o,S[8]=h,S[9]=c,S[10]=u,S[11]=f,S[12]=d,S[13]=_,S[14]=p,S[15]=m,T.markAsUpdated()}static FromValues(e,t,i,s,r,n,a,o,h,c,u,f,d,_,p,m){const T=new M,S=T._m;return S[0]=e,S[1]=t,S[2]=i,S[3]=s,S[4]=r,S[5]=n,S[6]=a,S[7]=o,S[8]=h,S[9]=c,S[10]=u,S[11]=f,S[12]=d,S[13]=_,S[14]=p,S[15]=m,T.markAsUpdated(),T}static Compose(e,t,i){const s=new M;return M.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,c=n+n,u=a+a,f=o+o,d=n*c,_=n*u,p=n*f,m=a*u,T=a*f,S=o*f,x=h*c,b=h*u,I=h*f,R=e._x,C=e._y,y=e._z;return r[0]=(1-(m+S))*R,r[1]=(_+I)*R,r[2]=(p-b)*R,r[3]=0,r[4]=(_-I)*C,r[5]=(1-(d+S))*C,r[6]=(T+x)*C,r[7]=0,r[8]=(p+b)*y,r[9]=(T-x)*y,r[10]=(1-(d+m))*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=M.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 M.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=M.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 M;return M.RotationXToRef(e,t),t}static Invert(e){const t=new e.constructor;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.FromValuesToRef(1,0,0,0,0,s,i,0,0,-i,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationY(e){const t=new M;return M.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.FromValuesToRef(s,0,-i,0,0,1,0,0,i,0,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationZ(e){const t=new M;return M.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.FromValuesToRef(s,i,0,0,-i,s,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationAxis(e,t){const i=new M;return M.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){const s=Math.sin(-t),r=Math.cos(-t),n=1-r;e.normalize();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){const s=E.Dot(t,e),r=i._m;if(s<-1+ke)r[0]=-1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0;else{const n=E.Cross(t,e),a=1/(1+s);r[0]=n._x*n._x*a+s,r[1]=n._y*n._x*a-n._z,r[2]=n._z*n._x*a+n._y,r[3]=0,r[4]=n._x*n._y*a+n._z,r[5]=n._y*n._y*a+s,r[6]=n._z*n._y*a-n._x,r[7]=0,r[8]=n._x*n._z*a-n._y,r[9]=n._y*n._z*a+n._x,r[10]=n._z*n._z*a+s,r[11]=0}return r[12]=0,r[13]=0,r[14]=0,r[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){const s=new M;return M.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return K.RotationYawPitchRollToRef(e,t,i,oe.Quaternion[0]),oe.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new M;return M.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return M.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,s),s._updateIdentityStatus(e===1&&t===1&&i===1),s}static Translation(e,t,i){const s=new M;return M.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return M.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,s),s._updateIdentityStatus(e===0&&t===0&&i===0),s}static Lerp(e,t,i){const s=new e.constructor;return M.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){const r=s._m,n=e.m,a=t.m;for(let o=0;o<16;o++)r[o]=n[o]*(1-i)+a[o]*i;return s.markAsUpdated(),s}static DecomposeLerp(e,t,i){const s=new e.constructor;return M.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const r=oe.Vector3[0],n=oe.Quaternion[0],a=oe.Vector3[1];e.decompose(r,n,a);const o=oe.Vector3[2],h=oe.Quaternion[1],c=oe.Vector3[3];t.decompose(o,h,c);const u=oe.Vector3[4];E.LerpToRef(r,o,i,u);const f=oe.Quaternion[2];K.SlerpToRef(n,h,i,f);const d=oe.Vector3[5];return E.LerpToRef(a,c,i,d),M.ComposeToRef(u,f,d,s),s}static LookAtLH(e,t,i){const s=new M;return M.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const r=oe.Vector3[0],n=oe.Vector3[1],a=oe.Vector3[2];t.subtractToRef(e,a),a.normalize(),E.CrossToRef(i,a,r);const o=r.lengthSquared();o===0?r.x=1:r.normalizeFromLength(Math.sqrt(o)),E.CrossToRef(a,r,n),n.normalize();const h=-E.Dot(r,e),c=-E.Dot(n,e),u=-E.Dot(a,e);M.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,c,u,1,s)}static LookAtRH(e,t,i){const s=new M;return M.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const r=oe.Vector3[0],n=oe.Vector3[1],a=oe.Vector3[2];e.subtractToRef(t,a),a.normalize(),E.CrossToRef(i,a,r);const o=r.lengthSquared();o===0?r.x=1:r.normalizeFromLength(Math.sqrt(o)),E.CrossToRef(a,r,n),n.normalize();const h=-E.Dot(r,e),c=-E.Dot(n,e),u=-E.Dot(a,e);return M.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,c,u,1,s),s}static LookDirectionLH(e,t){const i=new M;return M.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=oe.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const r=oe.Vector3[1];return E.CrossToRef(t,s,r),M.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 M;return M.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=oe.Vector3[2];return E.CrossToRef(t,e,s),M.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 M;return M.OrthoLHToRef(e,t,i,s,n,r),n}static OrthoLHToRef(e,t,i,s,r,n){const a=i,o=s,h=2/e,c=2/t,u=2/(o-a),f=-(o+a)/(o-a);return M.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,u,0,0,0,f,1,r),n&&r.multiplyToRef(es,r),r._updateIdentityStatus(h===1&&c===1&&u===1&&f===0),r}static OrthoOffCenterLH(e,t,i,s,r,n,a){const o=new M;return M.OrthoOffCenterLHToRef(e,t,i,s,r,n,o,a),o}static OrthoOffCenterLHToRef(e,t,i,s,r,n,a,o){const h=r,c=n,u=2/(t-e),f=2/(s-i),d=2/(c-h),_=-(c+h)/(c-h),p=(e+t)/(e-t),m=(s+i)/(i-s);return M.FromValuesToRef(u,0,0,0,0,f,0,0,0,0,d,0,p,m,_,1,a),o&&a.multiplyToRef(es,a),a.markAsUpdated(),a}static OrthoOffCenterRH(e,t,i,s,r,n,a){const o=new M;return M.OrthoOffCenterRHToRef(e,t,i,s,r,n,o,a),o}static OrthoOffCenterRHToRef(e,t,i,s,r,n,a,o){return M.OrthoOffCenterLHToRef(e,t,i,s,r,n,a,o),a._m[10]*=-1,a}static PerspectiveLH(e,t,i,s,r,n=0){const a=new M,o=i,h=s,c=2*o/e,u=2*o/t,f=(h+o)/(h-o),d=-2*h*o/(h-o),_=Math.tan(n);return M.FromValuesToRef(c,0,0,0,0,u,0,_,0,0,f,1,0,0,d,0,a),r&&a.multiplyToRef(es,a),a._updateIdentityStatus(!1),a}static PerspectiveFovLH(e,t,i,s,r,n=0,a=!1){const o=new M;return M.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 c=i,u=s,f=1/Math.tan(e*.5),d=n?f/t:f,_=n?f:f*t,p=h&&c===0?-1:u!==0?(u+c)/(u-c):1,m=h&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,T=Math.tan(o);return M.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,1,0,0,m,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,i,s,r,n=!0,a,o=0){const h=1/Math.tan(e*.5),c=n?h/t:h,u=n?h:h*t,f=Math.tan(o);return M.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,1,0,0,1,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,i,s,r,n=0,a=!1){const o=new M;return M.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 c=i,u=s,f=1/Math.tan(e*.5),d=n?f/t:f,_=n?f:f*t,p=h&&c===0?1:u!==0?-(u+c)/(u-c):-1,m=h&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,T=Math.tan(o);return M.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,-1,0,0,m,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,i,s,r,n=!0,a,o=0){const h=1/Math.tan(e*.5),c=n?h/t:h,u=n?h:h*t,f=Math.tan(o);return M.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,-1,0,0,-1,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovWebVRToRef(e,t,i,s,r=!1,n,a=0){const o=r?-1:1,h=Math.tan(e.upDegrees*Math.PI/180),c=Math.tan(e.downDegrees*Math.PI/180),u=Math.tan(e.leftDegrees*Math.PI/180),f=Math.tan(e.rightDegrees*Math.PI/180),d=2/(u+f),_=2/(h+c),p=Math.tan(a),m=s._m;return m[0]=d,m[1]=m[2]=m[3]=m[4]=0,m[5]=_,m[6]=0,m[7]=p,m[8]=(u-f)*d*.5,m[9]=-((h-c)*_*.5),m[10]=-i/(t-i),m[11]=1*o,m[12]=m[13]=m[15]=0,m[14]=-(2*i*t)/(i-t),n&&s.multiplyToRef(es,s),s.markAsUpdated(),s}static GetFinalMatrix(e,t,i,s,r,n){const a=e.width,o=e.height,h=e.x,c=e.y,u=M.FromValues(a/2,0,0,0,0,-o/2,0,0,0,0,n-r,0,h+a/2,o/2+c,r,1),f=new t.constructor;return t.multiplyToRef(i,f),f.multiplyToRef(s,f),f.multiplyToRef(u,f)}static GetAsMatrix2x2(e){const t=e.m,i=[t[0],t[1],t[4],t[5]];return ft.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 ft.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new e.constructor;return M.TransposeToRef(e,t),t}static TransposeToRef(e,t){const i=t._m,s=e.m;return i[0]=s[0],i[1]=s[4],i[2]=s[8],i[3]=s[12],i[4]=s[1],i[5]=s[5],i[6]=s[9],i[7]=s[13],i[8]=s[2],i[9]=s[6],i[10]=s[10],i[11]=s[14],i[12]=s[3],i[13]=s[7],i[14]=s[11],i[15]=s[15],t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new M;return M.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 M.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 M.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,c=e._y*e._z,u=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*(c+u),t._m[7]=0,t._m[8]=2*(o+h),t._m[9]=2*(c-u),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}}M._UpdateFlagSeed=0,M._IdentityReadOnly=M.Identity();class oe{}oe.Vector3=At.BuildTuple(11,E.Zero),oe.Matrix=At.BuildTuple(2,M.Identity),oe.Quaternion=At.BuildTuple(3,K.Zero);class D{}D.Vector2=At.BuildTuple(3,ae.Zero),D.Vector3=At.BuildTuple(13,E.Zero),D.Vector4=At.BuildTuple(3,He.Zero),D.Quaternion=At.BuildTuple(2,K.Zero),D.Matrix=At.BuildTuple(8,M.Identity),Re("BABYLON.Vector2",ae),Re("BABYLON.Vector3",E),Re("BABYLON.Vector4",He),Re("BABYLON.Matrix",M);const es=M.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function fe(l){return`${l} needs to be imported before as it contains a side-effect required by your code.`}function ws(l){return Math.pow(l,Yr)}function Bs(l){return l<=.04045?.0773993808*l:Math.pow(.947867299*(l+.055),2.4)}function Us(l){return Math.pow(l,fr)}function Vs(l){return l<=.0031308?12.92*l:1.055*Math.pow(l,.41666)-.055}class z{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=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),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 z.FromArrayToRef(e,t,this),this}toColor4(e=1){return new ge(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return this.r*.3+this.g*.59+this.b*.11}multiply(e){return new z(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,this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,i){return this.r===e&&this.g===t&&this.b===i}scale(e){return new z(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,this}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this}clampToRef(e=0,t=1,i){return i.r=$.Clamp(this.r,e,t),i.g=$.Clamp(this.g,e,t),i.b=$.Clamp(this.b,e,t),this}add(e){return new z(this.r+e.r,this.g+e.g,this.b+e.b)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this}subtract(e){return new z(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,this}clone(){return new z(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)}toHexString(){const e=Math.round(this.r*255),t=Math.round(this.g*255),i=Math.round(this.b*255);return"#"+$.ToHex(e)+$.ToHex(t)+$.ToHex(i)}toHSV(){const e=new z;return this.toHSVToRef(e),e}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,c=r-n;r!==0&&(o=c/r),r!=n&&(r==t?(a=(i-s)/c,i<s&&(a+=6)):r==i?a=(s-t)/c+2:r==s&&(a=(t-i)/c+4),a*=60),e.r=a,e.g=o,e.b=h}toLinearSpace(e=!1){const t=new z;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=Bs(this.r),e.g=Bs(this.g),e.b=Bs(this.b)):(e.r=ws(this.r),e.g=ws(this.g),e.b=ws(this.b)),this}toGammaSpace(e=!1){const t=new z;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=Vs(this.r),e.g=Vs(this.g),e.b=Vs(this.b)):(e.r=Us(this.r),e.g=Us(this.g),e.b=Us(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,c=0;n>=0&&n<=1?(o=r,h=a):n>=1&&n<=2?(o=a,h=r):n>=2&&n<=3?(h=r,c=a):n>=3&&n<=4?(h=a,c=r):n>=4&&n<=5?(o=a,c=r):n>=5&&n<=6&&(o=r,c=a);const u=i-r;s.set(o+u,h+u,c+u)}static FromHSV(e,t,i){const s=new z(0,0,0);return z.HSVtoRGBToRef(e,t,i,s),s}static FromHexString(e){if(e.substring(0,1)!=="#"||e.length!==7)return new z(0,0,0);const t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),s=parseInt(e.substring(5,7),16);return z.FromInts(t,i,s)}static FromArray(e,t=0){return new z(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 z(e/255,t/255,i/255)}static Lerp(e,t,i){const s=new z(0,0,0);return z.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,c=a-2*n+r,u=a-n,f=e.r*o+i.r*h+t.r*c+s.r*u,d=e.g*o+i.g*h+t.g*c+s.g*u,_=e.b*o+i.b*h+t.b*c+s.b*u;return new z(f,d,_)}static Hermite1stDerivative(e,t,i,s,r){const n=z.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=(a-r)*6*e.r+(3*a-4*r+1)*t.r+(-a+r)*6*i.r+(3*a-2*r)*s.r,n.g=(a-r)*6*e.g+(3*a-4*r+1)*t.g+(-a+r)*6*i.g+(3*a-2*r)*s.g,n.b=(a-r)*6*e.b+(3*a-4*r+1)*t.b+(-a+r)*6*i.b+(3*a-2*r)*s.b}static Red(){return new z(1,0,0)}static Green(){return new z(0,1,0)}static Blue(){return new z(0,0,1)}static Black(){return new z(0,0,0)}static get BlackReadOnly(){return z._BlackReadOnly}static White(){return new z(1,1,1)}static Purple(){return new z(.5,0,.5)}static Magenta(){return new z(1,0,1)}static Yellow(){return new z(1,1,0)}static Gray(){return new z(.5,.5,.5)}static Teal(){return new z(0,1,1)}static Random(){return new z(Math.random(),Math.random(),Math.random())}}z._BlackReadOnly=z.Black();class ge{constructor(e=0,t=0,i=0,s=1){this.r=e,this.g=t,this.b=i,this.a=s}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}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 ge.FromArrayToRef(e,t,this),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 ge(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}subtract(e){return new ge(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,this}scale(e){return new ge(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,this}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,this}clampToRef(e=0,t=1,i){return i.r=$.Clamp(this.r,e,t),i.g=$.Clamp(this.g,e,t),i.b=$.Clamp(this.b,e,t),i.a=$.Clamp(this.a,e,t),this}multiply(e){return new ge(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}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),e=e*397^(this.a*255|0),e}clone(){return new ge(this.r,this.g,this.b,this.a)}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)}toHexString(e=!1){const t=Math.round(this.r*255),i=Math.round(this.g*255),s=Math.round(this.b*255);if(e)return"#"+$.ToHex(t)+$.ToHex(i)+$.ToHex(s);const r=Math.round(this.a*255);return"#"+$.ToHex(t)+$.ToHex(i)+$.ToHex(s)+$.ToHex(r)}toLinearSpace(e=!1){const t=new ge;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=Bs(this.r),e.g=Bs(this.g),e.b=Bs(this.b)):(e.r=ws(this.r),e.g=ws(this.g),e.b=ws(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new ge;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=Vs(this.r),e.g=Vs(this.g),e.b=Vs(this.b)):(e.r=Us(this.r),e.g=Us(this.g),e.b=Us(this.b)),e.a=this.a,this}static FromHexString(e){if(e.substring(0,1)!=="#"||e.length!==9&&e.length!==7)return new ge(0,0,0,0);const t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),s=parseInt(e.substring(5,7),16),r=e.length===9?parseInt(e.substring(7,9),16):255;return ge.FromInts(t,i,s,r)}static Lerp(e,t,i){const s=new ge(0,0,0,0);return ge.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,s.a=e.a+(t.a-e.a)*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,c=a-2*n+r,u=a-n,f=e.r*o+i.r*h+t.r*c+s.r*u,d=e.g*o+i.g*h+t.g*c+s.g*u,_=e.b*o+i.b*h+t.b*c+s.b*u,p=e.a*o+i.a*h+t.a*c+s.a*u;return new ge(f,d,_,p)}static Hermite1stDerivative(e,t,i,s,r){const n=new ge;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;n.r=(a-r)*6*e.r+(3*a-4*r+1)*t.r+(-a+r)*6*i.r+(3*a-2*r)*s.r,n.g=(a-r)*6*e.g+(3*a-4*r+1)*t.g+(-a+r)*6*i.g+(3*a-2*r)*s.g,n.b=(a-r)*6*e.b+(3*a-4*r+1)*t.b+(-a+r)*6*i.b+(3*a-2*r)*s.b,n.a=(a-r)*6*e.a+(3*a-4*r+1)*t.a+(-a+r)*6*i.a+(3*a-2*r)*s.a}static FromColor3(e,t=1){return new ge(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new ge(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 ge(e/255,t/255,i/255,s/255)}static CheckColors4(e,t){if(e.length===t*3){const i=[];for(let s=0;s<e.length;s+=3){const r=s/3*4;i[r]=e[s],i[r+1]=e[s+1],i[r+2]=e[s+2],i[r+3]=1}return i}return e}}class pi{}pi.Color3=At.BuildArray(3,z.Black),pi.Color4=At.BuildArray(3,()=>new ge(0,0,0,0)),Re("BABYLON.Color3",z),Re("BABYLON.Color4",ge);const Kr={},jr={},Za=function(l,e,t,i={}){const s=l();xe&&xe.HasTags(e)&&xe.AddTagsTo(s,xe.GetTags(e,!0));const r=Sn(s),n={};for(const a in r){const o=r[a],h=e[a],c=o.type;if(h!=null&&(a!=="uniqueId"||J.AllowLoadingUniqueId))switch(c){case 0:case 6:case 11:s[a]=h;break;case 1:i.cloneTexturesOnlyOnce&&n[h.uniqueId]?s[a]=n[h.uniqueId]:(s[a]=t||h.isRenderTarget?h:h.clone(),n[h.uniqueId]=s[a]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:s[a]=t?h:h.clone();break}}return s};function sh(l){const e=l.getClassName();return Kr[e]||(Kr[e]={}),Kr[e]}function Sn(l){const e=l.getClassName();if(jr[e])return jr[e];jr[e]={};const t=jr[e];let i=l,s=e;for(;s;){const r=Kr[s];for(const o in r)t[o]=r[o];let n,a=!1;do{if(n=Object.getPrototypeOf(i),!n.getClassName){a=!0;break}if(n.getClassName()!==s)break;i=n}while(n);if(a)break;s=n.getClassName(),i=n}return t}function ti(l,e){return(t,i)=>{const s=sh(t);s[i]||(s[i]={type:l,sourceName:e})}}function rh(l,e=null){return(t,i)=>{const s=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[s]},set:function(r){typeof this.equals=="function"&&this.equals(r)||this[s]!==r&&(this[s]=r,t[l].apply(this))},enumerable:!0,configurable:!0})}}function W(l,e=null){return rh(l,e)}function v(l){return ti(0,l)}function Me(l){return ti(1,l)}function Ft(l){return ti(2,l)}function dr(l){return ti(3,l)}function Rn(l){return ti(4,l)}function Ut(l){return ti(5,l)}function xn(l){return ti(6,l)}function nh(l){return ti(7,l)}function Cn(l){return ti(8,l)}function ah(l){return ti(9,l)}function oh(l){return ti(10,l)}function Qa(l){return ti(12,l)}function lh(l){return ti(11,l)}class J{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={}),xe&&(t.tags=xe.GetTags(e));const i=Sn(e);for(const s in i){const r=i[s],n=r.sourceName||s,a=r.type,o=e[s];if(o!=null&&(s!=="uniqueId"||J.AllowLoadingUniqueId))switch(a){case 0:t[n]=o;break;case 1:t[n]=o.serialize();break;case 2:t[n]=o.asArray();break;case 3:t[n]=o.serialize();break;case 4:t[n]=o.asArray();break;case 5:t[n]=o.asArray();break;case 6:t[n]=o.id;break;case 7:t[n]=o.serialize();break;case 8:t[n]=o.asArray();break;case 9:t[n]=o.serialize();break;case 10:t[n]=o.asArray();break;case 11:t[n]=o.id;break;case 12:t[n]=o.asArray();break}}return t}static ParseProperties(e,t,i,s){s||(s="");const r=Sn(t);for(const n in r){const a=r[n],o=e[a.sourceName||n],h=a.type;if(o!=null&&(n!=="uniqueId"||J.AllowLoadingUniqueId)){const c=t;switch(h){case 0:c[n]=o;break;case 1:i&&(c[n]=J._TextureParser(o,i,s));break;case 2:c[n]=z.FromArray(o);break;case 3:c[n]=J._FresnelParametersParser(o);break;case 4:c[n]=ae.FromArray(o);break;case 5:c[n]=E.FromArray(o);break;case 6:i&&(c[n]=i.getLastMeshById(o));break;case 7:c[n]=J._ColorCurvesParser(o);break;case 8:c[n]=ge.FromArray(o);break;case 9:c[n]=J._ImageProcessingConfigurationParser(o);break;case 10:c[n]=K.FromArray(o);break;case 11:i&&(c[n]=i.getCameraById(o));break;case 12:c[n]=M.FromArray(o);break}}}}static Parse(e,t,i,s=null){const r=e();return xe&&xe.AddTagsTo(r,t.tags),J.ParseProperties(t,r,i,s),r}static Clone(e,t,i={}){return Za(e,t,!1,i)}static Instanciate(e,t){return Za(e,t,!0)}}J.AllowLoadingUniqueId=!1,J._ImageProcessingConfigurationParser=l=>{throw fe("ImageProcessingConfiguration")},J._FresnelParametersParser=l=>{throw fe("FresnelParameters")},J._ColorCurvesParser=l=>{throw fe("ColorCurves")},J._TextureParser=(l,e,t)=>{throw fe("Texture")};function ts(l,e,t,i){const s=t.value;t.value=(...r)=>{let n=s;if(typeof _native<"u"&&_native[e]){const a=_native[e];i?n=(...o)=>i(...o)?a(...o):s(...o):n=a}return l[e]=n,n(...r)}}ts.filter=function(l){return(e,t,i)=>ts(e,t,i,l)};class hh{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new B,this._onClonedObservable=new B}}let lt=class Ya{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?!0:this._parentNode?this._parentNode.doNotSerialize:!1}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&&this._parentNode._children!==void 0&&this._parentNode._children!==null){const i=this._parentNode._children.indexOf(this);i!==-1&&this._parentNode._children.splice(i,1),!e&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=e,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(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(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){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){this._isDirty=!1,this._nodeDataStorage=new hh,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new B,this._parentContainer=null,this.animations=new Array,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=M.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new B,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||Ee.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return this._behaviors.indexOf(e)!==-1?this:(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 t===-1?this:(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={},this._cache.parent=void 0}updateCache(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,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?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._cache.parent!==this._parentNode?(this._cache.parent=this._parentNode,!1):this._parentNode&&!this.isSynchronizedWithParent()?!1: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 e===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_syncParentEnabledState(){this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,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?!0:this.parent.isDescendantOf(e):!1}_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=new Array;return this._getDescendants(i,e,t),i}getChildMeshes(e,t){const i=[];return this._getDescendants(i,e,s=>(!t||t(s))&&s.cullingStrategy!==void 0),i}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){if(e!==this._nodeDataStorage._isReady){if(!e){this._nodeDataStorage._isReady=!1;return}this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0}}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]=Ya._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=J.Clone(()=>new Ya(e,this.getScene()),this);if(t&&(s.parent=t),!i){const r=this.getDescendants(!0);for(let n=0;n<r.length;n++){const a=r[n];a.clone(e+"."+a.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=M.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 i of this._behaviors)i.detach();this._behaviors.length=0,this.metadata=null}static ParseAnimationRanges(e,t,i){if(t.ranges)for(let s=0;s<t.ranges.length;s++){const r=t.ranges[s];e.createAnimationRange(r.name,r.from,r.to)}}getHierarchyBoundingVectors(e=!0,t=null){this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);let i,s;const r=this;if(r.getBoundingInfo&&r.subMeshes){const n=r.getBoundingInfo();i=n.boundingBox.minimumWorld.clone(),s=n.boundingBox.maximumWorld.clone()}else i=new E(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new E(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e){const n=this.getDescendants(!1);for(const a of n){const o=a;if(o.computeWorldMatrix(!0),t&&!t(o)||!o.getBoundingInfo||o.getTotalVertices()===0)continue;const c=o.getBoundingInfo().boundingBox,u=c.minimumWorld,f=c.maximumWorld;E.CheckExtends(u,i,s),E.CheckExtends(f,i,s)}}return{min:i,max:s}}};lt._AnimationRangeFactory=(l,e,t)=>{throw fe("AnimationRange")},lt._NodeConstructors={},g([v()],lt.prototype,"name",void 0),g([v()],lt.prototype,"id",void 0),g([v()],lt.prototype,"uniqueId",void 0),g([v()],lt.prototype,"state",void 0),g([v()],lt.prototype,"metadata",void 0);function Mt(){return typeof window<"u"}function qr(){return typeof navigator<"u"}function _r(){return typeof document<"u"}function $a(l){let e="",t=l.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}class F{static _CheckLimit(e,t){let i=F._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},F._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){var i;const s=F._LogLimitOutputs[e];if(!s||!F.MessageLimitReached)return;const r=this._Levels[t];s.current===s.limit&&F[r.name](F.MessageLimitReached.replace(/%LIMIT%/g,""+s.limit).replace(/%TYPE%/g,(i=r.name)!==null&&i!==void 0?i:""))}static _AddLogEntry(e){F._LogCache=e+F._LogCache,F.OnNewCacheEntry&&F.OnNewCacheEntry(e)}static _FormatMessage(e){const t=s=>s<10?"0"+s:""+s,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){if(i!==void 0&&!F._CheckLimit(t,i))return;const s=F._FormatMessage(t),r=this._Levels[e];r.logFunc&&r.logFunc("BJS - "+s);const n=`<div style='color:${r.color}'>${s}</div><br>`;F._AddLogEntry(n),F._GenerateLimitMessage(t,e)}static get LogCache(){return F._LogCache}static ClearLogCache(){F._LogCache="",F._LogLimitOutputs={},F.errorsCount=0}static set LogLevels(e){F.Log=F._LogDisabled,F.Warn=F._LogDisabled,F.Error=F._LogDisabled,[F.MessageLogLevel,F.WarningLogLevel,F.ErrorLogLevel].forEach(t=>{if((e&t)===t){const i=this._Levels[t];F[i.name]=F._LogEnabled.bind(F,t)}})}}F.NoneLogLevel=0,F.MessageLogLevel=1,F.WarningLogLevel=2,F.ErrorLogLevel=4,F.AllLogLevel=7,F.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",F._LogCache="",F._LogLimitOutputs={},F._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],F.errorsCount=0,F.Log=F._LogEnabled.bind(F,F.MessageLogLevel),F.Warn=F._LogEnabled.bind(F,F.WarningLogLevel),F.Error=F._LogEnabled.bind(F,F.ErrorLogLevel);const Ja=(l,e)=>!l||l.getClassName&&l.getClassName()==="Mesh"?null:l.getClassName&&(l.getClassName()==="SubMesh"||l.getClassName()==="PhysicsBody")?l.clone(e):l.clone?l.clone():Array.isArray(l)?l.slice():null;function ch(l){const e=[];do Object.getOwnPropertyNames(l).forEach(function(t){e.indexOf(t)===-1&&e.push(t)});while(l=Object.getPrototypeOf(l));return e}class pr{static DeepCopy(e,t,i,s){const r=ch(e);for(const n of r){if(n[0]==="_"&&(!s||s.indexOf(n)===-1)||n.endsWith("Observable")||i&&i.indexOf(n)!==-1)continue;const a=e[n],o=typeof a;if(o!=="function")try{if(o==="object")if(a instanceof Uint8Array)t[n]=Uint8Array.from(a);else if(a instanceof Array){if(t[n]=[],a.length>0)if(typeof a[0]=="object")for(let h=0;h<a.length;h++){const c=Ja(a[h],t);t[n].indexOf(c)===-1&&t[n].push(c)}else t[n]=a.slice(0)}else t[n]=Ja(a,t);else t[n]=a}catch(h){F.Warn(h.message)}}}}class ii{static get Now(){return Mt()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}function uh(){return typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}class wt{constructor(){this._xhr=uh(),this._requestURL=""}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in wt.CustomRequestHeaders){const t=wt.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return wt.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){wt.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const i of wt.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;i(this._xhr,t)}return t=t.replace("file:http:","http:"),t=t.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)}}wt.CustomRequestHeaders={},wt.CustomRequestModifiers=new Array,wt.SkipRequestModificationForBabylonCDN=!0;class mr{}mr.FilesToLoad={};class fh{static ExponentialBackoff(e=3,t=500){return(i,s,r)=>s.status!==0||r>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,r)*t}}class ks extends Error{}ks._setPrototypeOf=Object.setPrototypeOf||((l,e)=>(l.__proto__=e,l));const is={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class xi extends ks{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",ks._setPrototypeOf(this,xi.prototype)}}const dh=l=>{if(typeof TextDecoder<"u")return new TextDecoder().decode(l);let e="";for(let t=0;t<l.byteLength;t++)e+=String.fromCharCode(l[t]);return e},eo=l=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i,s,r,n,a,o,h,c=0;const u=ArrayBuffer.isView(l)?new Uint8Array(l.buffer,l.byteOffset,l.byteLength):new Uint8Array(l);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=(i&3)<<4|s>>4,o=(s&15)<<2|r>>6,h=r&63,isNaN(s)?o=h=64:isNaN(r)&&(h=64),t+=e.charAt(n)+e.charAt(a)+e.charAt(o)+e.charAt(h);return t},to=l=>atob(l),_h=l=>{const e=to(l),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let s=0;s<t;s++)i[s]=e.charCodeAt(s);return i.buffer},ph="attribute",mh="varying";class gr{constructor(){this.children=[]}isValid(e){return!0}process(e,t){var i,s,r,n,a,o,h;let c="";if(this.line){let u=this.line;const f=t.processor;if(f){f.lineProcessor&&(u=f.lineProcessor(u,t.isFragment,t.processingContext));const d=(s=(i=t.processor)===null||i===void 0?void 0:i.attributeKeywordName)!==null&&s!==void 0?s:ph,_=t.isFragment&&(!((r=t.processor)===null||r===void 0)&&r.varyingFragmentKeywordName)?(n=t.processor)===null||n===void 0?void 0:n.varyingFragmentKeywordName:!t.isFragment&&(!((a=t.processor)===null||a===void 0)&&a.varyingVertexKeywordName)?(o=t.processor)===null||o===void 0?void 0:o.varyingVertexKeywordName:mh;!t.isFragment&&f.attributeProcessor&&this.line.startsWith(d)?u=f.attributeProcessor(this.line,e,t.processingContext):f.varyingProcessor&&(!((h=f.varyingCheck)===null||h===void 0)&&h.call(f,this.line,t.isFragment)||!f.varyingCheck&&this.line.startsWith(_))?u=f.varyingProcessor(this.line,t.isFragment,e,t.processingContext):f.uniformProcessor&&f.uniformRegexp&&f.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(u=f.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):f.uniformBufferProcessor&&f.uniformBufferRegexp&&f.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(u=f.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):f.textureProcessor&&f.textureRegexp&&f.textureRegexp.test(this.line)?u=f.textureProcessor(this.line,t.isFragment,e,t.processingContext):(f.uniformProcessor||f.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?f.uniformProcessor&&(u=f.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):f.uniformBufferProcessor&&(u=f.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,f.endOfUniformBufferProcessor&&(u=f.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}c+=u+`\r
1
+ (function(_i,Ji){typeof exports=="object"&&typeof module<"u"?Ji(exports):typeof define=="function"&&define.amd?define(["exports"],Ji):(_i=typeof globalThis<"u"?globalThis:_i||self,Ji(_i.Preview={}))})(this,function(_i){"use strict";var Ji=(l=>(l[l.Orbit=0]="Orbit",l[l.Pan=1]="Pan",l))(Ji||{}),Xr=(l=>(l.None="None",l.RemoveWhenSelected="RemoveWhenSelected",l.ApplyWhenSelected="ApplyWhenSelected",l))(Xr||{});function g(l,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,t,i);else for(var a=l.length-1;a>=0;a--)(n=l[a])&&(r=(s<3?n(r):s>3?n(e,t,r):n(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}class ms{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),ms._HandleParenthesisContent(i,t))):e=ms._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:ms.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(r=>r==="true");let i;const s=e.split("||");for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){let n=ms._SimplifyNegation(s[r].trim());const a=n.split("&&");if(a.length>1)for(let o=0;o<a.length;++o){const h=ms._SimplifyNegation(a[o].trim());if(h!=="true"&&h!=="false"?h[0]==="!"?i=!t(h.substring(1)):i=t(h):i=h==="true",!i){n="false";break}}if(i||n==="true"){i=!0;break}n!=="true"&&n!=="false"?n[0]==="!"?i=!t(n.substring(1)):i=t(n):i=n==="true"}return i?"true":"false"}static _SimplifyNegation(e){return e=e.replace(/^[\s!]+/,t=>(t=t.replace(/[\s]/g,()=>""),t.length%2?"!":"")),e=e.trim(),e==="!true"?e="false":e==="!false"&&(e="true"),e}}class xe{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>xe.HasTags(e),e.addTags=t=>xe.AddTagsTo(e,t),e.removeTags=t=>xe.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>xe.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 i in t)if(Object.prototype.hasOwnProperty.call(t,i))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const i=[];for(const s in e._tags)Object.prototype.hasOwnProperty.call(e._tags,s)&&e._tags[s]===!0&&i.push(s);return i.join(" ")}else return e._tags}static AddTagsTo(e,t){if(!t||typeof t!="string")return;t.split(" ").forEach(function(s){xe._AddTagTo(e,s)})}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(xe.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!xe.HasTags(e))return;const i=t.split(" ");for(const s in i)xe._RemoveTagFrom(e,i[s])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?xe.HasTags(e):ms.Eval(t,i=>xe.HasTags(e)&&e._tags[i])}}class ${static WithinEpsilon(e,t,i=1401298e-51){return Math.abs(e-t)<=i}static ToHex(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}static Sign(e){return e=+e,e===0||isNaN(e)?e:e>0?1:-1}static Clamp(e,t=0,i=1){return Math.min(i,Math.max(t,e))}static Log2(e){return Math.log(e)*Math.LOG2E}static ILog2(e){if(Math.log2)return Math.floor(Math.log2(e));if(e<0)return NaN;if(e===0)return-1/0;let t=0;if(e<1){for(;e<1;)t++,e=e*2;t=-t}else if(e>1)for(;e>1;)t++,e=Math.floor(e/2);return t}static Repeat(e,t){return e-Math.floor(e/t)*t}static Normalize(e,t,i){return(e-t)/(i-t)}static Denormalize(e,t,i){return e*(i-t)+t}static DeltaAngle(e,t){let i=$.Repeat(t-e,360);return i>180&&(i-=360),i}static PingPong(e,t){const i=$.Repeat(e,t*2);return t-Math.abs(i-t)}static SmoothStep(e,t,i){let s=$.Clamp(i);return s=-2*s*s*s+3*s*s,t*s+e*(1-s)}static MoveTowards(e,t,i){let s=0;return Math.abs(t-e)<=i?s=t:s=e+$.Sign(t-e)*i,s}static MoveTowardsAngle(e,t,i){const s=$.DeltaAngle(e,t);let r=0;return-i<s&&s<i?r=t:(t=e+s,r=$.MoveTowards(e,t,i)),r}static Lerp(e,t,i){return e+(t-e)*i}static LerpAngle(e,t,i){let s=$.Repeat(t-e,360);return s>180&&(s-=360),e+s*$.Clamp(i)}static InverseLerp(e,t,i){let s=0;return e!=t?s=$.Clamp((i-e)/(t-e)):s=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,c=a-2*n+r,u=a-n;return e*o+i*h+t*c+s*u}static Hermite1stDerivative(e,t,i,s,r){const n=r*r;return(n-r)*6*e+(3*n-4*r+1)*t+(-n+r)*6*i+(3*n-2*r)*s}static RandomRange(e,t){return e===t?e:Math.random()*(t-e)+e}static RangeToPercent(e,t,i){return(e-t)/(i-t)}static PercentToRange(e,t,i){return(i-t)*e+t}static NormalizeRadians(e){return e-=$.TwoPi*Math.floor((e+Math.PI)/$.TwoPi),e}static HCF(e,t){const i=e%t;return i===0?t:$.HCF(t,i)}}$.TwoPi=Math.PI*2;const fr=1/2.2,Yr=2.2,ke=.001;class At{static BuildArray(e,t){const i=[];for(let s=0;s<e;++s)i.push(t());return i}static BuildTuple(e,t){return At.BuildArray(e,t)}}function Jl(l,e,t){const i=l[e];if(typeof i!="function")return null;const s=function(){const r=l.length,n=s.previous.apply(l,arguments);return t(e,r),n};return i.next=s,s.previous=i,l[e]=s,()=>{const r=s.previous;if(!r)return;const n=s.next;n?(r.next=n,n.previous=r):(r.next=void 0,l[e]=r),s.next=void 0,s.previous=void 0}}const eh=["push","splice","pop","shift","unshift"];function ja(l,e){const t=eh.map(i=>Jl(l,i,e));return()=>{t.forEach(i=>{i==null||i()})}}const qa={};function Re(l,e){qa[l]=e}function Ri(l){return qa[l]}class ft{static SetMatrixPrecision(e){if(ft.MatrixTrackPrecisionChange=!1,e&&!ft.MatrixUse64Bits&&ft.MatrixTrackedMatrices)for(let t=0;t<ft.MatrixTrackedMatrices.length;++t){const i=ft.MatrixTrackedMatrices[t],s=i._m;i._m=new Array(16);for(let r=0;r<16;++r)i._m[r]=s[r]}ft.MatrixUse64Bits=e,ft.MatrixCurrentType=ft.MatrixUse64Bits?Array:Float32Array,ft.MatrixTrackedMatrices=null}}ft.MatrixUse64Bits=!1,ft.MatrixTrackPrecisionChange=!0,ft.MatrixCurrentType=Float32Array,ft.MatrixTrackedMatrices=[];class th{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 ih{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 B{static FromPromise(e,t){const i=new B;return e.then(s=>{i.notifyObservers(s)}).catch(s=>{if(t)t.notifyObservers(s);else throw s}),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 th(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const n=new ih(e,t,s);return n.unregisterOnNextCall=r,i?this._observers.unshift(n):this._observers.push(n),this._onObserverAdded&&this._onObserverAdded(n),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(n,this._lastNotifiedValue),n._remove=()=>{this.remove(n)},n}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return e?(e._remove=null,this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1):!1}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 i!==-1?(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0):!1}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 a of this._observers)if(!a._willBeUnregistered&&(a.mask&t&&(a.unregisterOnNextCall&&this._deferUnregister(a),a.scope?n.lastReturnValue=a.callback.apply(a.scope,[e,n]):n.lastReturnValue=a.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 B;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}}class Ee{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}Ee.Instances=new Array,Ee.OnEnginesDisposedObservable=new B,Ee._LastCreatedScene=null,Ee.UseFallbackTexture=!0,Ee.FallbackTexture="";const Gt=l=>parseInt(l.toString().replace(/\W/g,""));class ae{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){const e=Gt(this.x),t=Gt(this.y);let i=e;return i=i*397^t,i}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return ae.FromArrayToRef(e,t,this),this}asArray(){const e=new Array;return this.toArray(e,0),e}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)}add(e){return new this.constructor(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}addVector3(e){return new this.constructor(this.x+e.x,this.y+e.y)}subtract(e){return new this.constructor(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 this.constructor(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 this.constructor(this.x*e,this.y*t)}divide(e){return new this.constructor(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.divideToRef(e,this)}negate(){return new this.constructor(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.copyFromFloats(this.x*-1,this.y*-1)}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){const t=new this.constructor(0,0);return this.scaleToRef(e,t),t}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=ke){return e&&$.WithinEpsilon(this.x,e.x,t)&&$.WithinEpsilon(this.y,e.y,t)}floor(){return new this.constructor(Math.floor(this.x),Math.floor(this.y))}fract(){return new this.constructor(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}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 ae.NormalizeToRef(this,this),this}clone(){return new this.constructor(this.x,this.y)}static Zero(){return new ae(0,0)}static One(){return new ae(1,1)}static Random(e=0,t=1){return new ae($.RandomRange(e,t),$.RandomRange(e,t))}static get ZeroReadOnly(){return ae._ZeroReadOnly}static FromArray(e,t=0){return new ae(e[t],e[t+1])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],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 e.constructor(o,h)}static Clamp(e,t,i){let s=e.x;s=s>i.x?i.x:s,s=s<t.x?t.x:s;let r=e.y;return r=r>i.y?i.y:r,r=r<t.y?t.y:r,new e.constructor(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,c=a-2*n+r,u=a-n,f=e.x*o+i.x*h+t.x*c+s.x*u,d=e.y*o+i.y*h+t.y*c+s.y*u;return new e.constructor(f,d)}static Hermite1stDerivative(e,t,i,s,r){const n=new e.constructor;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=(a-r)*6*e.x+(3*a-4*r+1)*t.x+(-a+r)*6*i.x+(3*a-2*r)*s.x,n.y=(a-r)*6*e.y+(3*a-4*r+1)*t.y+(-a+r)*6*i.y+(3*a-2*r)*s.y,n}static Lerp(e,t,i){const s=e.x+(t.x-e.x)*i,r=e.y+(t.y-e.y)*i;return new e.constructor(s,r)}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){const t=new e.constructor;return this.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){const i=e.length();return i===0||(t.x=e.x/i,t.y=e.y/i),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 e.constructor(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 e.constructor(i,s)}static Transform(e,t){const i=new e.constructor;return ae.TransformToRef(e,t,i),i}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(ae.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){const i=new e.constructor;return ae.CenterToRef(e,t,i)}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=ae.DistanceSquared(t,i);if(s===0)return ae.Distance(e,t);const r=i.subtract(t),n=Math.max(0,Math.min(1,ae.Dot(e.subtract(t),r)/s)),a=t.add(r.multiplyByFloats(n,n));return ae.Distance(e,a)}}ae._ZeroReadOnly=ae.Zero();class E{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(){const e=Gt(this._x),t=Gt(this._y),i=Gt(this._z);let s=e;return s=s*397^t,s=s*397^i,s}asArray(){const e=[];return this.toArray(e,0),e}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 E.FromArrayToRef(e,t,this),this}toQuaternion(){return K.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this.addInPlaceFromFloats(e._x,e._y,e._z)}addInPlaceFromFloats(e,t,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this}add(e){return new this.constructor(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,t){return t.copyFromFloats(this._x+e._x,this._y+e._y,this._z+e._z)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new this.constructor(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 this.constructor(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,s){return s.copyFromFloats(this._x-e,this._y-t,this._z-i)}negate(){return new this.constructor(-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.copyFromFloats(this._x*-1,this._y*-1,this._z*-1)}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new this.constructor(this._x*e,this._y*e,this._z*e)}scaleToRef(e,t){return t.copyFromFloats(this._x*e,this._y*e,this._z*e)}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,c=2*(a*r-o*s),u=2*(o*i-n*r),f=2*(n*s-a*i);return t._x=i+h*c+a*f-o*u,t._y=s+h*u+o*c-n*f,t._z=r+h*f+n*u-a*c,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new this.constructor)}scaleAndAddToRef(e,t){return t.addInPlaceFromFloats(this._x*e,this._y*e,this._z*e)}projectOnPlane(e,t){const i=new this.constructor;return this.projectOnPlaneToRef(e,t,i),i}projectOnPlaneToRef(e,t,i){const s=e.normal,r=e.d,n=oe.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=E.Dot(n,s);if(Math.abs(a)<Math.pow(10,-10))i.setAll(1/0);else{const o=-(E.Dot(t,s)+r)/a,h=n.scaleInPlace(o);t.addToRef(h,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=ke){return e&&$.WithinEpsilon(this._x,e._x,t)&&$.WithinEpsilon(this._y,e._y,t)&&$.WithinEpsilon(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.copyFromFloats(this._x*e._x,this._y*e._y,this._z*e._z)}multiplyByFloats(e,t,i){return new this.constructor(this._x*e,this._y*t,this._z*i)}divide(e){return new this.constructor(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,t){return t.copyFromFloats(this._x/e._x,this._y/e._y,this._z/e._z)}divideInPlace(e){return this.divideToRef(e,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(!$.WithinEpsilon(t,i,e))return!0;const s=Math.abs(this._z);return!$.WithinEpsilon(t,s,e)||!$.WithinEpsilon(i,s,e)}get isNonUniform(){const e=Math.abs(this._x),t=Math.abs(this._y);if(e!==t)return!0;const i=Math.abs(this._z);return e!==i}floor(){return new this.constructor(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fract(){return new this.constructor(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}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){return e=e.toLowerCase(),e==="xyz"?this:(oe.Vector3[0].copyFrom(this),["x","y","z"].forEach((t,i)=>{this[t]=oe.Vector3[0][e[i]]}),this)}rotateByQuaternionToRef(e,t){return e.toRotationMatrix(oe.Matrix[0]),E.TransformCoordinatesToRef(this,oe.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,oe.Vector3[0]),oe.Vector3[0].rotateByQuaternionToRef(e,oe.Vector3[0]),t.addToRef(oe.Vector3[0],i),i}cross(e){const t=new this.constructor;return E.CrossToRef(this,e,t)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new this.constructor(0,0,0);return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return t===0||t===1?e.copyFromFloats(this._x,this._y,this._z):this.scaleToRef(1/t,e)}clone(){return new this.constructor(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=E.Dot(e,i)-s,n=E.Dot(t,i)-s;return r/(r-n)}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef(oe.Vector3[1]),r=t.normalizeToRef(oe.Vector3[2]);let n=E.Dot(s,r);n=$.Clamp(n,-1,1);const a=Math.acos(n),o=oe.Vector3[3];return E.CrossToRef(s,r,o),E.Dot(o,i)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,i){oe.Vector3[0].copyFrom(e);const s=oe.Vector3[0];oe.Vector3[1].copyFrom(t);const r=oe.Vector3[1];oe.Vector3[2].copyFrom(i);const n=oe.Vector3[2],a=oe.Vector3[3],o=oe.Vector3[4];s.normalize(),r.normalize(),n.normalize(),E.CrossToRef(n,s,a),E.CrossToRef(a,n,o);const h=Math.atan2(E.Dot(r,a),E.Dot(r,o));return $.NormalizeRadians(h)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=D.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=E.Zero();return E.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=$.Clamp(i,0,1);const r=oe.Vector3[0],n=oe.Vector3[1];r.copyFrom(e);const a=r.length();r.normalizeFromLength(a),n.copyFrom(t);const o=n.length();n.normalizeFromLength(o);const h=E.Dot(r,n);let c,u;if(h<1-ke){const f=Math.acos(h),d=1/Math.sin(f);c=Math.sin((1-i)*f)*d,u=Math.sin(i*f)*d}else c=1-i,u=i;return r.scaleInPlace(c),n.scaleInPlace(u),s.copyFrom(r).addInPlace(n),s.scaleInPlace($.Lerp(a,o,i)),s}static SmoothToRef(e,t,i,s,r){return E.SlerpToRef(e,t,s===0?1:i/s,r),r}static FromArray(e,t=0){return new E(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return E.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 E.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new E(0,0,0)}static One(){return new E(1,1,1)}static Up(){return new E(0,1,0)}static get UpReadOnly(){return E._UpReadOnly}static get DownReadOnly(){return E._DownReadOnly}static get RightReadOnly(){return E._RightReadOnly}static get LeftReadOnly(){return E._LeftReadOnly}static get LeftHandedForwardReadOnly(){return E._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return E._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return E._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return E._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return E._ZeroReadOnly}static get OneReadOnly(){return E._OneReadOnly}static Down(){return new E(0,-1,0)}static Forward(e=!1){return new E(0,0,e?-1:1)}static Backward(e=!1){return new E(0,0,e?1:-1)}static Right(){return new E(1,0,0)}static Left(){return new E(-1,0,0)}static Random(e=0,t=1){return new E($.RandomRange(e,t),$.RandomRange(e,t),$.RandomRange(e,t))}static TransformCoordinates(e,t){const i=E.Zero();return E.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return E.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],c=1/(e*n[3]+t*n[7]+i*n[11]+n[15]);return r._x=a*c,r._y=o*c,r._z=h*c,r._isDirty=!0,r}static TransformNormal(e,t){const i=E.Zero();return E.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),c=.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 e.constructor(o,h,c)}static Clamp(e,t,i){const s=new e.constructor;return E.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,c=a-2*n+r,u=a-n,f=e._x*o+i._x*h+t._x*c+s._x*u,d=e._y*o+i._y*h+t._y*c+s._y*u,_=e._z*o+i._z*h+t._z*c+s._z*u;return new e.constructor(f,d,_)}static Hermite1stDerivative(e,t,i,s,r){const n=new e.constructor;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=(a-r)*6*e._x+(3*a-4*r+1)*t._x+(-a+r)*6*i._x+(3*a-2*r)*s._x,n._y=(a-r)*6*e._y+(3*a-4*r+1)*t._y+(-a+r)*6*i._y+(3*a-2*r)*s._y,n._z=(a-r)*6*e._z+(3*a-4*r+1)*t._z+(-a+r)*6*i._z+(3*a-2*r)*s._z,n._isDirty=!0,n}static Lerp(e,t,i){const s=new e.constructor(0,0,0);return E.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}static Cross(e,t){const i=new e.constructor;return E.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=E.Zero();return E.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const r=new e.constructor;return E.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,c=oe.Matrix[1];M.FromValuesToRef(n/2,0,0,0,0,-a/2,0,0,0,0,.5,0,o+n/2,a/2+h,.5,1,c);const u=oe.Matrix[0];return t.multiplyToRef(i,u),u.multiplyToRef(c,u),E.TransformCoordinatesToRef(e,u,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new E)}static ReflectToRef(e,t,i){const s=D.Vector3[0];return s.copyFrom(t).scaleInPlace(2*E.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static _UnprojectFromInvertedMatrixToRef(e,t,i){E.TransformCoordinatesToRef(e,t,i);const s=t.m,r=e._x*s[3]+e._y*s[7]+e._z*s[11]+s[15];return $.WithinEpsilon(r,1)&&i.scaleInPlace(1/r),i}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,M.IdentityReadOnly)}static Unproject(e,t,i,s,r,n){const a=new e.constructor;return E.UnprojectToRef(e,t,i,s,r,n,a),a}static UnprojectToRef(e,t,i,s,r,n,a){return E.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){var c;const u=oe.Matrix[0];n.multiplyToRef(a,u),u.multiplyToRef(o,u),u.invert();const f=oe.Vector3[0];return f.x=e/s*2-1,f.y=-(t/r*2-1),!((c=Ee.LastCreatedEngine)===null||c===void 0)&&c.isNDCHalfZRange?f.z=i:f.z=2*i-1,E._UnprojectFromInvertedMatrixToRef(f,u,h),h}static Minimize(e,t){const i=new e.constructor;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new e.constructor;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(E.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=oe.Vector3[0],a=oe.Vector3[1],o=oe.Vector3[2],h=oe.Vector3[3],c=oe.Vector3[4];i.subtractToRef(t,n),s.subtractToRef(t,a),s.subtractToRef(i,o);const u=n.length(),f=a.length(),d=o.length();if(u<ke||f<ke||d<ke)return r.copyFrom(t),E.Distance(e,t);e.subtractToRef(t,c),E.CrossToRef(n,a,h);const _=h.length();if(_<ke)return r.copyFrom(t),E.Distance(e,t);h.normalizeFromLength(_);let p=c.length();if(p<ke)return r.copyFrom(t),0;c.normalizeFromLength(p);const m=E.Dot(h,c),T=oe.Vector3[5],S=oe.Vector3[6];T.copyFrom(h).scaleInPlace(-p*m),S.copyFrom(e).addInPlace(T);const x=oe.Vector3[4],b=oe.Vector3[5],I=oe.Vector3[7],R=oe.Vector3[8];x.copyFrom(n).scaleInPlace(1/u),R.copyFrom(a).scaleInPlace(1/f),x.addInPlace(R).scaleInPlace(-1),b.copyFrom(n).scaleInPlace(-1/u),R.copyFrom(o).scaleInPlace(1/d),b.addInPlace(R).scaleInPlace(-1),I.copyFrom(o).scaleInPlace(-1/d),R.copyFrom(a).scaleInPlace(-1/f),I.addInPlace(R).scaleInPlace(-1);const C=oe.Vector3[9];let y;C.copyFrom(S).subtractInPlace(t),E.CrossToRef(x,C,R),y=E.Dot(R,h);const w=y;C.copyFrom(S).subtractInPlace(i),E.CrossToRef(b,C,R),y=E.Dot(R,h);const G=y;C.copyFrom(S).subtractInPlace(s),E.CrossToRef(I,C,R),y=E.Dot(R,h);const te=y,Q=oe.Vector3[10];let Te,he;w>0&&G<0?(Q.copyFrom(n),Te=t,he=i):G>0&&te<0?(Q.copyFrom(o),Te=i,he=s):(Q.copyFrom(a).scaleInPlace(-1),Te=s,he=t);const ve=oe.Vector3[9],le=oe.Vector3[4];if(Te.subtractToRef(S,R),he.subtractToRef(S,ve),E.CrossToRef(R,ve,le),!(E.Dot(le,h)<0))return r.copyFrom(S),Math.abs(p*m);const ye=oe.Vector3[5];E.CrossToRef(Q,le,ye),ye.normalize();const Ye=oe.Vector3[9];Ye.copyFrom(Te).subtractInPlace(S);const et=Ye.length();if(et<ke)return r.copyFrom(Te),E.Distance(e,Te);Ye.normalizeFromLength(et);const Ne=E.Dot(ye,Ye),pt=oe.Vector3[7];pt.copyFrom(S).addInPlace(ye.scaleInPlace(et*Ne)),R.copyFrom(pt).subtractInPlace(Te),p=Q.length(),Q.normalizeFromLength(p);let Si=E.Dot(R,Q)/Math.max(p,ke);return Si=$.Clamp(Si,0,1),pt.copyFrom(Te).addInPlace(Q.scaleInPlace(Si*p)),r.copyFrom(pt),E.Distance(e,pt)}static Center(e,t){return E.CenterToRef(e,t,E.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 e.constructor;return E.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const r=oe.Quaternion[0];return K.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(s),s}}E._UpReadOnly=E.Up(),E._DownReadOnly=E.Down(),E._LeftHandedForwardReadOnly=E.Forward(!1),E._RightHandedForwardReadOnly=E.Forward(!0),E._LeftHandedBackwardReadOnly=E.Backward(!1),E._RightHandedBackwardReadOnly=E.Backward(!0),E._RightReadOnly=E.Right(),E._LeftReadOnly=E.Left(),E._ZeroReadOnly=E.Zero(),E._OneReadOnly=E.One();class He{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(){const e=Gt(this.x),t=Gt(this.y),i=Gt(this.z),s=Gt(this.w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}asArray(){const e=new Array;return this.toArray(e,0),e}toArray(e,t){return t===void 0&&(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 He.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}add(e){return new this.constructor(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 this.constructor(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 this.constructor(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 this.constructor(-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.copyFromFloats(this.x*-1,this.y*-1,this.z*-1,this.w*-1)}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new this.constructor(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=ke){return e&&$.WithinEpsilon(this.x,e.x,t)&&$.WithinEpsilon(this.y,e.y,t)&&$.WithinEpsilon(this.z,e.z,t)&&$.WithinEpsilon(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 this.constructor(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 this.constructor(this.x*e,this.y*t,this.z*i,this.w*s)}divide(e){return new this.constructor(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}floor(){return new this.constructor(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))}fract(){return new this.constructor(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(){const e=this.length();return e===0?this:this.scaleInPlace(1/e)}toVector3(){return new E(this.x,this.y,this.z)}clone(){return new this.constructor(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}static FromArray(e,t){return t||(t=0),new He(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 He.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 He(0,0,0,0)}static One(){return new He(1,1,1,1)}static Random(e=0,t=1){return new He($.RandomRange(e,t),$.RandomRange(e,t),$.RandomRange(e,t),$.RandomRange(e,t))}static get ZeroReadOnly(){return He._ZeroReadOnly}static Normalize(e){const t=He.Zero();return He.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return t.copyFrom(e),t.normalize(),t}static Minimize(e,t){const i=new e.constructor;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new e.constructor;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(He.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 He.CenterToRef(e,t,He.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)}static TransformCoordinates(e,t){const i=He.Zero();return He.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return He.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],c=e*n[3]+t*n[7]+i*n[11]+n[15];return r.x=a,r.y=o,r.z=h,r.w=c,r}static TransformNormal(e,t){const i=new e.constructor;return He.TransformNormalToRef(e,t,i),i}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 He(e._x,e._y,e._z,t)}}He._ZeroReadOnly=He.Zero();class K{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(){const e=Gt(this._x),t=Gt(this._y),i=Gt(this._z),s=Gt(this._w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}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}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,t=ke){return e&&$.WithinEpsilon(this._x,e._x,t)&&$.WithinEpsilon(this._y,e._y,t)&&$.WithinEpsilon(this._z,e._z,t)&&$.WithinEpsilon(this._w,e._w,t)}clone(){return new this.constructor(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)}add(e){return new this.constructor(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}subtract(e){return new this.constructor(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 this.constructor(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 this.constructor(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),this}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 this.constructor(-this._x,-this._y,-this._z,this._w)}invert(){const e=this.conjugate(),t=this.lengthSquared();return t==0||t==1||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();const e=this.lengthSquared();return e==0||e==1?this:(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(){const e=this.length();if(e===0)return this;const t=1/e;return this.scaleInPlace(t),this}normalizeToNew(){const e=this.length();if(e===0)return this.clone();const t=1/e;return this.scale(t)}toEulerAngles(){const e=E.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 o=r*r,h=t*t,c=i*i,u=s*s;e._z=Math.atan2(2*(i*s+t*r),-h-c+u+o),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*i+s*r),h-c-u+o),e._isDirty=!0}return e}toRotationMatrix(e){return M.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return K.FromRotationMatrixToRef(e,this),this}static FromRotationMatrix(e){const t=new K;return K.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],c=i[2],u=i[6],f=i[10],d=s+o+f;let _;return d>0?(_=.5/Math.sqrt(d+1),t._w=.25/_,t._x=(u-h)*_,t._y=(n-c)*_,t._z=(a-r)*_,t._isDirty=!0):s>o&&s>f?(_=2*Math.sqrt(1+s-o-f),t._w=(u-h)/_,t._x=.25*_,t._y=(r+a)/_,t._z=(n+c)/_,t._isDirty=!0):o>f?(_=2*Math.sqrt(1+o-s-f),t._w=(n-c)/_,t._x=(r+a)/_,t._y=.25*_,t._z=(h+u)/_,t._isDirty=!0):(_=2*Math.sqrt(1+f-s-o),t._w=(a-r)/_,t._x=(n+c)/_,t._y=(h+u)/_,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=K.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let n=s===0?1:i/s;return n=$.Clamp(n,0,1),K.SlerpToRef(e,t,n,r),r}static Zero(){return new K(0,0,0,0)}static Inverse(e){return new e.constructor(-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 K(0,0,0,1)}static IsIdentity(e){return e&&e._x===0&&e._y===0&&e._z===0&&e._w===1}static RotationAxis(e,t){return K.RotationAxisToRef(e,t,new K)}static RotationAxisToRef(e,t,i){const s=Math.sin(t/2);return e.normalize(),i._w=Math.cos(t/2),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 K(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 FromEulerAngles(e,t,i){const s=new K;return K.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return K.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new K;return K.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return K.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=ke){const r=E.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):(E.CrossToRef(e,t,D.Vector3[0]),i.set(D.Vector3[0].x,D.Vector3[0].y,D.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new K;return K.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const r=i*.5,n=t*.5,a=e*.5,o=Math.sin(r),h=Math.cos(r),c=Math.sin(n),u=Math.cos(n),f=Math.sin(a),d=Math.cos(a);return s._x=d*c*h+f*u*o,s._y=f*u*h-d*c*o,s._z=d*u*o-f*c*h,s._w=d*u*h+f*c*o,s._isDirty=!0,s}static RotationAlphaBetaGamma(e,t,i){const s=new K;return K.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const r=(i+e)*.5,n=(i-e)*.5,a=t*.5;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 K(0,0,0,0);return K.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=oe.Matrix[0];return M.FromXYZAxesToRef(e.normalize(),t.normalize(),i.normalize(),r),K.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new K;return K.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=oe.Matrix[0];return M.LookDirectionLHToRef(e,t,s),K.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new K;return K.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=oe.Matrix[0];return M.LookDirectionRHToRef(e,t,s),K.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=K.Identity();return K.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 h=Math.acos(a),c=1/Math.sin(h);n=Math.sin((1-i)*h)*c,r=o?-Math.sin(i*h)*c:Math.sin(i*h)*c}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,c=a-2*n+r,u=a-n,f=e._x*o+i._x*h+t._x*c+s._x*u,d=e._y*o+i._y*h+t._y*c+s._y*u,_=e._z*o+i._z*h+t._z*c+s._z*u,p=e._w*o+i._w*h+t._w*c+s._w*u;return new e.constructor(f,d,_,p)}static Hermite1stDerivative(e,t,i,s,r){const n=new e.constructor;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=(a-r)*6*e._x+(3*a-4*r+1)*t._x+(-a+r)*6*i._x+(3*a-2*r)*s._x,n._y=(a-r)*6*e._y+(3*a-4*r+1)*t._y+(-a+r)*6*i._y+(3*a-2*r)*s._y,n._z=(a-r)*6*e._z+(3*a-4*r+1)*t._z+(-a+r)*6*i._z+(3*a-2*r)*s._z,n._w=(a-r)*6*e._w+(3*a-4*r+1)*t._w+(-a+r)*6*i._w+(3*a-2*r)*s._w,n._isDirty=!0,n}}class M{static get Use64Bits(){return ft.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=M._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?!1:t,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:s}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,ft.MatrixTrackPrecisionChange&&ft.MatrixTrackedMatrices.push(this),this._m=new ft.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;const e=this._m;this._isIdentity=e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1?this._isIdentity3x2=!1: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]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(this._isIdentity===!0)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],c=e[8],u=e[9],f=e[10],d=e[11],_=e[12],p=e[13],m=e[14],T=e[15],S=f*T-m*d,x=u*T-p*d,b=u*m-p*f,I=c*T-_*d,R=c*m-f*_,C=c*p-_*u,y=+(a*S-o*x+h*b),w=-(n*S-o*I+h*R),G=+(n*x-a*I+h*C),te=-(n*b-a*R+o*C);return t*y+i*w+s*G+r*te}toArray(){return this._m}asArray(){return this._m}invert(){return this.invertToRef(this),this}reset(){return M.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 this.constructor;return this.addToRef(e,t),t}addToRef(e,t){const i=this._m,s=t._m,r=e.m;for(let n=0;n<16;n++)s[n]=i[n]+r[n];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]+=i[s];return this.markAsUpdated(),this}invertToRef(e){if(this._isIdentity===!0)return M.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],c=t[7],u=t[8],f=t[9],d=t[10],_=t[11],p=t[12],m=t[13],T=t[14],S=t[15],x=d*S-T*_,b=f*S-m*_,I=f*T-m*d,R=u*S-p*_,C=u*T-d*p,y=u*m-p*f,w=+(o*x-h*b+c*I),G=-(a*x-h*R+c*C),te=+(a*b-o*R+c*y),Q=-(a*I-o*C+h*y),Te=i*w+s*G+r*te+n*Q;if(Te===0)return e.copyFrom(this),e;const he=1/Te,ve=h*S-T*c,le=o*S-m*c,be=o*T-m*h,ye=a*S-p*c,Ye=a*T-p*h,et=a*m-p*o,Ne=h*_-d*c,pt=o*_-f*c,Si=o*d-f*h,Os=a*_-u*c,ur=a*d-u*h,ot=a*f-u*o,Ds=-(s*x-r*b+n*I),Ls=+(i*x-r*R+n*C),Ns=-(i*b-s*R+n*y),Fs=+(i*I-s*C+r*y),za=+(s*ve-r*le+n*be),Xa=-(i*ve-r*ye+n*Ye),qi=+(i*le-s*ye+n*et),Zi=-(i*be-s*Ye+r*et),Qi=-(s*Ne-r*pt+n*Si),$i=+(i*Ne-r*Os+n*ur),hT=-(i*pt-s*Os+n*ot),cT=+(i*Si-s*ur+r*ot);return M.FromValuesToRef(w*he,Ds*he,za*he,Qi*he,G*he,Ls*he,Xa*he,$i*he,te*he,Ns*he,qi*he,hT*he,Q*he,Fs*he,Zi*he,cT*he,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 E(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 M.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),this}multiply(e){const t=new this.constructor;return this.multiplyToRef(e,t),t}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}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],c=s[4],u=s[5],f=s[6],d=s[7],_=s[8],p=s[9],m=s[10],T=s[11],S=s[12],x=s[13],b=s[14],I=s[15],R=r[0],C=r[1],y=r[2],w=r[3],G=r[4],te=r[5],Q=r[6],Te=r[7],he=r[8],ve=r[9],le=r[10],be=r[11],ye=r[12],Ye=r[13],et=r[14],Ne=r[15];return t[i]=n*R+a*G+o*he+h*ye,t[i+1]=n*C+a*te+o*ve+h*Ye,t[i+2]=n*y+a*Q+o*le+h*et,t[i+3]=n*w+a*Te+o*be+h*Ne,t[i+4]=c*R+u*G+f*he+d*ye,t[i+5]=c*C+u*te+f*ve+d*Ye,t[i+6]=c*y+u*Q+f*le+d*et,t[i+7]=c*w+u*Te+f*be+d*Ne,t[i+8]=_*R+p*G+m*he+T*ye,t[i+9]=_*C+p*te+m*ve+T*Ye,t[i+10]=_*y+p*Q+m*le+T*et,t[i+11]=_*w+p*Te+m*be+T*Ne,t[i+12]=S*R+x*G+b*he+I*ye,t[i+13]=S*C+x*te+b*ve+I*Ye,t[i+14]=S*y+x*Q+b*le+I*et,t[i+15]=S*w+x*Te+b*be+I*Ne,this}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]}clone(){const e=new this.constructor;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=Gt(this._m[0]);for(let t=1;t<16;t++)e=e*397^Gt(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new K,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,s){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const r=this._m;if(i&&i.copyFromFloats(r[12],r[13],r[14]),e=e||oe.Vector3[0],e.x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),e.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),e.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),s){const n=s.scaling.x<0?-1:1,a=s.scaling.y<0?-1:1,o=s.scaling.z<0?-1:1;e.x*=n,e.y*=a,e.z*=o}else this.determinant()<=0&&(e.y*=-1);if(e._x===0||e._y===0||e._z===0)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const n=1/e._x,a=1/e._y,o=1/e._z;M.FromValuesToRef(r[0]*n,r[1]*n,r[2]*n,0,r[4]*a,r[5]*a,r[6]*a,0,r[8]*o,r[9]*o,r[10]*o,0,0,0,0,1,oe.Matrix[0]),K.FromRotationMatrixToRef(oe.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=e*4;return new He(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=e*4;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 this.constructor;return M.TransposeToRef(this,e),e}transposeToRef(e){return M.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,s,r){if(e<0||e>3)return this;const n=e*4;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 this.constructor;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}toNormalMatrix(e){const t=oe.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return M.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 this.constructor;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=oe.Vector3[0];if(!this.decompose(t))return M.IdentityToRef(e),e;const i=this._m,s=1/t._x,r=1/t._y,n=1/t._z;return M.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 M;return M.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){for(let r=0;r<16;r++)s._m[r]=e[r+t]*i;return s.markAsUpdated(),s}static get IdentityReadOnly(){return M._IdentityReadOnly}static FromValuesToRef(e,t,i,s,r,n,a,o,h,c,u,f,d,_,p,m,T){const S=T._m;S[0]=e,S[1]=t,S[2]=i,S[3]=s,S[4]=r,S[5]=n,S[6]=a,S[7]=o,S[8]=h,S[9]=c,S[10]=u,S[11]=f,S[12]=d,S[13]=_,S[14]=p,S[15]=m,T.markAsUpdated()}static FromValues(e,t,i,s,r,n,a,o,h,c,u,f,d,_,p,m){const T=new M,S=T._m;return S[0]=e,S[1]=t,S[2]=i,S[3]=s,S[4]=r,S[5]=n,S[6]=a,S[7]=o,S[8]=h,S[9]=c,S[10]=u,S[11]=f,S[12]=d,S[13]=_,S[14]=p,S[15]=m,T.markAsUpdated(),T}static Compose(e,t,i){const s=new M;return M.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,c=n+n,u=a+a,f=o+o,d=n*c,_=n*u,p=n*f,m=a*u,T=a*f,S=o*f,x=h*c,b=h*u,I=h*f,R=e._x,C=e._y,y=e._z;return r[0]=(1-(m+S))*R,r[1]=(_+I)*R,r[2]=(p-b)*R,r[3]=0,r[4]=(_-I)*C,r[5]=(1-(d+S))*C,r[6]=(T+x)*C,r[7]=0,r[8]=(p+b)*y,r[9]=(T-x)*y,r[10]=(1-(d+m))*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=M.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 M.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=M.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 M;return M.RotationXToRef(e,t),t}static Invert(e){const t=new e.constructor;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.FromValuesToRef(1,0,0,0,0,s,i,0,0,-i,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationY(e){const t=new M;return M.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.FromValuesToRef(s,0,-i,0,0,1,0,0,i,0,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationZ(e){const t=new M;return M.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.FromValuesToRef(s,i,0,0,-i,s,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationAxis(e,t){const i=new M;return M.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){const s=Math.sin(-t),r=Math.cos(-t),n=1-r;e.normalize();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){const s=E.Dot(t,e),r=i._m;if(s<-1+ke)r[0]=-1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0;else{const n=E.Cross(t,e),a=1/(1+s);r[0]=n._x*n._x*a+s,r[1]=n._y*n._x*a-n._z,r[2]=n._z*n._x*a+n._y,r[3]=0,r[4]=n._x*n._y*a+n._z,r[5]=n._y*n._y*a+s,r[6]=n._z*n._y*a-n._x,r[7]=0,r[8]=n._x*n._z*a-n._y,r[9]=n._y*n._z*a+n._x,r[10]=n._z*n._z*a+s,r[11]=0}return r[12]=0,r[13]=0,r[14]=0,r[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){const s=new M;return M.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return K.RotationYawPitchRollToRef(e,t,i,oe.Quaternion[0]),oe.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new M;return M.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return M.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,s),s._updateIdentityStatus(e===1&&t===1&&i===1),s}static Translation(e,t,i){const s=new M;return M.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return M.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,s),s._updateIdentityStatus(e===0&&t===0&&i===0),s}static Lerp(e,t,i){const s=new e.constructor;return M.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){const r=s._m,n=e.m,a=t.m;for(let o=0;o<16;o++)r[o]=n[o]*(1-i)+a[o]*i;return s.markAsUpdated(),s}static DecomposeLerp(e,t,i){const s=new e.constructor;return M.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const r=oe.Vector3[0],n=oe.Quaternion[0],a=oe.Vector3[1];e.decompose(r,n,a);const o=oe.Vector3[2],h=oe.Quaternion[1],c=oe.Vector3[3];t.decompose(o,h,c);const u=oe.Vector3[4];E.LerpToRef(r,o,i,u);const f=oe.Quaternion[2];K.SlerpToRef(n,h,i,f);const d=oe.Vector3[5];return E.LerpToRef(a,c,i,d),M.ComposeToRef(u,f,d,s),s}static LookAtLH(e,t,i){const s=new M;return M.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const r=oe.Vector3[0],n=oe.Vector3[1],a=oe.Vector3[2];t.subtractToRef(e,a),a.normalize(),E.CrossToRef(i,a,r);const o=r.lengthSquared();o===0?r.x=1:r.normalizeFromLength(Math.sqrt(o)),E.CrossToRef(a,r,n),n.normalize();const h=-E.Dot(r,e),c=-E.Dot(n,e),u=-E.Dot(a,e);M.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,c,u,1,s)}static LookAtRH(e,t,i){const s=new M;return M.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const r=oe.Vector3[0],n=oe.Vector3[1],a=oe.Vector3[2];e.subtractToRef(t,a),a.normalize(),E.CrossToRef(i,a,r);const o=r.lengthSquared();o===0?r.x=1:r.normalizeFromLength(Math.sqrt(o)),E.CrossToRef(a,r,n),n.normalize();const h=-E.Dot(r,e),c=-E.Dot(n,e),u=-E.Dot(a,e);return M.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,c,u,1,s),s}static LookDirectionLH(e,t){const i=new M;return M.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=oe.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const r=oe.Vector3[1];return E.CrossToRef(t,s,r),M.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 M;return M.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=oe.Vector3[2];return E.CrossToRef(t,e,s),M.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 M;return M.OrthoLHToRef(e,t,i,s,n,r),n}static OrthoLHToRef(e,t,i,s,r,n){const a=i,o=s,h=2/e,c=2/t,u=2/(o-a),f=-(o+a)/(o-a);return M.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,u,0,0,0,f,1,r),n&&r.multiplyToRef(es,r),r._updateIdentityStatus(h===1&&c===1&&u===1&&f===0),r}static OrthoOffCenterLH(e,t,i,s,r,n,a){const o=new M;return M.OrthoOffCenterLHToRef(e,t,i,s,r,n,o,a),o}static OrthoOffCenterLHToRef(e,t,i,s,r,n,a,o){const h=r,c=n,u=2/(t-e),f=2/(s-i),d=2/(c-h),_=-(c+h)/(c-h),p=(e+t)/(e-t),m=(s+i)/(i-s);return M.FromValuesToRef(u,0,0,0,0,f,0,0,0,0,d,0,p,m,_,1,a),o&&a.multiplyToRef(es,a),a.markAsUpdated(),a}static OrthoOffCenterRH(e,t,i,s,r,n,a){const o=new M;return M.OrthoOffCenterRHToRef(e,t,i,s,r,n,o,a),o}static OrthoOffCenterRHToRef(e,t,i,s,r,n,a,o){return M.OrthoOffCenterLHToRef(e,t,i,s,r,n,a,o),a._m[10]*=-1,a}static PerspectiveLH(e,t,i,s,r,n=0){const a=new M,o=i,h=s,c=2*o/e,u=2*o/t,f=(h+o)/(h-o),d=-2*h*o/(h-o),_=Math.tan(n);return M.FromValuesToRef(c,0,0,0,0,u,0,_,0,0,f,1,0,0,d,0,a),r&&a.multiplyToRef(es,a),a._updateIdentityStatus(!1),a}static PerspectiveFovLH(e,t,i,s,r,n=0,a=!1){const o=new M;return M.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 c=i,u=s,f=1/Math.tan(e*.5),d=n?f/t:f,_=n?f:f*t,p=h&&c===0?-1:u!==0?(u+c)/(u-c):1,m=h&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,T=Math.tan(o);return M.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,1,0,0,m,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,i,s,r,n=!0,a,o=0){const h=1/Math.tan(e*.5),c=n?h/t:h,u=n?h:h*t,f=Math.tan(o);return M.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,1,0,0,1,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,i,s,r,n=0,a=!1){const o=new M;return M.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 c=i,u=s,f=1/Math.tan(e*.5),d=n?f/t:f,_=n?f:f*t,p=h&&c===0?1:u!==0?-(u+c)/(u-c):-1,m=h&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,T=Math.tan(o);return M.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,-1,0,0,m,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,i,s,r,n=!0,a,o=0){const h=1/Math.tan(e*.5),c=n?h/t:h,u=n?h:h*t,f=Math.tan(o);return M.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,-1,0,0,-1,0,r),a&&r.multiplyToRef(es,r),r._updateIdentityStatus(!1),r}static PerspectiveFovWebVRToRef(e,t,i,s,r=!1,n,a=0){const o=r?-1:1,h=Math.tan(e.upDegrees*Math.PI/180),c=Math.tan(e.downDegrees*Math.PI/180),u=Math.tan(e.leftDegrees*Math.PI/180),f=Math.tan(e.rightDegrees*Math.PI/180),d=2/(u+f),_=2/(h+c),p=Math.tan(a),m=s._m;return m[0]=d,m[1]=m[2]=m[3]=m[4]=0,m[5]=_,m[6]=0,m[7]=p,m[8]=(u-f)*d*.5,m[9]=-((h-c)*_*.5),m[10]=-i/(t-i),m[11]=1*o,m[12]=m[13]=m[15]=0,m[14]=-(2*i*t)/(i-t),n&&s.multiplyToRef(es,s),s.markAsUpdated(),s}static GetFinalMatrix(e,t,i,s,r,n){const a=e.width,o=e.height,h=e.x,c=e.y,u=M.FromValues(a/2,0,0,0,0,-o/2,0,0,0,0,n-r,0,h+a/2,o/2+c,r,1),f=new t.constructor;return t.multiplyToRef(i,f),f.multiplyToRef(s,f),f.multiplyToRef(u,f)}static GetAsMatrix2x2(e){const t=e.m,i=[t[0],t[1],t[4],t[5]];return ft.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 ft.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new e.constructor;return M.TransposeToRef(e,t),t}static TransposeToRef(e,t){const i=t._m,s=e.m;return i[0]=s[0],i[1]=s[4],i[2]=s[8],i[3]=s[12],i[4]=s[1],i[5]=s[5],i[6]=s[9],i[7]=s[13],i[8]=s[2],i[9]=s[6],i[10]=s[10],i[11]=s[14],i[12]=s[3],i[13]=s[7],i[14]=s[11],i[15]=s[15],t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new M;return M.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 M.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 M.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,c=e._y*e._z,u=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*(c+u),t._m[7]=0,t._m[8]=2*(o+h),t._m[9]=2*(c-u),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}}M._UpdateFlagSeed=0,M._IdentityReadOnly=M.Identity();class oe{}oe.Vector3=At.BuildTuple(11,E.Zero),oe.Matrix=At.BuildTuple(2,M.Identity),oe.Quaternion=At.BuildTuple(3,K.Zero);class D{}D.Vector2=At.BuildTuple(3,ae.Zero),D.Vector3=At.BuildTuple(13,E.Zero),D.Vector4=At.BuildTuple(3,He.Zero),D.Quaternion=At.BuildTuple(2,K.Zero),D.Matrix=At.BuildTuple(8,M.Identity),Re("BABYLON.Vector2",ae),Re("BABYLON.Vector3",E),Re("BABYLON.Vector4",He),Re("BABYLON.Matrix",M);const es=M.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function fe(l){return`${l} needs to be imported before as it contains a side-effect required by your code.`}function ws(l){return Math.pow(l,Yr)}function Bs(l){return l<=.04045?.0773993808*l:Math.pow(.947867299*(l+.055),2.4)}function Us(l){return Math.pow(l,fr)}function Vs(l){return l<=.0031308?12.92*l:1.055*Math.pow(l,.41666)-.055}class z{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=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),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 z.FromArrayToRef(e,t,this),this}toColor4(e=1){return new ge(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return this.r*.3+this.g*.59+this.b*.11}multiply(e){return new z(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,this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,i){return this.r===e&&this.g===t&&this.b===i}scale(e){return new z(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,this}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this}clampToRef(e=0,t=1,i){return i.r=$.Clamp(this.r,e,t),i.g=$.Clamp(this.g,e,t),i.b=$.Clamp(this.b,e,t),this}add(e){return new z(this.r+e.r,this.g+e.g,this.b+e.b)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this}subtract(e){return new z(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,this}clone(){return new z(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)}toHexString(){const e=Math.round(this.r*255),t=Math.round(this.g*255),i=Math.round(this.b*255);return"#"+$.ToHex(e)+$.ToHex(t)+$.ToHex(i)}toHSV(){const e=new z;return this.toHSVToRef(e),e}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,c=r-n;r!==0&&(o=c/r),r!=n&&(r==t?(a=(i-s)/c,i<s&&(a+=6)):r==i?a=(s-t)/c+2:r==s&&(a=(t-i)/c+4),a*=60),e.r=a,e.g=o,e.b=h}toLinearSpace(e=!1){const t=new z;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=Bs(this.r),e.g=Bs(this.g),e.b=Bs(this.b)):(e.r=ws(this.r),e.g=ws(this.g),e.b=ws(this.b)),this}toGammaSpace(e=!1){const t=new z;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=Vs(this.r),e.g=Vs(this.g),e.b=Vs(this.b)):(e.r=Us(this.r),e.g=Us(this.g),e.b=Us(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,c=0;n>=0&&n<=1?(o=r,h=a):n>=1&&n<=2?(o=a,h=r):n>=2&&n<=3?(h=r,c=a):n>=3&&n<=4?(h=a,c=r):n>=4&&n<=5?(o=a,c=r):n>=5&&n<=6&&(o=r,c=a);const u=i-r;s.set(o+u,h+u,c+u)}static FromHSV(e,t,i){const s=new z(0,0,0);return z.HSVtoRGBToRef(e,t,i,s),s}static FromHexString(e){if(e.substring(0,1)!=="#"||e.length!==7)return new z(0,0,0);const t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),s=parseInt(e.substring(5,7),16);return z.FromInts(t,i,s)}static FromArray(e,t=0){return new z(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 z(e/255,t/255,i/255)}static Lerp(e,t,i){const s=new z(0,0,0);return z.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,c=a-2*n+r,u=a-n,f=e.r*o+i.r*h+t.r*c+s.r*u,d=e.g*o+i.g*h+t.g*c+s.g*u,_=e.b*o+i.b*h+t.b*c+s.b*u;return new z(f,d,_)}static Hermite1stDerivative(e,t,i,s,r){const n=z.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=(a-r)*6*e.r+(3*a-4*r+1)*t.r+(-a+r)*6*i.r+(3*a-2*r)*s.r,n.g=(a-r)*6*e.g+(3*a-4*r+1)*t.g+(-a+r)*6*i.g+(3*a-2*r)*s.g,n.b=(a-r)*6*e.b+(3*a-4*r+1)*t.b+(-a+r)*6*i.b+(3*a-2*r)*s.b}static Red(){return new z(1,0,0)}static Green(){return new z(0,1,0)}static Blue(){return new z(0,0,1)}static Black(){return new z(0,0,0)}static get BlackReadOnly(){return z._BlackReadOnly}static White(){return new z(1,1,1)}static Purple(){return new z(.5,0,.5)}static Magenta(){return new z(1,0,1)}static Yellow(){return new z(1,1,0)}static Gray(){return new z(.5,.5,.5)}static Teal(){return new z(0,1,1)}static Random(){return new z(Math.random(),Math.random(),Math.random())}}z._BlackReadOnly=z.Black();class ge{constructor(e=0,t=0,i=0,s=1){this.r=e,this.g=t,this.b=i,this.a=s}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}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 ge.FromArrayToRef(e,t,this),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 ge(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}subtract(e){return new ge(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,this}scale(e){return new ge(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,this}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,this}clampToRef(e=0,t=1,i){return i.r=$.Clamp(this.r,e,t),i.g=$.Clamp(this.g,e,t),i.b=$.Clamp(this.b,e,t),i.a=$.Clamp(this.a,e,t),this}multiply(e){return new ge(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}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),e=e*397^(this.a*255|0),e}clone(){return new ge(this.r,this.g,this.b,this.a)}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)}toHexString(e=!1){const t=Math.round(this.r*255),i=Math.round(this.g*255),s=Math.round(this.b*255);if(e)return"#"+$.ToHex(t)+$.ToHex(i)+$.ToHex(s);const r=Math.round(this.a*255);return"#"+$.ToHex(t)+$.ToHex(i)+$.ToHex(s)+$.ToHex(r)}toLinearSpace(e=!1){const t=new ge;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=Bs(this.r),e.g=Bs(this.g),e.b=Bs(this.b)):(e.r=ws(this.r),e.g=ws(this.g),e.b=ws(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new ge;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=Vs(this.r),e.g=Vs(this.g),e.b=Vs(this.b)):(e.r=Us(this.r),e.g=Us(this.g),e.b=Us(this.b)),e.a=this.a,this}static FromHexString(e){if(e.substring(0,1)!=="#"||e.length!==9&&e.length!==7)return new ge(0,0,0,0);const t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),s=parseInt(e.substring(5,7),16),r=e.length===9?parseInt(e.substring(7,9),16):255;return ge.FromInts(t,i,s,r)}static Lerp(e,t,i){const s=new ge(0,0,0,0);return ge.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,s.a=e.a+(t.a-e.a)*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,c=a-2*n+r,u=a-n,f=e.r*o+i.r*h+t.r*c+s.r*u,d=e.g*o+i.g*h+t.g*c+s.g*u,_=e.b*o+i.b*h+t.b*c+s.b*u,p=e.a*o+i.a*h+t.a*c+s.a*u;return new ge(f,d,_,p)}static Hermite1stDerivative(e,t,i,s,r){const n=new ge;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;n.r=(a-r)*6*e.r+(3*a-4*r+1)*t.r+(-a+r)*6*i.r+(3*a-2*r)*s.r,n.g=(a-r)*6*e.g+(3*a-4*r+1)*t.g+(-a+r)*6*i.g+(3*a-2*r)*s.g,n.b=(a-r)*6*e.b+(3*a-4*r+1)*t.b+(-a+r)*6*i.b+(3*a-2*r)*s.b,n.a=(a-r)*6*e.a+(3*a-4*r+1)*t.a+(-a+r)*6*i.a+(3*a-2*r)*s.a}static FromColor3(e,t=1){return new ge(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new ge(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 ge(e/255,t/255,i/255,s/255)}static CheckColors4(e,t){if(e.length===t*3){const i=[];for(let s=0;s<e.length;s+=3){const r=s/3*4;i[r]=e[s],i[r+1]=e[s+1],i[r+2]=e[s+2],i[r+3]=1}return i}return e}}class pi{}pi.Color3=At.BuildArray(3,z.Black),pi.Color4=At.BuildArray(3,()=>new ge(0,0,0,0)),Re("BABYLON.Color3",z),Re("BABYLON.Color4",ge);const Kr={},jr={},Za=function(l,e,t,i={}){const s=l();xe&&xe.HasTags(e)&&xe.AddTagsTo(s,xe.GetTags(e,!0));const r=Sn(s),n={};for(const a in r){const o=r[a],h=e[a],c=o.type;if(h!=null&&(a!=="uniqueId"||J.AllowLoadingUniqueId))switch(c){case 0:case 6:case 11:s[a]=h;break;case 1:i.cloneTexturesOnlyOnce&&n[h.uniqueId]?s[a]=n[h.uniqueId]:(s[a]=t||h.isRenderTarget?h:h.clone(),n[h.uniqueId]=s[a]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:s[a]=t?h:h.clone();break}}return s};function sh(l){const e=l.getClassName();return Kr[e]||(Kr[e]={}),Kr[e]}function Sn(l){const e=l.getClassName();if(jr[e])return jr[e];jr[e]={};const t=jr[e];let i=l,s=e;for(;s;){const r=Kr[s];for(const o in r)t[o]=r[o];let n,a=!1;do{if(n=Object.getPrototypeOf(i),!n.getClassName){a=!0;break}if(n.getClassName()!==s)break;i=n}while(n);if(a)break;s=n.getClassName(),i=n}return t}function ti(l,e){return(t,i)=>{const s=sh(t);s[i]||(s[i]={type:l,sourceName:e})}}function rh(l,e=null){return(t,i)=>{const s=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[s]},set:function(r){typeof this.equals=="function"&&this.equals(r)||this[s]!==r&&(this[s]=r,t[l].apply(this))},enumerable:!0,configurable:!0})}}function W(l,e=null){return rh(l,e)}function v(l){return ti(0,l)}function Me(l){return ti(1,l)}function Ft(l){return ti(2,l)}function dr(l){return ti(3,l)}function Rn(l){return ti(4,l)}function Ut(l){return ti(5,l)}function xn(l){return ti(6,l)}function nh(l){return ti(7,l)}function Cn(l){return ti(8,l)}function ah(l){return ti(9,l)}function oh(l){return ti(10,l)}function Qa(l){return ti(12,l)}function lh(l){return ti(11,l)}class J{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={}),xe&&(t.tags=xe.GetTags(e));const i=Sn(e);for(const s in i){const r=i[s],n=r.sourceName||s,a=r.type,o=e[s];if(o!=null&&(s!=="uniqueId"||J.AllowLoadingUniqueId))switch(a){case 0:t[n]=o;break;case 1:t[n]=o.serialize();break;case 2:t[n]=o.asArray();break;case 3:t[n]=o.serialize();break;case 4:t[n]=o.asArray();break;case 5:t[n]=o.asArray();break;case 6:t[n]=o.id;break;case 7:t[n]=o.serialize();break;case 8:t[n]=o.asArray();break;case 9:t[n]=o.serialize();break;case 10:t[n]=o.asArray();break;case 11:t[n]=o.id;break;case 12:t[n]=o.asArray();break}}return t}static ParseProperties(e,t,i,s){s||(s="");const r=Sn(t);for(const n in r){const a=r[n],o=e[a.sourceName||n],h=a.type;if(o!=null&&(n!=="uniqueId"||J.AllowLoadingUniqueId)){const c=t;switch(h){case 0:c[n]=o;break;case 1:i&&(c[n]=J._TextureParser(o,i,s));break;case 2:c[n]=z.FromArray(o);break;case 3:c[n]=J._FresnelParametersParser(o);break;case 4:c[n]=ae.FromArray(o);break;case 5:c[n]=E.FromArray(o);break;case 6:i&&(c[n]=i.getLastMeshById(o));break;case 7:c[n]=J._ColorCurvesParser(o);break;case 8:c[n]=ge.FromArray(o);break;case 9:c[n]=J._ImageProcessingConfigurationParser(o);break;case 10:c[n]=K.FromArray(o);break;case 11:i&&(c[n]=i.getCameraById(o));break;case 12:c[n]=M.FromArray(o);break}}}}static Parse(e,t,i,s=null){const r=e();return xe&&xe.AddTagsTo(r,t.tags),J.ParseProperties(t,r,i,s),r}static Clone(e,t,i={}){return Za(e,t,!1,i)}static Instanciate(e,t){return Za(e,t,!0)}}J.AllowLoadingUniqueId=!1,J._ImageProcessingConfigurationParser=l=>{throw fe("ImageProcessingConfiguration")},J._FresnelParametersParser=l=>{throw fe("FresnelParameters")},J._ColorCurvesParser=l=>{throw fe("ColorCurves")},J._TextureParser=(l,e,t)=>{throw fe("Texture")};function ts(l,e,t,i){const s=t.value;t.value=(...r)=>{let n=s;if(typeof _native<"u"&&_native[e]){const a=_native[e];i?n=(...o)=>i(...o)?a(...o):s(...o):n=a}return l[e]=n,n(...r)}}ts.filter=function(l){return(e,t,i)=>ts(e,t,i,l)};class hh{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new B,this._onClonedObservable=new B}}let lt=class Ya{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?!0:this._parentNode?this._parentNode.doNotSerialize:!1}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&&this._parentNode._children!==void 0&&this._parentNode._children!==null){const i=this._parentNode._children.indexOf(this);i!==-1&&this._parentNode._children.splice(i,1),!e&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=e,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(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(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){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){this._isDirty=!1,this._nodeDataStorage=new hh,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new B,this._parentContainer=null,this.animations=new Array,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=M.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new B,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||Ee.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return this._behaviors.indexOf(e)!==-1?this:(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 t===-1?this:(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={},this._cache.parent=void 0}updateCache(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,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?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._cache.parent!==this._parentNode?(this._cache.parent=this._parentNode,!1):this._parentNode&&!this.isSynchronizedWithParent()?!1: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 e===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_syncParentEnabledState(){this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,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?!0:this.parent.isDescendantOf(e):!1}_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=new Array;return this._getDescendants(i,e,t),i}getChildMeshes(e,t){const i=[];return this._getDescendants(i,e,s=>(!t||t(s))&&s.cullingStrategy!==void 0),i}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){if(e!==this._nodeDataStorage._isReady){if(!e){this._nodeDataStorage._isReady=!1;return}this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0}}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]=Ya._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=J.Clone(()=>new Ya(e,this.getScene()),this);if(t&&(s.parent=t),!i){const r=this.getDescendants(!0);for(let n=0;n<r.length;n++){const a=r[n];a.clone(e+"."+a.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=M.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 i of this._behaviors)i.detach();this._behaviors.length=0,this.metadata=null}static ParseAnimationRanges(e,t,i){if(t.ranges)for(let s=0;s<t.ranges.length;s++){const r=t.ranges[s];e.createAnimationRange(r.name,r.from,r.to)}}getHierarchyBoundingVectors(e=!0,t=null){this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);let i,s;const r=this;if(r.getBoundingInfo&&r.subMeshes){const n=r.getBoundingInfo();i=n.boundingBox.minimumWorld.clone(),s=n.boundingBox.maximumWorld.clone()}else i=new E(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new E(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e){const n=this.getDescendants(!1);for(const a of n){const o=a;if(o.computeWorldMatrix(!0),t&&!t(o)||!o.getBoundingInfo||o.getTotalVertices()===0)continue;const c=o.getBoundingInfo().boundingBox,u=c.minimumWorld,f=c.maximumWorld;E.CheckExtends(u,i,s),E.CheckExtends(f,i,s)}}return{min:i,max:s}}};lt._AnimationRangeFactory=(l,e,t)=>{throw fe("AnimationRange")},lt._NodeConstructors={},g([v()],lt.prototype,"name",void 0),g([v()],lt.prototype,"id",void 0),g([v()],lt.prototype,"uniqueId",void 0),g([v()],lt.prototype,"state",void 0),g([v()],lt.prototype,"metadata",void 0);function Mt(){return typeof window<"u"}function qr(){return typeof navigator<"u"}function _r(){return typeof document<"u"}function $a(l){let e="",t=l.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}class F{static _CheckLimit(e,t){let i=F._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},F._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){var i;const s=F._LogLimitOutputs[e];if(!s||!F.MessageLimitReached)return;const r=this._Levels[t];s.current===s.limit&&F[r.name](F.MessageLimitReached.replace(/%LIMIT%/g,""+s.limit).replace(/%TYPE%/g,(i=r.name)!==null&&i!==void 0?i:""))}static _AddLogEntry(e){F._LogCache=e+F._LogCache,F.OnNewCacheEntry&&F.OnNewCacheEntry(e)}static _FormatMessage(e){const t=s=>s<10?"0"+s:""+s,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){if(i!==void 0&&!F._CheckLimit(t,i))return;const s=F._FormatMessage(t),r=this._Levels[e];r.logFunc&&r.logFunc("BJS - "+s);const n=`<div style='color:${r.color}'>${s}</div><br>`;F._AddLogEntry(n),F._GenerateLimitMessage(t,e)}static get LogCache(){return F._LogCache}static ClearLogCache(){F._LogCache="",F._LogLimitOutputs={},F.errorsCount=0}static set LogLevels(e){F.Log=F._LogDisabled,F.Warn=F._LogDisabled,F.Error=F._LogDisabled,[F.MessageLogLevel,F.WarningLogLevel,F.ErrorLogLevel].forEach(t=>{if((e&t)===t){const i=this._Levels[t];F[i.name]=F._LogEnabled.bind(F,t)}})}}F.NoneLogLevel=0,F.MessageLogLevel=1,F.WarningLogLevel=2,F.ErrorLogLevel=4,F.AllLogLevel=7,F.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",F._LogCache="",F._LogLimitOutputs={},F._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],F.errorsCount=0,F.Log=F._LogEnabled.bind(F,F.MessageLogLevel),F.Warn=F._LogEnabled.bind(F,F.WarningLogLevel),F.Error=F._LogEnabled.bind(F,F.ErrorLogLevel);const Ja=(l,e)=>!l||l.getClassName&&l.getClassName()==="Mesh"?null:l.getClassName&&(l.getClassName()==="SubMesh"||l.getClassName()==="PhysicsBody")?l.clone(e):l.clone?l.clone():Array.isArray(l)?l.slice():null;function ch(l){const e=[];do Object.getOwnPropertyNames(l).forEach(function(t){e.indexOf(t)===-1&&e.push(t)});while(l=Object.getPrototypeOf(l));return e}class pr{static DeepCopy(e,t,i,s){const r=ch(e);for(const n of r){if(n[0]==="_"&&(!s||s.indexOf(n)===-1)||n.endsWith("Observable")||i&&i.indexOf(n)!==-1)continue;const a=e[n],o=typeof a;if(o!=="function")try{if(o==="object")if(a instanceof Uint8Array)t[n]=Uint8Array.from(a);else if(a instanceof Array){if(t[n]=[],a.length>0)if(typeof a[0]=="object")for(let h=0;h<a.length;h++){const c=Ja(a[h],t);t[n].indexOf(c)===-1&&t[n].push(c)}else t[n]=a.slice(0)}else t[n]=Ja(a,t);else t[n]=a}catch(h){F.Warn(h.message)}}}}class ii{static get Now(){return Mt()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}function uh(){return typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}class wt{constructor(){this._xhr=uh(),this._requestURL=""}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in wt.CustomRequestHeaders){const t=wt.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return wt.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){wt.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const i of wt.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;i(this._xhr,t)}return t=t.replace("file:http:","http:"),t=t.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)}}wt.CustomRequestHeaders={},wt.CustomRequestModifiers=new Array,wt.SkipRequestModificationForBabylonCDN=!0;class mr{}mr.FilesToLoad={};class fh{static ExponentialBackoff(e=3,t=500){return(i,s,r)=>s.status!==0||r>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,r)*t}}class ks extends Error{}ks._setPrototypeOf=Object.setPrototypeOf||((l,e)=>(l.__proto__=e,l));const is={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class xi extends ks{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",ks._setPrototypeOf(this,xi.prototype)}}const dh=l=>{if(typeof TextDecoder<"u")return new TextDecoder().decode(l);let e="";for(let t=0;t<l.byteLength;t++)e+=String.fromCharCode(l[t]);return e},eo=l=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i,s,r,n,a,o,h,c=0;const u=ArrayBuffer.isView(l)?new Uint8Array(l.buffer,l.byteOffset,l.byteLength):new Uint8Array(l);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=(i&3)<<4|s>>4,o=(s&15)<<2|r>>6,h=r&63,isNaN(s)?o=h=64:isNaN(r)&&(h=64),t+=e.charAt(n)+e.charAt(a)+e.charAt(o)+e.charAt(h);return t},to=l=>atob(l),_h=l=>{const e=to(l),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let s=0;s<t;s++)i[s]=e.charCodeAt(s);return i.buffer},ph="attribute",mh="varying";class gr{constructor(){this.children=[]}isValid(e){return!0}process(e,t){var i,s,r,n,a,o,h;let c="";if(this.line){let u=this.line;const f=t.processor;if(f){f.lineProcessor&&(u=f.lineProcessor(u,t.isFragment,t.processingContext));const d=(s=(i=t.processor)===null||i===void 0?void 0:i.attributeKeywordName)!==null&&s!==void 0?s:ph,_=t.isFragment&&(!((r=t.processor)===null||r===void 0)&&r.varyingFragmentKeywordName)?(n=t.processor)===null||n===void 0?void 0:n.varyingFragmentKeywordName:!t.isFragment&&(!((a=t.processor)===null||a===void 0)&&a.varyingVertexKeywordName)?(o=t.processor)===null||o===void 0?void 0:o.varyingVertexKeywordName:mh;!t.isFragment&&f.attributeProcessor&&this.line.startsWith(d)?u=f.attributeProcessor(this.line,e,t.processingContext):f.varyingProcessor&&(!((h=f.varyingCheck)===null||h===void 0)&&h.call(f,this.line,t.isFragment)||!f.varyingCheck&&this.line.startsWith(_))?u=f.varyingProcessor(this.line,t.isFragment,e,t.processingContext):f.uniformProcessor&&f.uniformRegexp&&f.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(u=f.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):f.uniformBufferProcessor&&f.uniformBufferRegexp&&f.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(u=f.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):f.textureProcessor&&f.textureRegexp&&f.textureRegexp.test(this.line)?u=f.textureProcessor(this.line,t.isFragment,e,t.processingContext):(f.uniformProcessor||f.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?f.uniformProcessor&&(u=f.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):f.uniformBufferProcessor&&(u=f.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,f.endOfUniformBufferProcessor&&(u=f.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}c+=u+`\r
2
2
  `}return this.children.forEach(u=>{c+=u.process(e,t)}),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),c}}class gh{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||t==="\r")continue;if(t[0]==="#"){this._lines.push(t);continue}const i=t.trim();if(!i)continue;if(i.startsWith("//")){this._lines.push(t);continue}const s=i.indexOf(";");if(s===-1)this._lines.push(i);else if(s===i.length-1)i.length>1&&this._lines.push(i);else{const r=t.split(";");for(let n=0;n<r.length;n++){let a=r[n];a&&(a=a.trim(),a&&this._lines.push(a+(n!==r.length-1?";":"")))}}}}}class bn extends gr{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 Eh extends gr{isValid(e){return this.testExpression.isTrue(e)}}class Je{isTrue(e){return!0}static postfixToInfix(e){const t=[];for(const i of e)if(Je._OperatorPriority[i]===void 0)t.push(i);else{const s=t[t.length-1],r=t[t.length-2];t.length-=2,t.push(`(${r}${i}${s})`)}return t[t.length-1]}static infixToPostfix(e){const t=Je._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=()=>{c=c.trim(),c!==""&&(i.push(c),c="")},n=u=>{s<Je._Stack.length-1&&(Je._Stack[++s]=u)},a=()=>Je._Stack[s],o=()=>s===-1?"!!INVALID EXPRESSION!!":Je._Stack[s--];let h=0,c="";for(;h<e.length;){const u=e.charAt(h),f=h<e.length-1?e.substr(h,2):"";if(u==="(")c="",n(u);else if(u===")"){for(r();s!==-1&&a()!=="(";)i.push(o());o()}else if(Je._OperatorPriority[f]>1){for(r();s!==-1&&Je._OperatorPriority[a()]>=Je._OperatorPriority[f];)i.push(o());n(f),h++}else c+=u;h++}for(r();s!==-1;)a()==="("?o():i.push(o());return Je._InfixToPostfixCache.size>=Je.InfixToPostfixCacheLimitSize&&Je.ClearCache(),Je._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){const e=Array.from(Je._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t<Je.InfixToPostfixCacheCleanupSize;t++)Je._InfixToPostfixCache.delete(e[t][0])}}Je.InfixToPostfixCacheLimitSize=5e4,Je.InfixToPostfixCacheCleanupSize=25e3,Je._InfixToPostfixCache=new Map,Je._OperatorPriority={")":0,"(":1,"||":2,"&&":3},Je._Stack=["","","","","","","","","","","","","","","","","","","",""];class Zr extends Je{constructor(e,t=!1){super(),this.define=e,this.not=t}isTrue(e){let t=e[this.define]!==void 0;return this.not&&(t=!t),t}}class Th extends Je{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}class Ah extends Je{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}class vh extends Je{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}isTrue(e){let t=e[this.define];t===void 0&&(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;break}return i}}var Ct;(function(l){l[l.GLSL=0]="GLSL",l[l.WGSL=1]="WGSL"})(Ct||(Ct={}));const Sh=/defined\s*?\((.+?)\)/g,In=/defined\s*?\[(.+?)\]/g,Rh=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,xh=/__decl__/,io=/light\{X\}.(\w*)/g,so=/\{X\}/g,Qr=[];class Oi{static Initialize(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)}static Process(e,t,i,s){var r;!((r=t.processor)===null||r===void 0)&&r.preProcessShaderCode&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),this._ProcessIncludes(e,t,n=>{t.processCodeAfterIncludes&&(n=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",n));const a=this._ProcessShaderConversion(n,t,s);i(a,n)})}static PreProcess(e,t,i,s){var r;!((r=t.processor)===null||r===void 0)&&r.preProcessShaderCode&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),this._ProcessIncludes(e,t,n=>{t.processCodeAfterIncludes&&(n=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",n));const a=this._ApplyPreProcessing(n,t,s);i(a,n)})}static Finalize(e,t,i){return!i.processor||!i.processor.finalizeShaders?{vertexCode:e,fragmentCode:t}:i.processor.finalizeShaders(e,t,i.processingContext)}static _ProcessPrecision(e,t){var i;if(!((i=t.processor)===null||i===void 0)&&i.noPrecision)return e;const s=t.shouldUseHighPrecisionShader;return e.indexOf("precision highp float")===-1?s?e=`precision highp float;
3
3
  `+e:e=`precision mediump float;
4
4
  `+e:s||(e=e.replace("precision highp float","precision mediump float")),e}static _ExtractOperation(e){const i=/defined\((.+)\)/.exec(e);if(i&&i.length)return new Zr(i[1].trim(),e[0]==="!");const s=["==","!=",">=","<=","<",">"];let r="",n=0;for(r of s)if(n=e.indexOf(r),n>-1)break;if(n===-1)return new Zr(e);const a=e.substring(0,n).trim(),o=e.substring(n+r.length).trim();return new vh(a,r,o)}static _BuildSubExpression(e){e=e.replace(Sh,"defined[$1]");const t=Je.infixToPostfix(e),i=[];for(const r of t)if(r!=="||"&&r!=="&&")i.push(r);else if(i.length>=2){let n=i[i.length-1],a=i[i.length-2];i.length-=2;const o=r=="&&"?new Ah:new Th;typeof n=="string"&&(n=n.replace(In,"defined($1)")),typeof a=="string"&&(a=a.replace(In,"defined($1)")),o.leftOperand=typeof a=="string"?this._ExtractOperation(a):a,o.rightOperand=typeof n=="string"?this._ExtractOperation(n):n,i.push(o)}let s=i[i.length-1];return typeof s=="string"&&(s=s.replace(In,"defined($1)")),typeof s=="string"?this._ExtractOperation(s):s}static _BuildExpression(e,t){const i=new Eh,s=e.substring(0,t);let r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),s==="#ifdef"?i.testExpression=new Zr(r):s==="#ifndef"?i.testExpression=new Zr(r,!0):i.testExpression=this._BuildSubExpression(r),i}static _MoveCursorWithinIf(e,t,i){let s=e.currentLine;for(;this._MoveCursor(e,i);){s=e.currentLine;const r=s.substring(0,5).toLowerCase();if(r==="#else"){const n=new gr;t.children.push(n),this._MoveCursor(e,n);return}else if(r==="#elif"){const n=this._BuildExpression(s,5);t.children.push(n),i=n}}}static _MoveCursor(e,t){for(;e.canRead;){e.lineIndex++;const i=e.currentLine;if(i.indexOf("#")>=0){const r=Oi._MoveCursorRegex.exec(i);if(r&&r.length){switch(r[0]){case"#ifdef":{const a=new bn;t.children.push(a);const o=this._BuildExpression(i,6);a.children.push(o),this._MoveCursorWithinIf(e,a,o);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const a=new bn;t.children.push(a);const o=this._BuildExpression(i,7);a.children.push(o),this._MoveCursorWithinIf(e,a,o);break}case"#if":{const a=new bn,o=this._BuildExpression(i,3);t.children.push(a),a.children.push(o),this._MoveCursorWithinIf(e,a,o);break}}continue}}const s=new gr;if(s.line=i,t.children.push(s),i[0]==="#"&&i[1]==="d"){const r=i.replace(";","").split(" ");s.additionalDefineKey=r[1],r.length===3&&(s.additionalDefineValue=r[2])}}return!1}static _EvaluatePreProcessors(e,t,i){const s=new gr,r=new gh;return r.lineIndex=-1,r.lines=e.split(`
@@ -7588,8 +7588,8 @@ void main(void)
7588
7588
  gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);
7589
7589
  }`;U.ShadersStore[Mp]=Pp;const hl="image/png",cl=2,ul=[134,22,135,150,246,214,150,54];function Op(l){const e=new DataView(l.buffer,l.byteOffset,l.byteLength);let t=0;for(let n=0;n<ul.length;n++)if(e.getUint8(t++)!==ul[n])return F.Error("Not a babylon environment map"),null;let i="",s=0;for(;s=e.getUint8(t++);)i+=String.fromCharCode(s);let r=JSON.parse(i);return r=_n(r),r.specular&&(r.specular.specularDataPosition=t,r.specular.lodGenerationScale=r.specular.lodGenerationScale||.8),r}function _n(l){if(l.version>cl)throw new Error(`Unsupported babylon environment map version "${l.version}". Latest supported version is "${cl}".`);return l.version===2||(l=Object.assign(Object.assign({},l),{version:2,imageType:hl})),l}function Dp(l,e){e=_n(e);const t=e.specular;let i=$.Log2(e.width);if(i=Math.round(i)+1,t.mipmaps.length!==6*i)throw new Error(`Unsupported specular mipmaps number "${t.mipmaps.length}"`);const s=new Array(i);for(let r=0;r<i;r++){s[r]=new Array(6);for(let n=0;n<6;n++){const a=t.mipmaps[r*6+n];s[r][n]=new Uint8Array(l.buffer,l.byteOffset+t.specularDataPosition+a.position,a.length)}}return s}function Lp(l,e,t){t=_n(t);const i=t.specular;if(!i)return Promise.resolve();l._lodGenerationScale=i.lodGenerationScale;const s=Dp(e,t);return $n(l,s,t.imageType)}function fl(l,e,t,i,s,r,n,a,o,h,c){return new Promise((u,f)=>{if(t){const d=e.createTexture(null,!0,!0,null,1,null,_=>{f(_)},l);i.getEffect().executeWhenCompiled(()=>{i.externalTextureSamplerBinding=!0,i.onApply=_=>{_._bindTexture("textureSampler",d),_.setFloat2("scale",1,e._features.needsInvertingBitmap&&l instanceof ImageBitmap?-1:1)},e.scenes.length&&(e.scenes[0].postProcessManager.directRender([i],h,!0,r,n),e.restoreDefaultFramebuffer(),d.dispose(),URL.revokeObjectURL(s),u())})}else{if(e._uploadImageToTexture(c,l,r,n),a){const d=o[n];d&&e._uploadImageToTexture(d._texture,l,r,0)}u()}})}function $n(l,e,t=hl){if(!k.IsExponentOfTwo(l.width))throw new Error("Texture size must be a power of two");const i=$.ILog2(l.width)+1,s=l.getEngine();let r=!1,n=!1,a=null,o=null,h=null;const c=s.getCaps();if(l.format=5,l.type=0,l.generateMipMaps=!0,l._cachedAnisotropicFilteringLevel=null,s.updateTextureSamplingMode(3,l),c.textureLOD?s._features.supportRenderAndCopyToLodForFloatTextures?c.textureHalfFloatRender&&c.textureHalfFloatLinearFiltering?(r=!0,l.type=2):c.textureFloatRender&&c.textureFloatLinearFiltering&&(r=!0,l.type=1):r=!1:(r=!1,n=!0,h={}),r)a=new ue("rgbdDecode","rgbdDecode",null,null,1,null,3,s,!1,void 0,l.type,void 0,null,!1),l._isRGBD=!1,l.invertY=!1,o=s.createRenderTargetCubeTexture(l.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:3,type:l.type,format:5});else if(l._isRGBD=!0,l.invertY=!0,n){const d=l._lodGenerationScale,_=l._lodGenerationOffset;for(let p=0;p<3;p++){const T=1-p/2,S=_,x=(i-1)*d+_,b=S+(x-S)*T,I=Math.round(Math.min(Math.max(b,0),x)),R=new ht(s,Fe.Temp);R.isCube=!0,R.invertY=!0,R.generateMipMaps=!1,s.updateTextureSamplingMode(2,R);const C=new Ge(null);switch(C._isCube=!0,C._texture=R,h[I]=C,p){case 0:l._lodTextureLow=C;break;case 1:l._lodTextureMid=C;break;case 2:l._lodTextureHigh=C;break}}}const u=[];for(let f=0;f<e.length;f++)for(let d=0;d<6;d++){const _=e[f][d],p=new Blob([_],{type:t}),m=URL.createObjectURL(p);let T;if(typeof Image>"u"||s._features.forceBitmapOverHTMLImageElement)T=s.createImageBitmap(p,{premultiplyAlpha:"none"}).then(S=>fl(S,s,r,a,m,d,f,n,h,o,l));else{const S=new Image;S.src=m,T=new Promise((x,b)=>{S.onload=()=>{fl(S,s,r,a,m,d,f,n,h,o,l).then(()=>x()).catch(I=>{b(I)})},S.onerror=I=>{b(I)}})}u.push(T)}if(e.length<i){let f;const d=Math.pow(2,i-1-e.length),_=d*d*4;switch(l.type){case 0:{f=new Uint8Array(_);break}case 2:{f=new Uint16Array(_);break}case 1:{f=new Float32Array(_);break}}for(let p=e.length;p<i;p++)for(let m=0;m<6;m++)s._uploadArrayBufferViewToTexture(l,f,m,p)}return Promise.all(u).then(()=>{o&&(s._releaseTexture(l),o._swapAndDie(l)),a&&a.dispose(),n&&(l._lodTextureHigh&&l._lodTextureHigh._texture&&(l._lodTextureHigh._texture.isReady=!0),l._lodTextureMid&&l._lodTextureMid._texture&&(l._lodTextureMid._texture.isReady=!0),l._lodTextureLow&&l._lodTextureLow._texture&&(l._lodTextureLow._texture.isReady=!0))})}function Np(l,e){e=_n(e);const t=e.irradiance;if(!t)return;const i=new us;E.FromArrayToRef(t.x,0,i.x),E.FromArrayToRef(t.y,0,i.y),E.FromArrayToRef(t.z,0,i.z),E.FromArrayToRef(t.xx,0,i.xx),E.FromArrayToRef(t.yy,0,i.yy),E.FromArrayToRef(t.zz,0,i.zz),E.FromArrayToRef(t.yz,0,i.yz),E.FromArrayToRef(t.zx,0,i.zx),E.FromArrayToRef(t.xy,0,i.xy),l._sphericalPolynomial=i}function Fp(l,e,t,i,s){const r=l.getEngine().createRawCubeTexture(null,l.width,l.format,l.type,l.generateMipMaps,l.invertY,l.samplingMode,l._compression),n=$n(r,e).then(()=>l);return l.onRebuildCallback=a=>({proxy:n,isReady:!0,isAsync:!0}),l._source=Fe.CubeRawRGBD,l._bufferViewArrayArray=e,l._lodGenerationScale=i,l._lodGenerationOffset=s,l._sphericalPolynomial=t,$n(l,e).then(()=>(l.isReady=!0,l))}class Jn extends It{constructor(e,t,i,s=5,r=0,n=!1,a=!1,o=3,h=null){super("",e),this._texture=e.getEngine().createRawCubeTexture(t,i,s,r,n,a,o,h)}update(e,t,i,s,r=null){this._texture.getEngine().updateRawCubeTexture(this._texture,e,t,i,s,r)}updateRGBDAsync(e,t=null,i=.8,s=0){return Fp(this._texture,e,t,i,s).then(()=>{})}clone(){return J.Clone(()=>{const e=this.getScene(),t=this._texture,i=new Jn(e,t._bufferViewArray,t.width,t.format,t.type,t.generateMipMaps,t.invertY,t.samplingMode,t._compression);return t.source===Fe.CubeRawRGBD&&i.updateRGBDAsync(t._bufferViewArrayArray,t._sphericalPolynomial,t._lodGenerationScale,t._lodGenerationOffset),i},this)}}const ea="EXT_lights_image_based";class wp{constructor(e){this.name=ea,this._loader=e,this.enabled=this._loader.isExtensionUsed(ea)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights}}loadSceneAsync(e,t){return Z.LoadExtensionAsync(e,t,this.name,(i,s)=>{const r=new Array;r.push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen(`${i}`);const n=_e.Get(`${i}/light`,this._lights,s.light);return r.push(this._loadLightAsync(`/extensions/${this.name}/lights/${s.light}`,n).then(a=>{this._loader.babylonScene.environmentTexture=a})),this._loader.logClose(),Promise.all(r).then(()=>{})})}_loadLightAsync(e,t){if(!t._loaded){const i=new Array;this._loader.logOpen(`${e}`);const s=new Array(t.specularImages.length);for(let r=0;r<t.specularImages.length;r++){const n=t.specularImages[r];s[r]=new Array(n.length);for(let a=0;a<n.length;a++){const o=`${e}/specularImages/${r}/${a}`;this._loader.logOpen(`${o}`);const h=n[a],c=_e.Get(o,this._loader.gltf.images,h);i.push(this._loader.loadImageAsync(`/images/${h}`,c).then(u=>{s[r][a]=u})),this._loader.logClose()}}this._loader.logClose(),t._loaded=Promise.all(i).then(()=>{const r=new Jn(this._loader.babylonScene,null,t.specularImageSize);if(r.name=t.name||"environment",t._babylonTexture=r,t.intensity!=null&&(r.level=t.intensity),t.rotation){let h=K.FromArray(t.rotation);this._loader.babylonScene.useRightHandedSystem||(h=K.Inverse(h)),M.FromQuaternionToRef(h,r.getReflectionTextureMatrix())}if(!t.irradianceCoefficients)throw new Error(`${e}: Irradiance coefficients are missing`);const n=Qs.FromArray(t.irradianceCoefficients);n.scaleInPlace(t.intensity),n.convertIrradianceToLambertianRadiance();const a=us.FromHarmonics(n),o=(s.length-1)/$.Log2(t.specularImageSize);return r.updateRGBDAsync(s,a,o)})}return t._loaded.then(()=>t._babylonTexture)}}Z.RegisterExtension(ea,l=>new wp(l)),ne.prototype.thinInstanceAdd=function(l,e=!0){if(!this.getScene().getEngine().getCaps().instancedArrays)return F.Error("Thin Instances are not supported on this device as Instanced Array extension not supported"),-1;this._thinInstanceUpdateBufferSize("matrix",Array.isArray(l)?l.length:1);const t=this._thinInstanceDataStorage.instancesCount;if(Array.isArray(l))for(let i=0;i<l.length;++i)this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,l[i],i===l.length-1&&e);else this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,l,e);return t},ne.prototype.thinInstanceAddSelf=function(l=!0){return this.thinInstanceAdd(M.IdentityReadOnly,l)},ne.prototype.thinInstanceRegisterAttribute=function(l,e){l===A.ColorKind&&(l=A.ColorInstanceKind),this.removeVerticesData(l),this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.strides[l]=e,this._userThinInstanceBuffersStorage.sizes[l]=e*Math.max(32,this._thinInstanceDataStorage.instancesCount),this._userThinInstanceBuffersStorage.data[l]=new Float32Array(this._userThinInstanceBuffersStorage.sizes[l]),this._userThinInstanceBuffersStorage.vertexBuffers[l]=new A(this.getEngine(),this._userThinInstanceBuffersStorage.data[l],l,!0,!1,e,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[l])},ne.prototype.thinInstanceSetMatrixAt=function(l,e,t=!0){if(!this._thinInstanceDataStorage.matrixData||l>=this._thinInstanceDataStorage.instancesCount)return!1;const i=this._thinInstanceDataStorage.matrixData;return e.copyToArray(i,l*16),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[l]=e),t&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},ne.prototype.thinInstanceSetAttributeAt=function(l,e,t,i=!0){return l===A.ColorKind&&(l=A.ColorInstanceKind),!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[l]||e>=this._thinInstanceDataStorage.instancesCount?!1:(this._thinInstanceUpdateBufferSize(l,0),this._userThinInstanceBuffersStorage.data[l].set(t,e*this._userThinInstanceBuffersStorage.strides[l]),i&&this.thinInstanceBufferUpdated(l),!0)},Object.defineProperty(ne.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(l){var e,t;const i=(e=this._thinInstanceDataStorage.matrixData)!==null&&e!==void 0?e:(t=this.source)===null||t===void 0?void 0:t._thinInstanceDataStorage.matrixData,s=i?i.length/16:0;l<=s&&(this._thinInstanceDataStorage.instancesCount=l)},enumerable:!0,configurable:!0}),ne.prototype._thinInstanceCreateMatrixBuffer=function(l,e,t=!1){l===A.ColorKind&&(l=A.ColorInstanceKind);const i=new Gs(this.getEngine(),e,!t,16,!1,!0);for(let s=0;s<4;s++)this.setVerticesBuffer(i.createVertexBuffer(l+s,s*4,4));return i},ne.prototype.thinInstanceSetBuffer=function(l,e,t=0,i=!1){var s,r,n;t=t||16,l==="matrix"?((s=this._thinInstanceDataStorage.matrixBuffer)===null||s===void 0||s.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=e?e.length:32*t,this._thinInstanceDataStorage.matrixData=e,this._thinInstanceDataStorage.worldMatrices=null,e!==null?(this._thinInstanceDataStorage.instancesCount=e.length/t,this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",e,i),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)):(this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo())):l==="previousMatrix"?((r=this._thinInstanceDataStorage.previousMatrixBuffer)===null||r===void 0||r.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=null,this._thinInstanceDataStorage.previousMatrixData=e,e!==null&&(this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",e,i))):(l===A.ColorKind&&(l=A.ColorInstanceKind),e===null?!((n=this._userThinInstanceBuffersStorage)===null||n===void 0)&&n.data[l]&&(this.removeVerticesData(l),delete this._userThinInstanceBuffersStorage.data[l],delete this._userThinInstanceBuffersStorage.strides[l],delete this._userThinInstanceBuffersStorage.sizes[l],delete this._userThinInstanceBuffersStorage.vertexBuffers[l]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[l]=e,this._userThinInstanceBuffersStorage.strides[l]=t,this._userThinInstanceBuffersStorage.sizes[l]=e.length,this._userThinInstanceBuffersStorage.vertexBuffers[l]=new A(this.getEngine(),e,l,!i,!1,t,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[l])))},ne.prototype.thinInstanceBufferUpdated=function(l){var e,t,i;l==="matrix"?(e=this._thinInstanceDataStorage.matrixBuffer)===null||e===void 0||e.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount):l==="previousMatrix"?(t=this._thinInstanceDataStorage.previousMatrixBuffer)===null||t===void 0||t.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount):(l===A.ColorKind&&(l=A.ColorInstanceKind),!((i=this._userThinInstanceBuffersStorage)===null||i===void 0)&&i.vertexBuffers[l]&&this._userThinInstanceBuffersStorage.vertexBuffers[l].updateDirectly(this._userThinInstanceBuffersStorage.data[l],0))},ne.prototype.thinInstancePartialBufferUpdate=function(l,e,t){var i;l==="matrix"?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(e,t):(l===A.ColorKind&&(l=A.ColorInstanceKind),!((i=this._userThinInstanceBuffersStorage)===null||i===void 0)&&i.vertexBuffers[l]&&this._userThinInstanceBuffersStorage.vertexBuffers[l].updateDirectly(e,t))},ne.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];const l=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=new Array;for(let e=0;e<this._thinInstanceDataStorage.instancesCount;++e)this._thinInstanceDataStorage.worldMatrices[e]=M.FromArray(l,e*16)}return this._thinInstanceDataStorage.worldMatrices},ne.prototype.thinInstanceRefreshBoundingInfo=function(l=!1,e=!1,t=!1){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return;const i=this._thinInstanceDataStorage.boundingVectors;if(l||!this.rawBoundingInfo){i.length=0,this.refreshBoundingInfo(e,t);const n=this.getBoundingInfo();this.rawBoundingInfo=new $t(n.minimum,n.maximum)}const s=this.getBoundingInfo(),r=this._thinInstanceDataStorage.matrixData;if(i.length===0)for(let n=0;n<s.boundingBox.vectors.length;++n)i.push(s.boundingBox.vectors[n].clone());D.Vector3[0].setAll(Number.POSITIVE_INFINITY),D.Vector3[1].setAll(Number.NEGATIVE_INFINITY);for(let n=0;n<this._thinInstanceDataStorage.instancesCount;++n){M.FromArrayToRef(r,n*16,D.Matrix[0]);for(let a=0;a<i.length;++a)E.TransformCoordinatesToRef(i[a],D.Matrix[0],D.Vector3[2]),D.Vector3[0].minimizeInPlace(D.Vector3[2]),D.Vector3[1].maximizeInPlace(D.Vector3[2])}s.reConstruct(D.Vector3[0],D.Vector3[1]),this._updateBoundingInfo()},ne.prototype._thinInstanceUpdateBufferSize=function(l,e=1){var t,i,s;l===A.ColorKind&&(l=A.ColorInstanceKind);const r=l==="matrix";if(!r&&(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.strides[l]))return;const n=r?16:this._userThinInstanceBuffersStorage.strides[l],a=r?this._thinInstanceDataStorage.matrixBufferSize:this._userThinInstanceBuffersStorage.sizes[l];let o=r?this._thinInstanceDataStorage.matrixData:this._userThinInstanceBuffersStorage.data[l];const h=(this._thinInstanceDataStorage.instancesCount+e)*n;let c=a;for(;c<h;)c*=2;if(!o||a!=c){if(!o)o=new Float32Array(c);else{const u=new Float32Array(c);u.set(o,0),o=u}r?((t=this._thinInstanceDataStorage.matrixBuffer)===null||t===void 0||t.dispose(),this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",o,!1),this._thinInstanceDataStorage.matrixData=o,this._thinInstanceDataStorage.matrixBufferSize=c,this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&((i=this._thinInstanceDataStorage.previousMatrixBuffer)===null||i===void 0||i.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",o,!1))):((s=this._userThinInstanceBuffersStorage.vertexBuffers[l])===null||s===void 0||s.dispose(),this._userThinInstanceBuffersStorage.data[l]=o,this._userThinInstanceBuffersStorage.sizes[l]=c,this._userThinInstanceBuffersStorage.vertexBuffers[l]=new A(this.getEngine(),o,l,!0,!1,n,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[l]))}},ne.prototype._thinInstanceInitializeUserStorage=function(){this._userThinInstanceBuffersStorage||(this._userThinInstanceBuffersStorage={data:{},sizes:{},vertexBuffers:{},strides:{}})},ne.prototype._disposeThinInstanceSpecificData=function(){var l;!((l=this._thinInstanceDataStorage)===null||l===void 0)&&l.matrixBuffer&&(this._thinInstanceDataStorage.matrixBuffer.dispose(),this._thinInstanceDataStorage.matrixBuffer=null)};const ta="EXT_mesh_gpu_instancing";class Bp{constructor(e){this.name=ta,this._loader=e,this.enabled=this._loader.isExtensionUsed(ta)}dispose(){this._loader=null}loadNodeAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{this._loader._disableInstancedMesh++;const n=this._loader.loadNodeAsync(`/nodes/${t.index}`,t,i);if(this._loader._disableInstancedMesh--,!t._primitiveBabylonMeshes)return n;const a=new Array;let o=0;const h=c=>{if(r.attributes[c]==null){a.push(Promise.resolve(null));return}const u=_e.Get(`${s}/attributes/${c}`,this._loader.gltf.accessors,r.attributes[c]);if(a.push(this._loader._loadFloatAccessorAsync(`/accessors/${u.bufferView}`,u)),o===0)o=u.count;else if(o!==u.count)throw new Error(`${s}/attributes: Instance buffer accessors do not have the same count.`)};return h("TRANSLATION"),h("ROTATION"),h("SCALE"),n.then(c=>Promise.all(a).then(([u,f,d])=>{const _=new Float32Array(o*16);D.Vector3[0].copyFromFloats(0,0,0),D.Quaternion[0].copyFromFloats(0,0,0,1),D.Vector3[1].copyFromFloats(1,1,1);for(let p=0;p<o;++p)u&&E.FromArrayToRef(u,p*3,D.Vector3[0]),f&&K.FromArrayToRef(f,p*4,D.Quaternion[0]),d&&E.FromArrayToRef(d,p*3,D.Vector3[1]),M.ComposeToRef(D.Vector3[1],D.Quaternion[0],D.Vector3[0],D.Matrix[0]),D.Matrix[0].copyToArray(_,p*16);for(const p of t._primitiveBabylonMeshes)p.thinInstanceSetBuffer("matrix",_,16,!0);return c}))})}}Z.RegisterExtension(ta,l=>new Bp(l));class Wi{static get Default(){return Wi._Default||(Wi._Default=new Wi),Wi._Default}constructor(){const e=Wi.Configuration.decoder;this._decoderModulePromise=k.LoadScriptAsync(k.GetAbsoluteUrl(e.url)).then(()=>MeshoptDecoder.ready)}dispose(){delete this._decoderModulePromise}decodeGltfBufferAsync(e,t,i,s,r){return this._decoderModulePromise.then(()=>{const n=new Uint8Array(t*i);return MeshoptDecoder.decodeGltfBuffer(n,t,i,e,s,r),n})}}Wi.Configuration={decoder:{url:"https://preview.babylonjs.com/meshopt_decoder.js"}},Wi._Default=null;const ia="EXT_meshopt_compression";class Up{constructor(e){this.name=ia,this.enabled=e.isExtensionUsed(ia),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,t){return Z.LoadExtensionAsync(e,t,this.name,(i,s)=>{const r=t;if(r._meshOptData)return r._meshOptData;const n=_e.Get(`${e}/buffer`,this._loader.gltf.buffers,s.buffer);return r._meshOptData=this._loader.loadBufferAsync(`/buffers/${n.index}`,n,s.byteOffset||0,s.byteLength).then(a=>Wi.Default.decodeGltfBufferAsync(a,s.count,s.byteStride,s.mode,s.filter)),r._meshOptData})}}Z.RegisterExtension(ia,l=>new Up(l));const sa="EXT_texture_webp";class Vp{constructor(e){this.name=sa,this._loader=e,this.enabled=e.isExtensionUsed(sa)}dispose(){this._loader=null}_loadTextureAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=t.sampler==null?Z.DefaultSampler:_e.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=_e.Get(`${s}/source`,this._loader.gltf.images,r.source);return this._loader._createTextureAsync(e,n,a,o=>{i(o)},void 0,!t._textureInfo.nonColorData)})}}Z.RegisterExtension(sa,l=>new Vp(l));const ra="KHR_draco_mesh_compression";class kp{constructor(e){this.name=ra,this._loader=e,this.enabled=Xt.DecoderAvailable&&this._loader.isExtensionUsed(ra)}dispose(){delete this.dracoCompression,this._loader=null}_loadVertexDataAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{if(t.mode!=null){if(t.mode!==5&&t.mode!==4)throw new Error(`${e}: Unsupported mode ${t.mode}`);if(t.mode===5)throw new Error(`${e}: Mode ${t.mode} is not currently supported`)}const n={},a={},o=(c,u)=>{const f=r.attributes[c];if(f===void 0||t.attributes[c]===void 0)return;n[u]=f;const d=_e.Get(`${e}/attributes/${c}`,this._loader.gltf.accessors,t.attributes[c]);if(d.normalized&&d.componentType!==5126){let _=1;switch(d.componentType){case 5120:_=127;break;case 5121:_=255;break;case 5122:_=32767;break;case 5123:_=65535;break}a[u]=_}i._delayInfo=i._delayInfo||[],i._delayInfo.indexOf(u)===-1&&i._delayInfo.push(u)};o("POSITION",A.PositionKind),o("NORMAL",A.NormalKind),o("TANGENT",A.TangentKind),o("TEXCOORD_0",A.UVKind),o("TEXCOORD_1",A.UV2Kind),o("TEXCOORD_2",A.UV3Kind),o("TEXCOORD_3",A.UV4Kind),o("TEXCOORD_4",A.UV5Kind),o("TEXCOORD_5",A.UV6Kind),o("JOINTS_0",A.MatricesIndicesKind),o("WEIGHTS_0",A.MatricesWeightsKind),o("COLOR_0",A.ColorKind);const h=_e.Get(s,this._loader.gltf.bufferViews,r.bufferView);return h._dracoBabylonGeometry||(h._dracoBabylonGeometry=this._loader.loadBufferViewAsync(`/bufferViews/${h.index}`,h).then(c=>(this.dracoCompression||Xt.Default).decodeMeshAsync(c,n,a).then(f=>{const d=new Bt(i.name,this._loader.babylonScene);return f.applyToGeometry(d),d}).catch(f=>{throw new Error(`${e}: ${f.message}`)}))),h._dracoBabylonGeometry})}}Z.RegisterExtension(ra,l=>new kp(l));const na="KHR_lights_punctual";class Gp{constructor(e){this.name=na,this._loader=e,this.enabled=this._loader.isExtensionUsed(na)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,_e.Assign(this._lights)}}loadNodeAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>this._loader.loadNodeAsync(e,t,n=>{let a;const o=_e.Get(s,this._lights,r.light),h=o.name||n.name;switch(this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,o.type){case"directional":{const c=new fi(h,E.Backward(),this._loader.babylonScene);c.position.setAll(0),a=c;break}case"point":{a=new Dr(h,E.Zero(),this._loader.babylonScene);break}case"spot":{const c=new Kt(h,E.Zero(),E.Backward(),0,1,this._loader.babylonScene);c.angle=(o.spot&&o.spot.outerConeAngle||Math.PI/4)*2,c.innerAngle=(o.spot&&o.spot.innerConeAngle||0)*2,a=c;break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${s}: Invalid light type (${o.type})`)}a._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,o._babylonLight=a,a.falloffType=Ae.FALLOFF_GLTF,a.diffuse=o.color?z.FromArray(o.color):z.White(),a.intensity=o.intensity==null?1:o.intensity,a.range=o.range==null?Number.MAX_VALUE:o.range,a.parent=n,this._loader._babylonLights.push(a),Z.AddPointerMetadata(a,s),i(n)}))}}Z.RegisterExtension(na,l=>new Gp(l));const aa="KHR_materials_pbrSpecularGlossiness";class Hp{constructor(e){this.name=aa,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(aa)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialBasePropertiesAsync(e,t,i)),n.push(this._loadSpecularGlossinessPropertiesAsync(s,t,r,i)),this._loader.loadMaterialAlphaProperties(e,t,i),Promise.all(n).then(()=>{})})}_loadSpecularGlossinessPropertiesAsync(e,t,i,s){if(!(s instanceof j))throw new Error(`${e}: Material type not supported`);const r=new Array;return s.metallic=null,s.roughness=null,i.diffuseFactor?(s.albedoColor=z.FromArray(i.diffuseFactor),s.alpha=i.diffuseFactor[3]):s.albedoColor=z.White(),s.reflectivityColor=i.specularFactor?z.FromArray(i.specularFactor):z.White(),s.microSurface=i.glossinessFactor==null?1:i.glossinessFactor,i.diffuseTexture&&r.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTexture`,i.diffuseTexture,n=>{n.name=`${s.name} (Diffuse)`,s.albedoTexture=n})),i.specularGlossinessTexture&&(r.push(this._loader.loadTextureInfoAsync(`${e}/specularGlossinessTexture`,i.specularGlossinessTexture,n=>{n.name=`${s.name} (Specular Glossiness)`,s.reflectivityTexture=n,s.reflectivityTexture.hasAlpha=!0})),s.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(r).then(()=>{})}}Z.RegisterExtension(aa,l=>new Hp(l));const oa="KHR_materials_unlit";class Wp{constructor(e){this.name=oa,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(oa)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,()=>this._loadUnlitPropertiesAsync(e,t,i))}_loadUnlitPropertiesAsync(e,t,i){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const s=new Array;i.unlit=!0;const r=t.pbrMetallicRoughness;return r&&(r.baseColorFactor?(i.albedoColor=z.FromArray(r.baseColorFactor),i.alpha=r.baseColorFactor[3]):i.albedoColor=z.White(),r.baseColorTexture&&s.push(this._loader.loadTextureInfoAsync(`${e}/baseColorTexture`,r.baseColorTexture,n=>{n.name=`${i.name} (Base Color)`,i.albedoTexture=n}))),t.doubleSided&&(i.backFaceCulling=!1,i.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,t,i),Promise.all(s).then(()=>{})}}Z.RegisterExtension(oa,l=>new Wp(l));const la="KHR_materials_clearcoat";class zp{constructor(e){this.name=la,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(la)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadClearCoatPropertiesAsync(s,r,i)),Promise.all(n).then(()=>{})})}_loadClearCoatPropertiesAsync(e,t,i){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const s=new Array;return i.clearCoat.isEnabled=!0,i.clearCoat.useRoughnessFromMainTexture=!1,i.clearCoat.remapF0OnInterfaceChange=!1,t.clearcoatFactor!=null?i.clearCoat.intensity=t.clearcoatFactor:i.clearCoat.intensity=0,t.clearcoatTexture&&s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatTexture`,t.clearcoatTexture,r=>{r.name=`${i.name} (ClearCoat Intensity)`,i.clearCoat.texture=r})),t.clearcoatRoughnessFactor!=null?i.clearCoat.roughness=t.clearcoatRoughnessFactor:i.clearCoat.roughness=0,t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatRoughnessTexture`,t.clearcoatRoughnessTexture,r=>{r.name=`${i.name} (ClearCoat Roughness)`,i.clearCoat.textureRoughness=r}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatNormalTexture`,t.clearcoatNormalTexture,r=>{r.name=`${i.name} (ClearCoat Normal)`,i.clearCoat.bumpTexture=r})),i.invertNormalMapX=!i.getScene().useRightHandedSystem,i.invertNormalMapY=i.getScene().useRightHandedSystem,t.clearcoatNormalTexture.scale!=null&&(i.clearCoat.bumpTexture.level=t.clearcoatNormalTexture.scale)),Promise.all(s).then(()=>{})}}Z.RegisterExtension(la,l=>new zp(l));const ha="KHR_materials_iridescence";class Xp{constructor(e){this.name=ha,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(ha)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadIridescencePropertiesAsync(s,r,i)),Promise.all(n).then(()=>{})})}_loadIridescencePropertiesAsync(e,t,i){var s,r,n,a,o;if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const h=new Array;return i.iridescence.isEnabled=!0,i.iridescence.intensity=(s=t.iridescenceFactor)!==null&&s!==void 0?s:0,i.iridescence.indexOfRefraction=(n=(r=t.iridescenceIor)!==null&&r!==void 0?r:t.iridescenceIOR)!==null&&n!==void 0?n:1.3,i.iridescence.minimumThickness=(a=t.iridescenceThicknessMinimum)!==null&&a!==void 0?a:100,i.iridescence.maximumThickness=(o=t.iridescenceThicknessMaximum)!==null&&o!==void 0?o:400,t.iridescenceTexture&&h.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceTexture`,t.iridescenceTexture,c=>{c.name=`${i.name} (Iridescence Intensity)`,i.iridescence.texture=c})),t.iridescenceThicknessTexture&&h.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceThicknessTexture`,t.iridescenceThicknessTexture,c=>{c.name=`${i.name} (Iridescence Thickness)`,i.iridescence.thicknessTexture=c})),Promise.all(h).then(()=>{})}}Z.RegisterExtension(ha,l=>new Xp(l));const ca="KHR_materials_anisotropy";class Yp{constructor(e){this.name=ca,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(ca)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadIridescencePropertiesAsync(s,r,i)),Promise.all(n).then(()=>{})})}_loadIridescencePropertiesAsync(e,t,i){var s,r;if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const n=new Array;return i.anisotropy.isEnabled=!0,i.anisotropy.intensity=(s=t.anisotropyStrength)!==null&&s!==void 0?s:0,i.anisotropy.angle=(r=t.anisotropyRotation)!==null&&r!==void 0?r:0,t.anisotropyTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/anisotropyTexture`,t.anisotropyTexture,a=>{a.name=`${i.name} (Anisotropy Intensity)`,i.anisotropy.texture=a})),Promise.all(n).then(()=>{})}}Z.RegisterExtension(ca,l=>new Yp(l));const ua="KHR_materials_emissive_strength";class Kp{constructor(e){this.name=ua,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(ua)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>this._loader.loadMaterialPropertiesAsync(e,t,i).then(()=>{this._loadEmissiveProperties(s,r,i)}))}_loadEmissiveProperties(e,t,i){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);t.emissiveStrength!==void 0&&i.emissiveColor.scaleToRef(t.emissiveStrength,i.emissiveColor)}}Z.RegisterExtension(ua,l=>new Kp(l));const fa="KHR_materials_sheen";class jp{constructor(e){this.name=fa,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(fa)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadSheenPropertiesAsync(s,r,i)),Promise.all(n).then(()=>{})})}_loadSheenPropertiesAsync(e,t,i){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const s=new Array;return i.sheen.isEnabled=!0,i.sheen.intensity=1,t.sheenColorFactor!=null?i.sheen.color=z.FromArray(t.sheenColorFactor):i.sheen.color=z.Black(),t.sheenColorTexture&&s.push(this._loader.loadTextureInfoAsync(`${e}/sheenColorTexture`,t.sheenColorTexture,r=>{r.name=`${i.name} (Sheen Color)`,i.sheen.texture=r})),t.sheenRoughnessFactor!==void 0?i.sheen.roughness=t.sheenRoughnessFactor:i.sheen.roughness=0,t.sheenRoughnessTexture&&(t.sheenRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/sheenRoughnessTexture`,t.sheenRoughnessTexture,r=>{r.name=`${i.name} (Sheen Roughness)`,i.sheen.textureRoughness=r}))),i.sheen.albedoScaling=!0,i.sheen.useRoughnessFromMainTexture=!1,Promise.all(s).then(()=>{})}}Z.RegisterExtension(fa,l=>new jp(l));const da="KHR_materials_specular";class qp{constructor(e){this.name=da,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(da)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadSpecularPropertiesAsync(s,r,i)),Promise.all(n).then(()=>{})})}_loadSpecularPropertiesAsync(e,t,i){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const s=new Array;return t.specularFactor!==void 0&&(i.metallicF0Factor=t.specularFactor),t.specularColorFactor!==void 0&&(i.metallicReflectanceColor=z.FromArray(t.specularColorFactor)),t.specularTexture&&(t.specularTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/specularTexture`,t.specularTexture,r=>{r.name=`${i.name} (Specular F0 Strength)`,i.metallicReflectanceTexture=r,i.useOnlyMetallicFromMetallicReflectanceTexture=!0}))),t.specularColorTexture&&s.push(this._loader.loadTextureInfoAsync(`${e}/specularColorTexture`,t.specularColorTexture,r=>{r.name=`${i.name} (Specular F0 Color)`,i.reflectanceTexture=r})),Promise.all(s).then(()=>{})}}Z.RegisterExtension(da,l=>new qp(l));const _a="KHR_materials_ior";class pn{constructor(e){this.name=_a,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(_a)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadIorPropertiesAsync(s,r,i)),Promise.all(n).then(()=>{})})}_loadIorPropertiesAsync(e,t,i){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);return t.ior!==void 0?i.indexOfRefraction=t.ior:i.indexOfRefraction=pn._DEFAULT_IOR,Promise.resolve()}}pn._DEFAULT_IOR=1.5,Z.RegisterExtension(_a,l=>new pn(l));const qt="KHR_materials_variants";class ds{constructor(e){this.name=qt,this._loader=e,this.enabled=this._loader.isExtensionUsed(qt)}dispose(){this._loader=null}static GetAvailableVariants(e){const t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]}getAvailableVariants(e){return ds.GetAvailableVariants(e)}static SelectVariant(e,t){const i=this._GetExtensionMetadata(e);if(!i)throw new Error(`Cannot select variant on a glTF mesh that does not have the ${qt} extension`);const s=r=>{const n=i.variants[r];if(n)for(const a of n)a.mesh.material=a.material};if(t instanceof Array)for(const r of t)s(r);else s(t);i.lastSelected=t}selectVariant(e,t){return ds.SelectVariant(e,t)}static Reset(e){const t=this._GetExtensionMetadata(e);if(!t)throw new Error(`Cannot reset on a glTF mesh that does not have the ${qt} extension`);for(const i of t.original)i.mesh.material=i.material;t.lastSelected=null}reset(e){return ds.Reset(e)}static GetLastSelectedVariant(e){const t=this._GetExtensionMetadata(e);if(!t)throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${qt} extension`);return t.lastSelected}getLastSelectedVariant(e){return ds.GetLastSelectedVariant(e)}static _GetExtensionMetadata(e){var t,i;return((i=(t=e==null?void 0:e._internalMetadata)===null||t===void 0?void 0:t.gltf)===null||i===void 0?void 0:i[qt])||null}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._variants=t.variants}}_loadMeshPrimitiveAsync(e,t,i,s,r,n){return Z.LoadExtensionAsync(e,r,this.name,(a,o)=>{const h=new Array;return h.push(this._loader._loadMeshPrimitiveAsync(e,t,i,s,r,c=>{if(n(c),c instanceof ne){const u=Z._GetDrawMode(e,r.mode),f=this._loader.rootBabylonMesh,d=f?f._internalMetadata=f._internalMetadata||{}:{},_=d.gltf=d.gltf||{},p=_[qt]=_[qt]||{lastSelected:null,original:[],variants:{}};p.original.push({mesh:c,material:c.material});for(let m=0;m<o.mappings.length;++m){const T=o.mappings[m],S=_e.Get(`${a}/mappings/${m}/material`,this._loader.gltf.materials,T.material);h.push(this._loader._loadMaterialAsync(`#/materials/${T.material}`,S,c,u,x=>{for(let b=0;b<T.variants.length;++b){const I=T.variants[b],R=_e.Get(`/extensions/${qt}/variants/${I}`,this._variants,I);p.variants[R.name]=p.variants[R.name]||[],p.variants[R.name].push({mesh:c,material:x}),c.onClonedObservable.add(C=>{const y=C;let w=null,G=y;do{if(G=G.parent,!G)return;w=ds._GetExtensionMetadata(G)}while(w===null);if(f&&w===ds._GetExtensionMetadata(f)){G._internalMetadata={};for(const te in f._internalMetadata)G._internalMetadata[te]=f._internalMetadata[te];G._internalMetadata.gltf=[];for(const te in f._internalMetadata.gltf)G._internalMetadata.gltf[te]=f._internalMetadata.gltf[te];G._internalMetadata.gltf[qt]={lastSelected:null,original:[],variants:{}};for(const te of w.original)G._internalMetadata.gltf[qt].original.push({mesh:te.mesh,material:te.material});for(const te in w.variants)if(Object.prototype.hasOwnProperty.call(w.variants,te)){G._internalMetadata.gltf[qt].variants[te]=[];for(const Q of w.variants[te])G._internalMetadata.gltf[qt].variants[te].push({mesh:Q.mesh,material:Q.material})}w=G._internalMetadata.gltf[qt]}for(const te of w.original)te.mesh===c&&(te.mesh=y);for(const te of w.variants[R.name])te.mesh===c&&(te.mesh=y)})}}))}}})),Promise.all(h).then(([c])=>c)})}}Z.RegisterExtension(qt,l=>new ds(l));class pa{static _GetDefaultOptions(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:P.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}}constructor(e,t){this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._options={...pa._GetDefaultOptions(),...e},this._scene=t,this._scene._transmissionHelper=this,this.onErrorObservable=new B,this._scene.onDisposeObservable.addOnce(()=>{this.dispose()}),this._parseScene(),this._setupRenderTargets()}updateOptions(e){if(!Object.keys(e).filter(r=>this._options[r]!==e[r]).length)return;const i={...this._options,...e},s=this._options;this._options=i,i.renderSize!==s.renderSize||i.renderTargetTextureType!==s.renderTargetTextureType||i.generateMipmaps!==s.generateMipmaps||!this._opaqueRenderTarget?this._setupRenderTargets():(this._opaqueRenderTarget.samples=i.samples,this._opaqueRenderTarget.lodGenerationScale=i.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=i.lodGenerationOffset)}getOpaqueTarget(){return this._opaqueRenderTarget}_shouldRenderAsTransmission(e){return e?!!(e instanceof j&&e.subSurface.isRefractionEnabled):!1}_addMesh(e){this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),k.SetImmediate(()=>{this._shouldRenderAsTransmission(e.material)?(e.material.refractionTexture=this._opaqueRenderTarget,this._transparentMeshesCache.indexOf(e)===-1&&this._transparentMeshesCache.push(e)):this._opaqueMeshesCache.indexOf(e)===-1&&this._opaqueMeshesCache.push(e)})}_removeMesh(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];let t=this._transparentMeshesCache.indexOf(e);t!==-1&&this._transparentMeshesCache.splice(t,1),t=this._opaqueMeshesCache.indexOf(e),t!==-1&&this._opaqueMeshesCache.splice(t,1)}_parseScene(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))}_onMeshMaterialChanged(e){const t=this._transparentMeshesCache.indexOf(e),i=this._opaqueMeshesCache.indexOf(e);this._shouldRenderAsTransmission(e.material)?(e.material instanceof j&&(e.material.subSurface.refractionTexture=this._opaqueRenderTarget),i!==-1?(this._opaqueMeshesCache.splice(i,1),this._transparentMeshesCache.push(e)):t===-1&&this._transparentMeshesCache.push(e)):t!==-1?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):i===-1&&this._opaqueMeshesCache.push(e)}_setupRenderTargets(){var e,t;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new Dt("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=(t=(e=this._options.clearColor)===null||e===void 0?void 0:e.clone())!==null&&t!==void 0?t:this._scene.clearColor.clone(),this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples;let i,s;this._opaqueRenderTarget.onBeforeBindObservable.add(r=>{s=this._scene.environmentIntensity,this._scene.environmentIntensity=1,i=this._scene.imageProcessingConfiguration.applyByPostProcess,this._options.clearColor?r.clearColor.copyFrom(this._options.clearColor):this._scene.clearColor.toLinearSpaceToRef(r.clearColor,this._scene.getEngine().useExactSrgbConversions),this._scene.imageProcessingConfiguration._applyByPostProcess=!0}),this._opaqueRenderTarget.onAfterUnbindObservable.add(()=>{this._scene.environmentIntensity=s,this._scene.imageProcessingConfiguration._applyByPostProcess=i}),this._transparentMeshesCache.forEach(r=>{this._shouldRenderAsTransmission(r.material)&&(r.material.refractionTexture=this._opaqueRenderTarget)})}dispose(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[]}}const ma="KHR_materials_transmission";class Zp{constructor(e){this.name=ma,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(ma),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialBasePropertiesAsync(e,t,i)),n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadTransparentPropertiesAsync(s,t,i,r)),Promise.all(n).then(()=>{})})}_loadTransparentPropertiesAsync(e,t,i,s){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const r=i;if(r.subSurface.isRefractionEnabled=!0,r.subSurface.volumeIndexOfRefraction=1,r.subSurface.useAlbedoToTintRefraction=!0,s.transmissionFactor!==void 0){r.subSurface.refractionIntensity=s.transmissionFactor;const n=r.getScene();r.subSurface.refractionIntensity&&!n._transmissionHelper&&new pa({},r.getScene())}else return r.subSurface.refractionIntensity=0,r.subSurface.isRefractionEnabled=!1,Promise.resolve();return r.subSurface.minimumThickness=0,r.subSurface.maximumThickness=0,s.transmissionTexture?(s.transmissionTexture.nonColorData=!0,this._loader.loadTextureInfoAsync(`${e}/transmissionTexture`,s.transmissionTexture,void 0).then(n=>{r.subSurface.refractionIntensityTexture=n,r.subSurface.useGltfStyleTextures=!0})):Promise.resolve()}}Z.RegisterExtension(ma,l=>new Zp(l));const ga="KHR_materials_translucency";class Qp{constructor(e){this.name=ga,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(ga),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialBasePropertiesAsync(e,t,i)),n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadTranslucentPropertiesAsync(s,t,i,r)),Promise.all(n).then(()=>{})})}_loadTranslucentPropertiesAsync(e,t,i,s){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);const r=i;if(r.subSurface.isTranslucencyEnabled=!0,r.subSurface.volumeIndexOfRefraction=1,r.subSurface.minimumThickness=0,r.subSurface.maximumThickness=0,r.subSurface.useAlbedoToTintTranslucency=!0,s.translucencyFactor!==void 0)r.subSurface.translucencyIntensity=s.translucencyFactor;else return r.subSurface.translucencyIntensity=0,r.subSurface.isTranslucencyEnabled=!1,Promise.resolve();return s.translucencyTexture?(s.translucencyTexture.nonColorData=!0,this._loader.loadTextureInfoAsync(`${e}/translucencyTexture`,s.translucencyTexture).then(n=>{r.subSurface.translucencyIntensityTexture=n})):Promise.resolve()}}Z.RegisterExtension(ga,l=>new Qp(l));const Ea="KHR_materials_volume";class $p{constructor(e){this.name=Ea,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ea),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return n.push(this._loader.loadMaterialBasePropertiesAsync(e,t,i)),n.push(this._loader.loadMaterialPropertiesAsync(e,t,i)),n.push(this._loadVolumePropertiesAsync(s,t,i,r)),Promise.all(n).then(()=>{})})}_loadVolumePropertiesAsync(e,t,i,s){if(!(i instanceof j))throw new Error(`${e}: Material type not supported`);if(!i.subSurface.isRefractionEnabled&&!i.subSurface.isTranslucencyEnabled||!s.thicknessFactor)return Promise.resolve();i.subSurface.volumeIndexOfRefraction=i.indexOfRefraction;const r=s.attenuationDistance!==void 0?s.attenuationDistance:Number.MAX_VALUE;return i.subSurface.tintColorAtDistance=r,s.attenuationColor!==void 0&&s.attenuationColor.length==3&&i.subSurface.tintColor.copyFromFloats(s.attenuationColor[0],s.attenuationColor[1],s.attenuationColor[2]),i.subSurface.minimumThickness=0,i.subSurface.maximumThickness=s.thicknessFactor,i.subSurface.useThicknessAsDepth=!0,s.thicknessTexture?(s.thicknessTexture.nonColorData=!0,this._loader.loadTextureInfoAsync(`${e}/thicknessTexture`,s.thicknessTexture).then(n=>{i.subSurface.thicknessTexture=n,i.subSurface.useGltfStyleTextures=!0})):Promise.resolve()}}Z.RegisterExtension(Ea,l=>new $p(l));const Ta="KHR_mesh_quantization";class Jp{constructor(e){this.name=Ta,this.enabled=e.isExtensionUsed(Ta)}dispose(){}}Z.RegisterExtension(Ta,l=>new Jp(l));const Aa="KHR_texture_basisu";class em{constructor(e){this.name=Aa,this._loader=e,this.enabled=e.isExtensionUsed(Aa)}dispose(){this._loader=null}_loadTextureAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=t.sampler==null?Z.DefaultSampler:_e.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=_e.Get(`${s}/source`,this._loader.gltf.images,r.source);return this._loader._createTextureAsync(e,n,a,o=>{i(o)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)})}}Z.RegisterExtension(Aa,l=>new em(l));const va="KHR_texture_transform";class tm{constructor(e){this.name=va,this._loader=e,this.enabled=this._loader.isExtensionUsed(va)}dispose(){this._loader=null}loadTextureInfoAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>this._loader.loadTextureInfoAsync(e,t,n=>{if(!(n instanceof O))throw new Error(`${s}: Texture type not supported`);r.offset&&(n.uOffset=r.offset[0],n.vOffset=r.offset[1]),n.uRotationCenter=0,n.vRotationCenter=0,r.rotation&&(n.wAng=-r.rotation),r.scale&&(n.uScale=r.scale[0],n.vScale=r.scale[1]),r.texCoord!=null&&(n.coordinatesIndex=r.texCoord),i(n)}))}}Z.RegisterExtension(va,l=>new tm(l));const Sa="KHR_xmp_json_ld";class im{constructor(e){this.name=Sa,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(Sa)}dispose(){this._loader=null}onLoading(){var e,t,i;if(this._loader.rootBabylonMesh===null)return;const s=(e=this._loader.gltf.extensions)===null||e===void 0?void 0:e.KHR_xmp_json_ld,r=(i=(t=this._loader.gltf.asset)===null||t===void 0?void 0:t.extensions)===null||i===void 0?void 0:i.KHR_xmp_json_ld;if(s&&r){const n=+r.packet;s.packets&&n<s.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=s.packets[n])}}}Z.RegisterExtension(Sa,l=>new im(l));function ir(l,e,t,i){return z.FromArray(e,t).scale(i)}function sm(l,e,t,i){return e[t+3]*i}function Qe(l,e,t,i){return e[t]*i}function Ra(l,e,t,i){return-e[t]*i}function mn(l,e,t,i){return e[t+1]*i}function dl(l,e,t,i){return e[t]*i*2}function xa(l){return{scale:[new qe(N.ANIMATIONTYPE_FLOAT,`${l}.uScale`,Qe,()=>2),new qe(N.ANIMATIONTYPE_FLOAT,`${l}.vScale`,mn,()=>2)],offset:[new qe(N.ANIMATIONTYPE_FLOAT,`${l}.uOffset`,Qe,()=>2),new qe(N.ANIMATIONTYPE_FLOAT,`${l}.vOffset`,mn,()=>2)],rotation:[new qe(N.ANIMATIONTYPE_FLOAT,`${l}.wAng`,Ra,()=>1)]}}class zi extends wr{buildAnimations(e,t,i,s,r){r(e._babylonCamera,this._buildAnimation(t,i,s))}}class qe extends wr{buildAnimations(e,t,i,s,r){for(const n in e._data)r(e._data[n].babylonMaterial,this._buildAnimation(t,i,s))}}class Ur extends wr{buildAnimations(e,t,i,s,r){r(e._babylonLight,this._buildAnimation(t,i,s))}}const rm={__array__:{__target__:!0,...Br}},nm={__array__:{__target__:!0,orthographic:{xmag:[new zi(N.ANIMATIONTYPE_FLOAT,"orthoLeft",Ra,()=>1),new zi(N.ANIMATIONTYPE_FLOAT,"orthoRight",mn,()=>1)],ymag:[new zi(N.ANIMATIONTYPE_FLOAT,"orthoBottom",Ra,()=>1),new zi(N.ANIMATIONTYPE_FLOAT,"orthoTop",mn,()=>1)],zfar:[new zi(N.ANIMATIONTYPE_FLOAT,"maxZ",Qe,()=>1)],znear:[new zi(N.ANIMATIONTYPE_FLOAT,"minZ",Qe,()=>1)]},perspective:{yfov:[new zi(N.ANIMATIONTYPE_FLOAT,"fov",Qe,()=>1)],zfar:[new zi(N.ANIMATIONTYPE_FLOAT,"maxZ",Qe,()=>1)],znear:[new zi(N.ANIMATIONTYPE_FLOAT,"minZ",Qe,()=>1)]}}},am={__array__:{__target__:!0,pbrMetallicRoughness:{baseColorFactor:[new qe(N.ANIMATIONTYPE_COLOR3,"albedoColor",ir,()=>4),new qe(N.ANIMATIONTYPE_FLOAT,"alpha",sm,()=>4)],metallicFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"metallic",Qe,()=>1)],roughnessFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"roughness",Qe,()=>1)],baseColorTexture:{extensions:{KHR_texture_transform:xa("albedoTexture")}}},emissiveFactor:[new qe(N.ANIMATIONTYPE_COLOR3,"emissiveColor",ir,()=>3)],normalTexture:{scale:[new qe(N.ANIMATIONTYPE_FLOAT,"bumpTexture.level",Qe,()=>1)]},occlusionTexture:{strength:[new qe(N.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",Qe,()=>1)],extensions:{KHR_texture_transform:xa("ambientTexture")}},emissiveTexture:{extensions:{KHR_texture_transform:xa("emissiveTexture")}},extensions:{KHR_materials_ior:{ior:[new qe(N.ANIMATIONTYPE_FLOAT,"indexOfRefraction",Qe,()=>1)]},KHR_materials_clearcoat:{clearcoatFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",Qe,()=>1)],clearcoatRoughnessFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",Qe,()=>1)]},KHR_materials_sheen:{sheenColorFactor:[new qe(N.ANIMATIONTYPE_COLOR3,"sheen.color",ir,()=>3)],sheenRoughnessFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"sheen.roughness",Qe,()=>1)]},KHR_materials_specular:{specularFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"metallicF0Factor",Qe,()=>1)],specularColorFactor:[new qe(N.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",ir,()=>3)]},KHR_materials_emissive_strength:{emissiveStrength:[new qe(N.ANIMATIONTYPE_FLOAT,"emissiveIntensity",Qe,()=>1)]},KHR_materials_transmission:{transmissionFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",Qe,()=>1)]},KHR_materials_volume:{attenuationColor:[new qe(N.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",ir,()=>3)],attenuationDistance:[new qe(N.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",Qe,()=>1)],thicknessFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",Qe,()=>1)]},KHR_materials_iridescence:{iridescenceFactor:[new qe(N.ANIMATIONTYPE_FLOAT,"iridescence.intensity",Qe,()=>1)],iridescenceIor:[new qe(N.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",Qe,()=>1)],iridescenceThicknessMinimum:[new qe(N.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",Qe,()=>1)],iridescenceThicknessMaximum:[new qe(N.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",Qe,()=>1)]},KHR_materials_anisotropy:{anisotropyStrength:[new qe(N.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",Qe,()=>1)],anisotropyRotation:[new qe(N.ANIMATIONTYPE_FLOAT,"anisotropy.angle",Qe,()=>1)]}}}},om={KHR_lights_punctual:{lights:{__array__:{__target__:!0,color:[new Ur(N.ANIMATIONTYPE_COLOR3,"diffuse",ir,()=>3)],intensity:[new Ur(N.ANIMATIONTYPE_FLOAT,"intensity",Qe,()=>1)],range:[new Ur(N.ANIMATIONTYPE_FLOAT,"range",Qe,()=>1)],spot:{innerConeAngle:[new Ur(N.ANIMATIONTYPE_FLOAT,"innerAngle",dl,()=>1)],outerConeAngle:[new Ur(N.ANIMATIONTYPE_FLOAT,"angle",dl,()=>1)]}}}}},lm={nodes:rm,materials:am,cameras:nm,extensions:om},Ca="KHR_animation_pointer";class hm{constructor(e){this.name=Ca,this._loader=e}get enabled(){return this._loader.isExtensionUsed(Ca)}dispose(){this._loader=null}_loadAnimationChannelAsync(e,t,i,s,r){var n;const a=(n=s.target.extensions)===null||n===void 0?void 0:n.KHR_animation_pointer;if(!a)return null;s.target.path!=="pointer"&&F.Warn(`${e}/target/path: Value (${s.target.path}) must be (pointer) when using the ${this.name} extension`),s.target.node!=null&&F.Warn(`${e}/target/node: Value (${s.target.node}) must not be present when using the ${this.name} extension`);const o=`${e}/extensions/${this.name}`,h=a.pointer;if(!h)throw new Error(`${o}: Pointer is missing`);const c=this._parseAnimationPointer(`${o}/pointer`,h);return c?this._loader._loadAnimationChannelFromTargetInfoAsync(e,t,i,s,c,r):(F.Warn(`${o}/pointer: Invalid pointer (${h}) skipped`),null)}_parseAnimationPointer(e,t){if(!t.startsWith("/"))return F.Warn(`${e}: Value (${t}) must start with a slash`),null;const i=t.split("/");i.shift();let s=lm,r=this._loader.gltf,n;for(const a of i){if(s.__array__)s=s.__array__;else if(s=s[a],!s)return null;r=r&&r[a],s.__target__&&(n=r)}return!n||!Array.isArray(s)?null:{target:n,properties:s}}}Z.RegisterExtension(Ca,l=>new hm(l));class ba{constructor(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}_clone(){return new ba(this.frame,this.action,this.onlyOnce)}}class ys{get loop(){return this._loop}set loop(e){e!==this._loop&&(this._loop=e,this.updateOptions({loop:e}))}get currentTime(){var e;if(this._htmlAudioElement)return this._htmlAudioElement.currentTime;if(!((e=L.audioEngine)===null||e===void 0)&&e.audioContext&&(this.isPlaying||this.isPaused)){const t=this.isPaused?0:L.audioEngine.audioContext.currentTime-this._startTime;return this._currentTime+t}return 0}get spatialSound(){return this._spatialSound}set spatialSound(e){if(e==this._spatialSound)return;const t=this.isPlaying;this.pause(),e?(this._spatialSound=e,this._updateSpatialParameters()):this._disableSpatialSound(),t&&this.play()}constructor(e,t,i,s=null,r){var n,a,o,h,c;if(this.autoplay=!1,this._loop=!1,this.useCustomAttenuation=!1,this.isPlaying=!1,this.isPaused=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this.metadata=null,this.onEndedObservable=new B,this._spatialSound=!1,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._currentTime=0,this._position=E.Zero(),this._localDirection=new E(1,0,0),this._volume=1,this._isReadyToPlay=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=e,i=i||Ee.LastCreatedScene,!!i)if(this._scene=i,ys._SceneComponentInitialization(i),this._readyToPlayCallback=s,this._customAttenuationFunction=(u,f,d,_,p)=>f<d?u*(1-f/d):0,r&&(this.autoplay=r.autoplay||!1,this._loop=r.loop||!1,r.volume!==void 0&&(this._volume=r.volume),this._spatialSound=(n=r.spatialSound)!==null&&n!==void 0?n:!1,this.maxDistance=(a=r.maxDistance)!==null&&a!==void 0?a:100,this.useCustomAttenuation=(o=r.useCustomAttenuation)!==null&&o!==void 0?o:!1,this.rolloffFactor=r.rolloffFactor||1,this.refDistance=r.refDistance||1,this.distanceModel=r.distanceModel||"linear",this._playbackRate=r.playbackRate||1,this._streaming=(h=r.streaming)!==null&&h!==void 0?h:!1,this._length=r.length,this._offset=r.offset),!((c=L.audioEngine)===null||c===void 0)&&c.canUseWebAudio&&L.audioEngine.audioContext){this._soundGain=L.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._outputAudioNode=this._soundGain,this._spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.addSound(this);let u=!0;if(t)try{typeof t=="string"?this._urlType="String":t instanceof ArrayBuffer?this._urlType="ArrayBuffer":t instanceof HTMLMediaElement?this._urlType="MediaElement":t instanceof MediaStream?this._urlType="MediaStream":t instanceof AudioBuffer?this._urlType="AudioBuffer":Array.isArray(t)&&(this._urlType="Array");let f=[],d=!1;switch(this._urlType){case"MediaElement":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=L.audioEngine.audioContext.createMediaElementSource(t),this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=L.audioEngine.audioContext.createMediaStreamSource(t),this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":t.byteLength>0&&(d=!0,this._soundLoaded(t));break;case"AudioBuffer":this._audioBufferLoaded(t);break;case"String":f.push(t);case"Array":f.length===0&&(f=t);for(let _=0;_<f.length;_++){const p=f[_];if(d=r&&r.skipCodecCheck||p.indexOf(".mp3",p.length-4)!==-1&&L.audioEngine.isMP3supported||p.indexOf(".ogg",p.length-4)!==-1&&L.audioEngine.isOGGsupported||p.indexOf(".wav",p.length-4)!==-1||p.indexOf(".m4a",p.length-4)!==-1||p.indexOf(".mp4",p.length-4)!==-1||p.indexOf("blob:")!==-1,d){this._streaming?(this._htmlAudioElement=new Audio(p),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,k.SetCorsBehavior(p,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",()=>{this._isReadyToPlay=!0,this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(p,m=>{this._soundLoaded(m)},void 0,!0,!0,m=>{m&&F.Error("XHR "+m.status+" error on: "+p+"."),F.Error("Sound creation aborted."),this._scene.mainSoundTrack.removeSound(this)});break}}break;default:u=!1;break}u?d||(this._isReadyToPlay=!0,this._readyToPlayCallback&&setTimeout(()=>{this._readyToPlayCallback&&this._readyToPlayCallback()},1e3)):F.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch{F.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.removeSound(this)}}else this._scene.mainSoundTrack.addSound(this),L.audioEngine&&!L.audioEngine.WarnedWebAudioUnsupported&&(F.Error("Web Audio is not supported by your browser."),L.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&setTimeout(()=>{this._readyToPlayCallback&&this._readyToPlayCallback()},1e3)}dispose(){var e;!((e=L.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,this.soundTrackId===-1?this._scene.mainSoundTrack.removeSound(this):this._scene.soundTracks&&this._scene.soundTracks[this.soundTrackId].removeSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._streamingSource&&this._streamingSource.disconnect(),this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedTransformNode=null),this._clearTimeoutsAndObservers())}isReady(){return this._isReadyToPlay}getClassName(){return"Sound"}_audioBufferLoaded(e){var t;!((t=L.audioEngine)===null||t===void 0)&&t.audioContext&&(this._audioBuffer=e,this._isReadyToPlay=!0,this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback())}_soundLoaded(e){var t;!((t=L.audioEngine)===null||t===void 0)&&t.audioContext&&L.audioEngine.audioContext.decodeAudioData(e,i=>{this._audioBufferLoaded(i)},i=>{F.Error("Error while decoding audio data for: "+this.name+" / Error: "+i)})}setAudioBuffer(e){var t;!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&(this._audioBuffer=e,this._isReadyToPlay=!0)}updateOptions(e){var t,i,s,r,n,a,o,h,c,u,f;e&&(this.loop=(t=e.loop)!==null&&t!==void 0?t:this.loop,this.maxDistance=(i=e.maxDistance)!==null&&i!==void 0?i:this.maxDistance,this.useCustomAttenuation=(s=e.useCustomAttenuation)!==null&&s!==void 0?s:this.useCustomAttenuation,this.rolloffFactor=(r=e.rolloffFactor)!==null&&r!==void 0?r:this.rolloffFactor,this.refDistance=(n=e.refDistance)!==null&&n!==void 0?n:this.refDistance,this.distanceModel=(a=e.distanceModel)!==null&&a!==void 0?a:this.distanceModel,this._playbackRate=(o=e.playbackRate)!==null&&o!==void 0?o:this._playbackRate,this._length=(h=e.length)!==null&&h!==void 0?h:void 0,this.spatialSound=(c=e.spatialSound)!==null&&c!==void 0?c:this._spatialSound,this._setOffset((u=e.offset)!==null&&u!==void 0?u:void 0),this.setVolume((f=e.volume)!==null&&f!==void 0?f:this._volume),this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?(this._htmlAudioElement.playbackRate=this._playbackRate,this._htmlAudioElement.loop!==this.loop&&(this._htmlAudioElement.loop=this.loop)):this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.loop!==this.loop&&(this._soundSource.loop=this.loop),this._offset!==void 0&&this._soundSource.loopStart!==this._offset&&(this._soundSource.loopStart=this._offset),this._length!==void 0&&this._length!==this._soundSource.loopEnd&&(this._soundSource.loopEnd=(this._offset|0)+this._length))))}_createSpatialParameters(){var e,t;!((e=L.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&L.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=(t=this._soundPanner)!==null&&t!==void 0?t:L.audioEngine.audioContext.createPanner(),this._soundPanner&&this._outputAudioNode&&(this._updateSpatialParameters(),this._soundPanner.connect(this._outputAudioNode),this._inputAudioNode=this._soundPanner))}_disableSpatialSound(){var e;this._spatialSound&&(this._inputAudioNode=this._soundGain,(e=this._soundPanner)===null||e===void 0||e.disconnect(),this._soundPanner=null,this._spatialSound=!1)}_updateSpatialParameters(){this._spatialSound&&(this._soundPanner?this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel):this._createSpatialParameters())}switchPanningModelToHRTF(){this._panningModel="HRTF",this._switchPanningModel()}switchPanningModelToEqualPower(){this._panningModel="equalpower",this._switchPanningModel()}_switchPanningModel(){var e;!((e=L.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)}connectToSoundTrackAudioNode(e){var t;!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._outputAudioNode&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(e),this._isOutputConnected=!0)}setDirectionalCone(e,t,i){if(t<e){F.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");return}this._coneInnerAngle=e,this._coneOuterAngle=t,this._coneOuterGain=i,this._isDirectional=!0,this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length))}get directionalConeInnerAngle(){return this._coneInnerAngle}set directionalConeInnerAngle(e){var t;if(e!=this._coneInnerAngle){if(this._coneOuterAngle<e){F.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");return}this._coneInnerAngle=e,!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}}get directionalConeOuterAngle(){return this._coneOuterAngle}set directionalConeOuterAngle(e){var t;if(e!=this._coneOuterAngle){if(e<this._coneInnerAngle){F.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");return}this._coneOuterAngle=e,!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}}setPosition(e){var t;e.equals(this._position)||(this._position.copyFrom(e),!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._spatialSound&&this._soundPanner&&!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&(this._soundPanner.positionX.value=this._position.x,this._soundPanner.positionY.value=this._position.y,this._soundPanner.positionZ.value=this._position.z))}setLocalDirectionToMesh(e){var t;this._localDirection=e,!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._connectedTransformNode&&this.isPlaying&&this._updateDirection()}_updateDirection(){if(!this._connectedTransformNode||!this._soundPanner)return;const e=this._connectedTransformNode.getWorldMatrix(),t=E.TransformNormal(this._localDirection,e);t.normalize(),this._soundPanner.orientationX.value=t.x,this._soundPanner.orientationY.value=t.y,this._soundPanner.orientationZ.value=t.z}updateDistanceFromListener(){var e;if(!((e=L.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._connectedTransformNode&&this.useCustomAttenuation&&this._soundGain&&this._scene.activeCamera){const t=this._scene.audioListenerPositionProvider?this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length():this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}}setAttenuationFunction(e){this._customAttenuationFunction=e}play(e,t,i){var s,r,n,a;if(this._isReadyToPlay&&this._scene.audioEnabled&&(!((s=L.audioEngine)===null||s===void 0)&&s.audioContext))try{this._clearTimeoutsAndObservers();let o=e?((r=L.audioEngine)===null||r===void 0?void 0:r.audioContext.currentTime)+e:(n=L.audioEngine)===null||n===void 0?void 0:n.audioContext.currentTime;if((!this._soundSource||!this._streamingSource)&&this._spatialSound&&this._soundPanner&&(!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&(this._soundPanner.positionX.value=this._position.x,this._soundPanner.positionY.value=this._position.y,this._soundPanner.positionZ.value=this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedTransformNode?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming){if(this._streamingSource||(this._streamingSource=L.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=()=>{this._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._inputAudioNode&&this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement){const h=()=>{var c,u;if(!((c=L.audioEngine)===null||c===void 0)&&c.unlocked){const f=this._htmlAudioElement.play();f!==void 0&&f.catch(()=>{var d,_;(d=L.audioEngine)===null||d===void 0||d.lock(),(this.loop||this.autoplay)&&(this._audioUnlockedObserver=(_=L.audioEngine)===null||_===void 0?void 0:_.onAudioUnlockedObservable.addOnce(()=>{h()}))})}else(this.loop||this.autoplay)&&(this._audioUnlockedObserver=(u=L.audioEngine)===null||u===void 0?void 0:u.onAudioUnlockedObservable.addOnce(()=>{h()}))};h()}}else{const h=()=>{var c,u,f,d;if(!((c=L.audioEngine)===null||c===void 0)&&c.audioContext){if(i=i||this._length,t!==void 0&&this._setOffset(t),this._soundSource){const _=this._soundSource;_.onended=()=>{_.disconnect()}}if(this._soundSource=(u=L.audioEngine)===null||u===void 0?void 0:u.audioContext.createBufferSource(),this._soundSource&&this._inputAudioNode){this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,t!==void 0&&(this._soundSource.loopStart=t),i!==void 0&&(this._soundSource.loopEnd=(t|0)+i),this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.onended=()=>{this._onended()},o=e?((f=L.audioEngine)===null||f===void 0?void 0:f.audioContext.currentTime)+e:L.audioEngine.audioContext.currentTime;const _=((this.isPaused?this.currentTime:0)+((d=this._offset)!==null&&d!==void 0?d:0))%this._soundSource.buffer.duration;this._soundSource.start(o,_,this.loop?void 0:i)}}};((a=L.audioEngine)===null||a===void 0?void 0:a.audioContext.state)==="suspended"?this._tryToPlayTimeout=setTimeout(()=>{var c;((c=L.audioEngine)===null||c===void 0?void 0:c.audioContext.state)==="suspended"?(L.audioEngine.lock(),(this.loop||this.autoplay)&&(this._audioUnlockedObserver=L.audioEngine.onAudioUnlockedObservable.addOnce(()=>{h()}))):h()},500):h()}this._startTime=o,this.isPlaying=!0,this.isPaused=!1}catch(o){F.Error("Error while trying to play audio: "+this.name+", "+o.message)}}_onended(){this.isPlaying=!1,this._startTime=0,this._currentTime=0,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)}stop(e){var t;if(this.isPlaying)if(this._clearTimeoutsAndObservers(),this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(!((t=L.audioEngine)===null||t===void 0)&&t.audioContext&&this._soundSource){const i=e?L.audioEngine.audioContext.currentTime+e:void 0;this._soundSource.onended=()=>{this.isPlaying=!1,this.isPaused=!1,this._startTime=0,this._currentTime=0,this._soundSource&&(this._soundSource.onended=()=>{}),this._onended()},this._soundSource.stop(i)}else this.isPlaying=!1;else this.isPaused&&(this.isPaused=!1,this._startTime=0,this._currentTime=0)}pause(){var e;this.isPlaying&&(this._clearTimeoutsAndObservers(),this._streaming?(this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect(),this.isPlaying=!1,this.isPaused=!0):!((e=L.audioEngine)===null||e===void 0)&&e.audioContext&&this._soundSource&&(this._soundSource.onended=()=>{},this._soundSource.stop(),this.isPlaying=!1,this.isPaused=!0,this._currentTime+=L.audioEngine.audioContext.currentTime-this._startTime))}setVolume(e,t){var i;!((i=L.audioEngine)===null||i===void 0)&&i.canUseWebAudio&&this._soundGain&&(t&&L.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(L.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,L.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,L.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e}setPlaybackRate(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))}getPlaybackRate(){return this._playbackRate}getVolume(){return this._volume}attachToMesh(e){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,this._spatialSound||(this._spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length))),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=t=>this._onRegisterAfterWorldMatrixUpdate(t),this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)}detachFromMesh(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)}_onRegisterAfterWorldMatrixUpdate(e){var t;if(!e.getBoundingInfo)this.setPosition(e.absolutePosition);else{const s=e.getBoundingInfo();this.setPosition(s.boundingSphere.centerWorld)}!((t=L.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()}clone(){if(this._streaming)return null;{const e=()=>{this._isReadyToPlay?(i._audioBuffer=this.getAudioBuffer(),i._isReadyToPlay=!0,i.autoplay&&i.play(0,this._offset,this._length)):setTimeout(e,300)},t={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},i=new ys(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,t);return this.useCustomAttenuation&&i.setAttenuationFunction(this._customAttenuationFunction),i.setPosition(this._position),i.setPlaybackRate(this._playbackRate),e(),i}}getAudioBuffer(){return this._audioBuffer}getSoundSource(){return this._soundSource}getSoundGain(){return this._soundGain}serialize(){const e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId,metadata:this.metadata};return this._spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e}static Parse(e,t,i,s){const r=e.name;let n;e.url?n=i+e.url:n=i+r;const a={autoplay:e.autoplay,loop:e.loop,volume:e.volume,spatialSound:e.spatialSound,maxDistance:e.maxDistance,rolloffFactor:e.rolloffFactor,refDistance:e.refDistance,distanceModel:e.distanceModel,playbackRate:e.playbackRate};let o;if(!s)o=new ys(r,n,t,()=>{t.removePendingData(o)},a),t.addPendingData(o);else{const h=()=>{s._isReadyToPlay?(o._audioBuffer=s.getAudioBuffer(),o._isReadyToPlay=!0,o.autoplay&&o.play(0,o._offset,o._length)):setTimeout(h,300)};o=new ys(r,new ArrayBuffer(0),t,null,a),h()}if(e.position){const h=E.FromArray(e.position);o.setPosition(h)}if(e.isDirectional&&(o.setDirectionalCone(e.coneInnerAngle||360,e.coneOuterAngle||360,e.coneOuterGain||0),e.localDirectionToMesh)){const h=E.FromArray(e.localDirectionToMesh);o.setLocalDirectionToMesh(h)}if(e.connectedMeshId){const h=t.getMeshById(e.connectedMeshId);h&&o.attachToMesh(h)}return e.metadata&&(o.metadata=e.metadata),o}_setOffset(e){this._offset!==e&&(this.isPaused&&(this.stop(),this.isPaused=!1),this._offset=e)}_clearTimeoutsAndObservers(){var e;this._tryToPlayTimeout&&(clearTimeout(this._tryToPlayTimeout),this._tryToPlayTimeout=null),this._audioUnlockedObserver&&((e=L.audioEngine)===null||e===void 0||e.onAudioUnlockedObservable.remove(this._audioUnlockedObserver),this._audioUnlockedObserver=null)}}ys._SceneComponentInitialization=l=>{throw fe("AudioSceneComponent")};class cm{constructor(e,t,i){if(this.loop=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._volume=1,this.isPlaying=!1,this.isPaused=!1,this._sounds=[],this._weights=[],t.length!==i.length)throw new Error("Sounds length does not equal weights length");this.loop=e,this._weights=i;let s=0;for(const n of i)s+=n;const r=s>0?1/s:0;for(let n=0;n<this._weights.length;n++)this._weights[n]*=r;this._sounds=t;for(const n of this._sounds)n.onEndedObservable.add(()=>{this._onended()})}get directionalConeInnerAngle(){return this._coneInnerAngle}set directionalConeInnerAngle(e){if(e!==this._coneInnerAngle){if(this._coneOuterAngle<e){F.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");return}this._coneInnerAngle=e;for(const t of this._sounds)t.directionalConeInnerAngle=e}}get directionalConeOuterAngle(){return this._coneOuterAngle}set directionalConeOuterAngle(e){if(e!==this._coneOuterAngle){if(e<this._coneInnerAngle){F.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");return}this._coneOuterAngle=e;for(const t of this._sounds)t.directionalConeOuterAngle=e}}get volume(){return this._volume}set volume(e){if(e!==this._volume)for(const t of this._sounds)t.setVolume(e)}_onended(){this._currentIndex!==void 0&&(this._sounds[this._currentIndex].autoplay=!1),this.loop&&this.isPlaying?this.play():this.isPlaying=!1}pause(){this.isPaused=!0,this._currentIndex!==void 0&&this._sounds[this._currentIndex].pause()}stop(){this.isPlaying=!1,this._currentIndex!==void 0&&this._sounds[this._currentIndex].stop()}play(e){if(!this.isPaused){this.stop();const i=Math.random();let s=0;for(let r=0;r<this._weights.length;r++)if(s+=this._weights[r],i<=s){this._currentIndex=r;break}}const t=this._sounds[this._currentIndex];t.isReady()?t.play(0,this.isPaused?void 0:e):t.autoplay=!0,this.isPlaying=!0,this.isPaused=!1}}const Ia="MSFT_audio_emitter";class um{constructor(e){this.name=Ia,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ia)}dispose(){this._loader=null,this._clips=null,this._emitters=null}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,_e.Assign(this._clips),_e.Assign(this._emitters)}}loadSceneAsync(e,t){return Z.LoadExtensionAsync(e,t,this.name,(i,s)=>{const r=new Array;r.push(this._loader.loadSceneAsync(e,t));for(const n of s.emitters){const a=_e.Get(`${i}/emitters`,this._emitters,n);if(a.refDistance!=null||a.maxDistance!=null||a.rolloffFactor!=null||a.distanceModel!=null||a.innerAngle!=null||a.outerAngle!=null)throw new Error(`${i}: Direction or Distance properties are not allowed on emitters attached to a scene`);r.push(this._loadEmitterAsync(`${i}/emitters/${a.index}`,a))}return Promise.all(r).then(()=>{})})}loadNodeAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{const n=new Array;return this._loader.loadNodeAsync(s,t,a=>{for(const o of r.emitters){const h=_e.Get(`${s}/emitters`,this._emitters,o);n.push(this._loadEmitterAsync(`${s}/emitters/${h.index}`,h).then(()=>{for(const c of h._babylonSounds)c.attachToMesh(a),(h.innerAngle!=null||h.outerAngle!=null)&&(c.setLocalDirectionToMesh(E.Forward()),c.setDirectionalCone(2*k.ToDegrees(h.innerAngle==null?Math.PI:h.innerAngle),2*k.ToDegrees(h.outerAngle==null?Math.PI:h.outerAngle),0))}))}i(a)}).then(a=>Promise.all(n).then(()=>a))})}loadAnimationAsync(e,t){return Z.LoadExtensionAsync(e,t,this.name,(i,s)=>this._loader.loadAnimationAsync(e,t).then(r=>{const n=new Array;_e.Assign(s.events);for(const a of s.events)n.push(this._loadAnimationEventAsync(`${i}/events/${a.index}`,e,t,a,r));return Promise.all(n).then(()=>r)}))}_loadClipAsync(e,t){if(t._objectURL)return t._objectURL;let i;if(t.uri)i=this._loader.loadUriAsync(e,t,t.uri);else{const s=_e.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,t.bufferView);i=this._loader.loadBufferViewAsync(`/bufferViews/${s.index}`,s)}return t._objectURL=i.then(s=>URL.createObjectURL(new Blob([s],{type:t.mimeType}))),t._objectURL}_loadEmitterAsync(e,t){if(t._babylonSounds=t._babylonSounds||[],!t._babylonData){const i=new Array,s=t.name||`emitter${t.index}`,r={loop:!1,autoplay:!1,volume:t.volume==null?1:t.volume};for(let a=0;a<t.clips.length;a++){const o=`/extensions/${this.name}/clips`,h=_e.Get(o,this._clips,t.clips[a].clip);i.push(this._loadClipAsync(`${o}/${t.clips[a].clip}`,h).then(c=>{const u=t._babylonSounds[a]=new ys(s,c,this._loader.babylonScene,null,r);u.refDistance=t.refDistance||1,u.maxDistance=t.maxDistance||256,u.rolloffFactor=t.rolloffFactor||1,u.distanceModel=t.distanceModel||"exponential"}))}const n=Promise.all(i).then(()=>{const a=t.clips.map(h=>h.weight||1),o=new cm(t.loop||!1,t._babylonSounds,a);t.innerAngle&&(o.directionalConeInnerAngle=2*k.ToDegrees(t.innerAngle)),t.outerAngle&&(o.directionalConeOuterAngle=2*k.ToDegrees(t.outerAngle)),t.volume&&(o.volume=t.volume),t._babylonData.sound=o});t._babylonData={loaded:n}}return t._babylonData.loaded}_getEventAction(e,t,i,s,r){switch(i){case"play":return n=>{const a=(r||0)+(n-s);t.play(a)};case"stop":return()=>{t.stop()};case"pause":return()=>{t.pause()};default:throw new Error(`${e}: Unsupported action ${i}`)}}_loadAnimationEventAsync(e,t,i,s,r){if(r.targetedAnimations.length==0)return Promise.resolve();const n=r.targetedAnimations[0],a=s.emitter,o=_e.Get(`/extensions/${this.name}/emitters`,this._emitters,a);return this._loadEmitterAsync(e,o).then(()=>{const h=o._babylonData.sound;if(h){const c=new ba(s.time,this._getEventAction(e,h,s.action,s.time,s.startOffset));n.animation.addEvent(c),r.onAnimationGroupEndObservable.add(()=>{h.stop()}),r.onAnimationGroupPauseObservable.add(()=>{h.pause()})}})}}Z.RegisterExtension(Ia,l=>new um(l));const ya="MSFT_lod";class fm{constructor(e){this.name=ya,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new B,this.onMaterialLODsLoadedObservable=new B,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.enabled=this._loader.isExtensionUsed(ya)}dispose(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()}onReady(){for(let e=0;e<this._nodePromiseLODs.length;e++){const t=Promise.all(this._nodePromiseLODs[e]).then(()=>{e!==0&&(this._loader.endPerformanceCounter(`Node LOD ${e}`),this._loader.log(`Loaded node LOD ${e}`)),this.onNodeLODsLoadedObservable.notifyObservers(e),e!==this._nodePromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Node LOD ${e+1}`),this._loadBufferLOD(this._nodeBufferLODs,e+1),this._nodeSignalLODs[e]&&this._nodeSignalLODs[e].resolve())});this._loader._completePromises.push(t)}for(let e=0;e<this._materialPromiseLODs.length;e++){const t=Promise.all(this._materialPromiseLODs[e]).then(()=>{e!==0&&(this._loader.endPerformanceCounter(`Material LOD ${e}`),this._loader.log(`Loaded material LOD ${e}`)),this.onMaterialLODsLoadedObservable.notifyObservers(e),e!==this._materialPromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Material LOD ${e+1}`),this._loadBufferLOD(this._materialBufferLODs,e+1),this._materialSignalLODs[e]&&this._materialSignalLODs[e].resolve())});this._loader._completePromises.push(t)}}loadSceneAsync(e,t){const i=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),i}loadNodeAsync(e,t,i){return Z.LoadExtensionAsync(e,t,this.name,(s,r)=>{let n;const a=this._getLODs(s,t,this._loader.gltf.nodes,r.ids);this._loader.logOpen(`${s}`);for(let o=0;o<a.length;o++){const h=a[o];o!==0&&(this._nodeIndexLOD=o,this._nodeSignalLODs[o]=this._nodeSignalLODs[o]||new Nr);const c=f=>{i(f),f.setEnabled(!1)},u=this._loader.loadNodeAsync(`/nodes/${h.index}`,h,c).then(f=>{if(o!==0){const d=a[o-1];d._babylonTransformNode&&(this._disposeTransformNode(d._babylonTransformNode),delete d._babylonTransformNode)}return f.setEnabled(!0),f});this._nodePromiseLODs[o]=this._nodePromiseLODs[o]||[],o===0?n=u:(this._nodeIndexLOD=null,this._nodePromiseLODs[o].push(u))}return this._loader.logClose(),n})}_loadMaterialAsync(e,t,i,s,r){return this._nodeIndexLOD?null:Z.LoadExtensionAsync(e,t,this.name,(n,a)=>{let o;const h=this._getLODs(n,t,this._loader.gltf.materials,a.ids);this._loader.logOpen(`${n}`);for(let c=0;c<h.length;c++){const u=h[c];c!==0&&(this._materialIndexLOD=c);const f=this._loader._loadMaterialAsync(`/materials/${u.index}`,u,i,s,d=>{c===0&&r(d)}).then(d=>{if(c!==0){r(d);const _=h[c-1]._data;_[s]&&(this._disposeMaterials([_[s].babylonMaterial]),delete _[s])}return d});this._materialPromiseLODs[c]=this._materialPromiseLODs[c]||[],c===0?o=f:(this._materialIndexLOD=null,this._materialPromiseLODs[c].push(f))}return this._loader.logClose(),o})}_loadUriAsync(e,t,i){if(this._nodeIndexLOD!==null){this._loader.log("deferred");const s=this._nodeIndexLOD-1;return this._nodeSignalLODs[s]=this._nodeSignalLODs[s]||new Nr,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(()=>this._loader.loadUriAsync(e,t,i))}else if(this._materialIndexLOD!==null){this._loader.log("deferred");const s=this._materialIndexLOD-1;return this._materialSignalLODs[s]=this._materialSignalLODs[s]||new Nr,this._materialSignalLODs[s].promise.then(()=>this._loader.loadUriAsync(e,t,i))}return null}loadBufferAsync(e,t,i,s){if(this._loader.parent.useRangeRequests&&!t.uri){if(!this._loader.bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);const r=(n,a)=>{const o=i,h=o+s-1;let c=n[a];return c?(c.start=Math.min(c.start,o),c.end=Math.max(c.end,h)):(c={start:o,end:h,loaded:new Nr},n[a]=c),c.loaded.promise.then(u=>new Uint8Array(u.buffer,u.byteOffset+i-c.start,s))};return this._loader.log("deferred"),this._nodeIndexLOD!==null?r(this._nodeBufferLODs,this._nodeIndexLOD):this._materialIndexLOD!==null?r(this._materialBufferLODs,this._materialIndexLOD):r(this._bufferLODs,0)}return null}_loadBufferLOD(e,t){const i=e[t];i&&(this._loader.log(`Loading buffer range [${i.start}-${i.end}]`),this._loader.bin.readAsync(i.start,i.end-i.start+1).then(s=>{i.loaded.resolve(s)},s=>{i.loaded.reject(s)}))}_getLODs(e,t,i,s){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");const r=new Array;for(let n=s.length-1;n>=0;n--)if(r.push(_e.Get(`${e}/ids/${s[n]}`,i,s[n])),r.length===this.maxLODsToLoad)return r;return r.push(t),r}_disposeTransformNode(e){const t=new Array,i=e.material;i&&t.push(i);for(const r of e.getChildMeshes())r.material&&t.push(r.material);e.dispose();const s=t.filter(r=>this._loader.babylonScene.meshes.every(n=>n.material!=r));this._disposeMaterials(s)}_disposeMaterials(e){const t={};for(const i of e){for(const s of i.getActiveTextures())t[s.uniqueId]=s;i.dispose()}for(const i in t)for(const s of this._loader.babylonScene.materials)s.hasTexture(t[i])&&delete t[i];for(const i in t)t[i].dispose()}}Z.RegisterExtension(ya,l=>new fm(l));const Ma="MSFT_minecraftMesh";class dm{constructor(e){this.name=Ma,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ma)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtraAsync(e,t,this.name,(s,r)=>{if(r){if(!(i instanceof j))throw new Error(`${s}: Material type not supported`);const n=this._loader.loadMaterialPropertiesAsync(e,t,i);return i.needAlphaBlending()&&(i.forceDepthWrite=!0,i.separateCullingPass=!0),i.backFaceCulling=i.forceDepthWrite,i.twoSidedLighting=!0,n}return null})}}Z.RegisterExtension(Ma,l=>new dm(l));const Pa="MSFT_sRGBFactors";class _m{constructor(e){this.name=Pa,this._loader=e,this.enabled=this._loader.isExtensionUsed(Pa)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,i){return Z.LoadExtraAsync(e,t,this.name,(s,r)=>{if(r){if(!(i instanceof j))throw new Error(`${s}: Material type not supported`);const n=this._loader.loadMaterialPropertiesAsync(e,t,i),a=i.getScene().getEngine().useExactSrgbConversions;return i.albedoTexture||i.albedoColor.toLinearSpaceToRef(i.albedoColor,a),i.reflectivityTexture||i.reflectivityColor.toLinearSpaceToRef(i.reflectivityColor,a),n}return null})}}Z.RegisterExtension(Pa,l=>new _m(l));const _l="ExtrasAsMetadata";class pm{_assignExtras(e,t){if(t.extras&&Object.keys(t.extras).length>0){const i=e.metadata=e.metadata||{},s=i.gltf=i.gltf||{};s.extras=t.extras}}constructor(e){this.name=_l,this.enabled=!0,this._loader=e}dispose(){this._loader=null}loadNodeAsync(e,t,i){return this._loader.loadNodeAsync(e,t,s=>{this._assignExtras(s,t),i(s)})}loadCameraAsync(e,t,i){return this._loader.loadCameraAsync(e,t,s=>{this._assignExtras(s,t),i(s)})}createMaterial(e,t,i){const s=this._loader.createMaterial(e,t,i);return this._assignExtras(s,t),s}}Z.RegisterExtension(_l,l=>new pm(l));class mm{constructor(e){this.getSceneClearColor=()=>{var i,s,r,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(s=this.customOptions)!=null&&s.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new ge(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=z.FromHexString(this.customOptions.backgroundColor);return new ge(a.r,a.g,a.b,t).toLinearSpace()}return new ge(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new ge(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const s=z.FromHexString(t);return new ge(s.r,s.g,s.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){return this.customOptions.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,s,r,n,a,o,h,c,u,f,d;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(s=this.customOptions)!=null&&s.lowerAlphaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(o=this.customOptions)==null?void 0:o.minZoomOverride},max:{alpha:(h=this.customOptions)!=null&&h.upperAlphaLimitDeg?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(u=this.customOptions)!=null&&u.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(d=this.customOptions)==null?void 0:d.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,s;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((s=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:s.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class gn extends Dt{set blurRatio(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())}get blurRatio(){return this._blurRatio}set adaptiveBlurKernel(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()}set blurKernel(e){this.blurKernelX=e,this.blurKernelY=e}set blurKernelX(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())}get blurKernelX(){return this._blurKernelX}set blurKernelY(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())}get blurKernelY(){return this._blurKernelY}_autoComputeBlurKernel(){const e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i}_onRatioRescale(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()}_updateGammaSpace(){const e=this.getScene();e&&(this.gammaSpace=!e.imageProcessingConfiguration.isEnabled||!e.imageProcessingConfiguration.applyByPostProcess)}constructor(e,t,i,s,r=0,n=O.BILINEAR_SAMPLINGMODE,a=!0){if(super(e,t,i,s,!0,r,!1,n,a),this.mirrorPlane=new Zt(0,1,0,1),this._transformMatrix=M.Zero(),this._mirrorMatrix=M.Zero(),this._adaptiveBlurKernel=0,this._blurKernelX=0,this._blurKernelY=0,this._blurRatio=1,i=this.getScene(),!i)return this;this.ignoreCameraViewport=!0,this._updateGammaSpace(),this._imageProcessingConfigChangeObserver=i.imageProcessingConfiguration.onUpdateParameters.add(()=>{this._updateGammaSpace()});const o=i.getEngine();o.supportsUniformBuffers&&(this._sceneUBO=i.createSceneUniformBuffer(`Scene for Mirror Texture (name "${e}")`)),this.onBeforeBindObservable.add(()=>{var c;(c=o._debugPushGroup)===null||c===void 0||c.call(o,`mirror generation for ${e}`,1)}),this.onAfterUnbindObservable.add(()=>{var c;(c=o._debugPopGroup)===null||c===void 0||c.call(o,1)});let h;this.onBeforeRenderObservable.add(()=>{this._sceneUBO&&(this._currentSceneUBO=i.getSceneUniformBuffer(),i.setSceneUniformBuffer(this._sceneUBO),i.getSceneUniformBuffer().unbindEffect()),M.ReflectionToRef(this.mirrorPlane,this._mirrorMatrix),this._mirrorMatrix.multiplyToRef(i.getViewMatrix(),this._transformMatrix),i.setTransformMatrix(this._transformMatrix,i.getProjectionMatrix()),h=i.clipPlane,i.clipPlane=this.mirrorPlane,i._mirroredCameraPosition=E.TransformCoordinates(i.activeCamera.globalPosition,this._mirrorMatrix)}),this.onAfterRenderObservable.add(()=>{this._sceneUBO&&i.setSceneUniformBuffer(this._currentSceneUBO),i.updateTransformMatrix(),i._mirroredCameraPosition=null,i.clipPlane=h})}_preparePostProcesses(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){const e=this.getScene().getEngine(),t=e.getCaps().textureFloatRender&&e.getCaps().textureFloatLinearFiltering?1:2;this._blurX=new gt("horizontal blur",new ae(1,0),this._blurKernelX,this._blurRatio,null,O.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,this._blurRatio===1&&this.samples<2&&this._texture?this._blurX.inputTexture=this._renderTarget:this._blurX.alwaysForcePOT=!0,this._blurY=new gt("vertical blur",new ae(0,1),this._blurKernelY,this._blurRatio,null,O.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=this._blurRatio!==1,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)}clone(){const e=this.getScene();if(!e)return this;const t=this.getSize(),i=new gn(this.name,t.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(i.renderList=this.renderList.slice(0)),i}serialize(){if(!this.name)return null;const e=super.serialize();return e.mirrorPlane=this.mirrorPlane.asArray(),e}dispose(){var e;super.dispose();const t=this.getScene();t&&t.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),(e=this._sceneUBO)===null||e===void 0||e.dispose()}}O._CreateMirror=(l,e,t,i)=>new gn(l,e,t,i),hi.prototype.removeReflectionProbe=function(l){if(!this.reflectionProbes)return-1;const e=this.reflectionProbes.indexOf(l);return e!==-1&&this.reflectionProbes.splice(e,1),e},hi.prototype.addReflectionProbe=function(l){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(l)};class Vr{constructor(e,t,i,s=!0,r=!1,n=!1){if(this.name=e,this._viewMatrix=M.Identity(),this._target=E.Zero(),this._add=E.Zero(),this._invertYAxis=!1,this.position=E.Zero(),this.metadata=null,this._parentContainer=null,this._scene=i,i.getEngine().supportsUniformBuffers){this._sceneUBOs=[];for(let c=0;c<6;++c)this._sceneUBOs.push(i.createSceneUniformBuffer(`Scene for Reflection Probe (name "${e}") face #${c}`))}this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);let a=0;if(r){const c=this._scene.getEngine().getCaps();c.textureHalfFloatRender?a=2:c.textureFloatRender&&(a=1)}this._renderTargetTexture=new Dt(e,t,i,s,!0,a,!0),this._renderTargetTexture.gammaSpace=!n,this._renderTargetTexture.invertZ=i.useRightHandedSystem;const o=i.getEngine().useReverseDepthBuffer;this._renderTargetTexture.onBeforeRenderObservable.add(c=>{switch(this._sceneUBOs&&(i.setSceneUniformBuffer(this._sceneUBOs[c]),i.getSceneUniformBuffer().unbindEffect()),c){case 0:this._add.copyFromFloats(1,0,0);break;case 1:this._add.copyFromFloats(-1,0,0);break;case 2:this._add.copyFromFloats(0,this._invertYAxis?1:-1,0);break;case 3:this._add.copyFromFloats(0,this._invertYAxis?-1:1,0);break;case 4:this._add.copyFromFloats(0,0,i.useRightHandedSystem?-1:1);break;case 5:this._add.copyFromFloats(0,0,i.useRightHandedSystem?1:-1);break}this._attachedMesh&&this.position.copyFrom(this._attachedMesh.getAbsolutePosition()),this.position.addToRef(this._add,this._target);const u=i.useRightHandedSystem?M.LookAtRHToRef:M.LookAtLHToRef,f=i.useRightHandedSystem?M.PerspectiveFovRH:M.PerspectiveFovLH;u(this.position,this._target,E.Up(),this._viewMatrix),i.activeCamera&&(this._projectionMatrix=f(Math.PI/2,1,o?i.activeCamera.maxZ:i.activeCamera.minZ,o?i.activeCamera.minZ:i.activeCamera.maxZ,this._scene.getEngine().isNDCHalfZRange),i.setTransformMatrix(this._viewMatrix,this._projectionMatrix),i.activeCamera.isRigCamera&&!this._renderTargetTexture.activeCamera&&(this._renderTargetTexture.activeCamera=i.activeCamera.rigParent||null)),i._forcedViewPosition=this.position});let h;this._renderTargetTexture.onBeforeBindObservable.add(()=>{var c,u;this._currentSceneUBO=i.getSceneUniformBuffer(),(u=(c=i.getEngine())._debugPushGroup)===null||u===void 0||u.call(c,`reflection probe generation for ${e}`,1),h=this._scene.imageProcessingConfiguration.applyByPostProcess,n&&(i.imageProcessingConfiguration.applyByPostProcess=!0)}),this._renderTargetTexture.onAfterUnbindObservable.add(()=>{var c,u;i.imageProcessingConfiguration.applyByPostProcess=h,i._forcedViewPosition=null,this._sceneUBOs&&i.setSceneUniformBuffer(this._currentSceneUBO),i.updateTransformMatrix(!0),(u=(c=i.getEngine())._debugPopGroup)===null||u===void 0||u.call(c,1)})}get samples(){return this._renderTargetTexture.samples}set samples(e){this._renderTargetTexture.samples=e}get refreshRate(){return this._renderTargetTexture.refreshRate}set refreshRate(e){this._renderTargetTexture.refreshRate=e}getScene(){return this._scene}get cubeTexture(){return this._renderTargetTexture}get renderList(){return this._renderTargetTexture.renderList}attachToMesh(e){this._attachedMesh=e}setRenderingAutoClearDepthStencil(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)}dispose(){const e=this._scene.reflectionProbes.indexOf(this);if(e!==-1&&this._scene.reflectionProbes.splice(e,1),this._parentContainer){const t=this._parentContainer.reflectionProbes.indexOf(this);t>-1&&this._parentContainer.reflectionProbes.splice(t,1),this._parentContainer=null}if(this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null),this._sceneUBOs){for(const t of this._sceneUBOs)t.dispose();this._sceneUBOs=[]}}toString(e){let t="Name: "+this.name;return e&&(t+=", position: "+this.position.toString(),this._attachedMesh&&(t+=", attached mesh: "+this._attachedMesh.name)),t}getClassName(){return"ReflectionProbe"}serialize(){const e=J.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e.metadata=this.metadata,e}static Parse(e,t,i){let s=null;if(t.reflectionProbes)for(let r=0;r<t.reflectionProbes.length;r++){const n=t.reflectionProbes[r];if(n.name===e.name){s=n;break}}return s=J.Parse(()=>s||new Vr(e.name,e.renderTargetSize,t,e._generateMipMaps),e,t,i),s.cubeTexture._waitingRenderList=e.renderList,e._attachedMesh&&s.attachToMesh(t.getMeshById(e._attachedMesh)),e.metadata&&(s.metadata=e.metadata),s}}g([xn()],Vr.prototype,"_attachedMesh",void 0),g([Ut()],Vr.prototype,"position",void 0);class sr{static getDynamicTextureResolution(){return this.getIsMobile()||!sr.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const pl=128,De={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class gm{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(s){t.extras&&Object.keys(t.extras).forEach(r=>{const n=t.extras[r];s.metadata[r]=n}),i(s)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof j))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new z(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(r){const n=[];return r.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&n.push(...a.getChildMeshes())}),r.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!n.includes(a)&&n.push(a)}),n}function i(r,n=1){const a=r.material;if(!a)return;const o=new gn("mirror",sr.getMirrorTextureResolution(),e,!0);o.renderList=t(e);const h=r.getVerticesData("normal");if(!h)throw new Error("Mirror attribute specified on: "+r.name+"But no normals exist to generate a mirror from!");r.computeWorldMatrix(!0);const c=r.getWorldMatrix(),u=E.TransformNormal(new E(h[0],h[1],h[2]),c).normalize(),f=Zt.FromPositionAndNormal(r.position,u.scale(-1));o.mirrorPlane=f,o.level=n,a.reflectionTexture=o}function s(r){const n=r.material,a=new Vr("probe-"+n.name,pl,e);a.attachToMesh(r),a.renderList&&a.renderList.push(...t(e)),n.reflectionTexture=a.cubeTexture}e.meshes.forEach(r=>{const n=r.metadata;n&&(n.mirrorTexture&&i(r,n.mirrorTexture),n.reflectionProbe&&s(r))})}}hi.prototype.getGlowLayerByName=function(l){var e;for(let t=0;t<((e=this.effectLayers)===null||e===void 0?void 0:e.length);t++)if(this.effectLayers[t].name===l&&this.effectLayers[t].getEffectName()===ei.EffectName)return this.effectLayers[t];return null};class ei extends ni{set blurKernelSize(e){if(e===this._options.blurKernelSize)return;this._options.blurKernelSize=e;const t=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1.kernel=t,this._verticalBlurPostprocess1.kernel=t,this._horizontalBlurPostprocess2.kernel=t,this._verticalBlurPostprocess2.kernel=t}get blurKernelSize(){return this._options.blurKernelSize}set intensity(e){this._intensity=e}get intensity(){return this._intensity}constructor(e,t,i){super(e,t),this._intensity=1,this._includedOnlyMeshes=[],this._excludedMeshes=[],this._meshesUsingTheirOwnMaterials=[],this.neutralColor=new ge(0,0,0,1),this._options=Object.assign({mainTextureRatio:ei.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1,ldrMerge:!1,alphaBlendingMode:1,mainTextureType:0,generateStencilBuffer:!1},i),this._init({alphaBlendingMode:this._options.alphaBlendingMode,camera:this._options.camera,mainTextureFixedSize:this._options.mainTextureFixedSize,mainTextureRatio:this._options.mainTextureRatio,renderingGroupId:this._options.renderingGroupId,mainTextureType:this._options.mainTextureType,generateStencilBuffer:this._options.generateStencilBuffer})}getEffectName(){return ei.EffectName}_createMergeEffect(){let e=`#define EMISSIVE
7590
7590
  `;return this._options.ldrMerge&&(e+=`#define LDR
7591
- `),this._engine.createEffect("glowMapMerge",[A.PositionKind],["offset"],["textureSampler","textureSampler2"],e)}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width,t=this._mainTextureDesiredSize.height;e=this._engine.needPOTTextures?L.GetExponentOfTwo(e,this._maxSize):e,t=this._engine.needPOTTextures?L.GetExponentOfTwo(t,this._maxSize):t;let i=0;this._engine.getCaps().textureHalfFloatRender?i=2:i=0,this._blurTexture1=new Dt("GlowLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,i),this._blurTexture1.wrapU=O.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=O.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(O.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;const s=Math.floor(e/2),r=Math.floor(t/2);this._blurTexture2=new Dt("GlowLayerBlurRTT2",{width:s,height:r},this._scene,!1,!0,i),this._blurTexture2.wrapU=O.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=O.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(O.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2];const n=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1=new gt("GlowLayerHBP1",new ae(1,0),n,{width:e,height:t},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._horizontalBlurPostprocess1.width=e,this._horizontalBlurPostprocess1.height=t,this._horizontalBlurPostprocess1.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess1.onApplyObservable.add(a=>{a.setTexture("textureSampler",this._mainTexture)}),this._verticalBlurPostprocess1=new gt("GlowLayerVBP1",new ae(0,1),n,{width:e,height:t},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._horizontalBlurPostprocess2=new gt("GlowLayerHBP2",new ae(1,0),n,{width:s,height:r},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._horizontalBlurPostprocess2.width=s,this._horizontalBlurPostprocess2.height=r,this._horizontalBlurPostprocess2.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess2.onApplyObservable.add(a=>{a.setTexture("textureSampler",this._blurTexture1)}),this._verticalBlurPostprocess2=new gt("GlowLayerVBP2",new ae(0,1),n,{width:s,height:r},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add(()=>{const a=this._blurTexture1.renderTarget;if(a){this._scene.postProcessManager.directRender(this._postProcesses1,a,!0);const o=this._blurTexture2.renderTarget;o&&this._scene.postProcessManager.directRender(this._postProcesses2,o,!0),this._engine.unBindFramebuffer(o??a,!0)}}),this._postProcesses.map(a=>{a.autoClear=!1})}_getEffectiveBlurKernelSize(){return this._options.blurKernelSize/2}isReady(e,t){const i=e.getMaterial(),s=e.getRenderingMesh();if(!i||!s)return!1;const r=i.emissiveTexture;return super._isReady(e,t,r)}needStencil(){return!1}_canRenderMesh(e,t){return!0}_internalRender(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);const t=this._engine,i=t.getStencilBuffer();t.setStencilBuffer(!1),t.drawElementsType(V.TriangleFillMode,0,6),t.setStencilBuffer(i)}_setEmissiveTextureAndColor(e,t,i){var s;let r=1;if(this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(r=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector)this.customEmissiveColorSelector(e,t,i,this._emissiveTextureAndColor.color);else if(i.emissiveColor){const n=(s=i.emissiveIntensity)!==null&&s!==void 0?s:1;r*=n,this._emissiveTextureAndColor.color.set(i.emissiveColor.r*r,i.emissiveColor.g*r,i.emissiveColor.b*r,i.alpha)}else this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)}_shouldRenderMesh(e){return this.hasMesh(e)}_addCustomEffectDefines(e){e.push("#define GLOW")}addExcludedMesh(e){this._excludedMeshes.indexOf(e.uniqueId)===-1&&this._excludedMeshes.push(e.uniqueId)}removeExcludedMesh(e){const t=this._excludedMeshes.indexOf(e.uniqueId);t!==-1&&this._excludedMeshes.splice(t,1)}addIncludedOnlyMesh(e){this._includedOnlyMeshes.indexOf(e.uniqueId)===-1&&this._includedOnlyMeshes.push(e.uniqueId)}removeIncludedOnlyMesh(e){const t=this._includedOnlyMeshes.indexOf(e.uniqueId);t!==-1&&this._includedOnlyMeshes.splice(t,1)}hasMesh(e){return super.hasMesh(e)?this._includedOnlyMeshes.length?this._includedOnlyMeshes.indexOf(e.uniqueId)!==-1:this._excludedMeshes.length?this._excludedMeshes.indexOf(e.uniqueId)===-1:!0:!1}_useMeshMaterial(e){return this._meshesUsingTheirOwnMaterials.length==0?!1:this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1}referenceMeshToUseItsOwnMaterial(e){e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add(()=>{this._disposeMesh(e)})}unReferenceMeshFromUsingItsOwnMaterial(e){let t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);for(;t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);e.resetDrawCache(this._mainTexture.renderPassId)}_disposeMesh(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)}getClassName(){return"GlowLayer"}serialize(){const e=J.Serialize(this);e.customType="BABYLON.GlowLayer";let t;if(e.includedMeshes=[],this._includedOnlyMeshes.length)for(t=0;t<this._includedOnlyMeshes.length;t++){const i=this._scene.getMeshByUniqueId(this._includedOnlyMeshes[t]);i&&e.includedMeshes.push(i.id)}if(e.excludedMeshes=[],this._excludedMeshes.length)for(t=0;t<this._excludedMeshes.length;t++){const i=this._scene.getMeshByUniqueId(this._excludedMeshes[t]);i&&e.excludedMeshes.push(i.id)}return e}static Parse(e,t,i){const s=J.Parse(()=>new ei(e.name,t,e.options),e,t,i);let r;for(r=0;r<e.excludedMeshes.length;r++){const n=t.getMeshById(e.excludedMeshes[r]);n&&s.addExcludedMesh(n)}for(r=0;r<e.includedMeshes.length;r++){const n=t.getMeshById(e.includedMeshes[r]);n&&s.addIncludedOnlyMesh(n)}return s}}ei.EffectName="GlowLayer",ei.DefaultBlurKernelSize=32,ei.DefaultTextureRatio=.5,g([v()],ei.prototype,"blurKernelSize",null),g([v()],ei.prototype,"intensity",null),g([v("options")],ei.prototype,"_options",void 0),Re("BABYLON.GlowLayer",ei);class Em{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new ei("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}class $e{constructor(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new B,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,this._nextActiveAction=this,this._condition=t}_prepare(){}getTriggerParameter(){return this._triggerParameter}setTriggerParameter(e){this._triggerParameter=e}_evaluateConditionForCurrentFrame(){const e=this._condition;if(!e)return!0;const t=this._actionManager.getScene().getRenderId();return e._evaluationId!==t&&(e._evaluationId=t,e._currentResult=e.isValid()),e._currentResult}_executeCurrent(e){this._evaluateConditionForCurrentFrame()&&(this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction())}execute(e){}skipToNextActiveAction(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this}then(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e}_getProperty(e){return this._actionManager._getProperty(e)}_getEffectiveTarget(e,t){return this._actionManager._getEffectiveTarget(e,t)}serialize(e){}_serialize(e,t){const i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){const s=this._condition.serialize();return s.children.push(i),t&&t.children.push(s),s}return t&&t.children.push(i),i}}$e._SerializeValueAsString=l=>typeof l=="number"?l.toString():typeof l=="boolean"?l?"true":"false":l instanceof ae?l.x+", "+l.y:l instanceof E?l.x+", "+l.y+", "+l.z:l instanceof z?l.r+", "+l.g+", "+l.b:l instanceof ge?l.r+", "+l.g+", "+l.b+", "+l.a:l,$e._GetTargetProperty=l=>({name:"target",targetType:l._isMesh?"MeshProperties":l._isLight?"LightProperties":l._isCamera?"CameraProperties":l._isMaterial?"MaterialProperties":"SceneProperties",value:l._isScene?"Scene":l.name}),Re("BABYLON.Action",$e);class kr{constructor(e){this._actionManager=e}isValid(){return!0}_getProperty(e){return this._actionManager._getProperty(e)}_getEffectiveTarget(e,t){return this._actionManager._getEffectiveTarget(e,t)}serialize(){}_serialize(e){return{type:2,children:[],name:e.name,properties:e.properties}}}class _t extends kr{static get IsEqual(){return _t._IsEqual}static get IsDifferent(){return _t._IsDifferent}static get IsGreater(){return _t._IsGreater}static get IsLesser(){return _t._IsLesser}constructor(e,t,i,s,r=_t.IsEqual){super(e),this.propertyPath=i,this.value=s,this.operator=r,this._target=t,this._effectiveTarget=this._getEffectiveTarget(t,this.propertyPath),this._property=this._getProperty(this.propertyPath)}isValid(){switch(this.operator){case _t.IsGreater:return this._effectiveTarget[this._property]>this.value;case _t.IsLesser:return this._effectiveTarget[this._property]<this.value;case _t.IsEqual:case _t.IsDifferent:{let e;return this.value.equals?e=this.value.equals(this._effectiveTarget[this._property]):e=this.value===this._effectiveTarget[this._property],this.operator===_t.IsEqual?e:!e}}return!1}serialize(){return this._serialize({name:"ValueCondition",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:$e._SerializeValueAsString(this.value)},{name:"operator",value:_t.GetOperatorName(this.operator)}]})}static GetOperatorName(e){switch(e){case _t._IsEqual:return"IsEqual";case _t._IsDifferent:return"IsDifferent";case _t._IsGreater:return"IsGreater";case _t._IsLesser:return"IsLesser";default:return""}}}_t._IsEqual=0,_t._IsDifferent=1,_t._IsGreater=2,_t._IsLesser=3;class Tm extends kr{constructor(e,t){super(e),this.predicate=t}isValid(){return this.predicate()}}class Am extends kr{constructor(e,t,i){super(e),this.value=i,this._target=t}isValid(){return this._target.state===this.value}serialize(){return this._serialize({name:"StateCondition",properties:[$e._GetTargetProperty(this._target),{name:"value",value:this.value}]})}}Re("BABYLON.ValueCondition",_t),Re("BABYLON.PredicateCondition",Tm),Re("BABYLON.StateCondition",Am);class vm extends $e{constructor(e,t,i,s){super(e,s),this.propertyPath=i,this._target=this._effectiveTarget=t}_prepare(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)}execute(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]}serialize(e){return super._serialize({name:"SwitchBooleanAction",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},e)}}class Sm extends $e{constructor(e,t,i,s){super(e,s),this.value=i,this._target=t}execute(){this._target.state=this.value}serialize(e){return super._serialize({name:"SetStateAction",properties:[$e._GetTargetProperty(this._target),{name:"value",value:this.value}]},e)}}class Rm extends $e{constructor(e,t,i,s,r){super(e,r),this.propertyPath=i,this.value=s,this._target=this._effectiveTarget=t}_prepare(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)}execute(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)}serialize(e){return super._serialize({name:"SetValueAction",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:$e._SerializeValueAsString(this.value)}]},e)}}class xm extends $e{constructor(e,t,i,s,r){super(e,r),this.propertyPath=i,this.value=s,this._target=this._effectiveTarget=t}_prepare(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),typeof this._effectiveTarget[this._property]!="number"&&F.Warn("Warning: IncrementValueAction can only be used with number values")}execute(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)}serialize(e){return super._serialize({name:"IncrementValueAction",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:$e._SerializeValueAsString(this.value)}]},e)}}class Cm extends $e{constructor(e,t,i,s,r,n){super(e,n),this.from=i,this.to=s,this.loop=r,this._target=t}_prepare(){}execute(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)}serialize(e){return super._serialize({name:"PlayAnimationAction",properties:[$e._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:$e._SerializeValueAsString(this.loop)||!1}]},e)}}class bm extends $e{constructor(e,t,i){super(e,i),this._target=t}_prepare(){}execute(){this._actionManager.getScene().stopAnimation(this._target)}serialize(e){return super._serialize({name:"StopAnimationAction",properties:[$e._GetTargetProperty(this._target)]},e)}}class ml extends $e{constructor(e=0,t){super(e,t)}execute(){}serialize(e){return super._serialize({name:"DoNothingAction",properties:[]},e)}}class Im extends $e{constructor(e,t,i,s=!0){super(e,i),this.children=t,this.enableChildrenConditions=s}_prepare(){for(let e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()}execute(e){for(const t of this.children)(!this.enableChildrenConditions||t._evaluateConditionForCurrentFrame())&&t.execute(e)}serialize(e){const t=super._serialize({name:"CombineAction",properties:[],combine:[]},e);for(let i=0;i<this.children.length;i++)t.combine.push(this.children[i].serialize(null));return t}}class Oa extends $e{constructor(e,t,i){super(e,i),this.func=t}execute(e){this.func(e)}}class gl extends $e{constructor(e,t,i,s){super(e,s),this._target=t,this._parent=i}_prepare(){}execute(){if(this._target.parent===this._parent)return;const e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=E.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}serialize(e){return super._serialize({name:"SetParentAction",properties:[$e._GetTargetProperty(this._target),$e._GetTargetProperty(this._parent)]},e)}}Re("BABYLON.SetParentAction",gl),Re("BABYLON.ExecuteCodeAction",Oa),Re("BABYLON.DoNothingAction",ml),Re("BABYLON.StopAnimationAction",bm),Re("BABYLON.PlayAnimationAction",Cm),Re("BABYLON.IncrementValueAction",xm),Re("BABYLON.SetValueAction",Rm),Re("BABYLON.SetStateAction",Sm),Re("BABYLON.SetParentAction",gl),Re("BABYLON.SwitchBooleanAction",vm),Re("BABYLON.CombineAction",Im);class Pe extends Qt{constructor(e){super(),e=e||Ee.LastCreatedScene,e&&(this._scene=e,e.actionManagers.push(this))}dispose(){const e=this._scene.actionManagers.indexOf(this);for(let t=0;t<this.actions.length;t++){const i=this.actions[t];Pe.Triggers[i.trigger]--,Pe.Triggers[i.trigger]===0&&delete Pe.Triggers[i.trigger]}e>-1&&this._scene.actionManagers.splice(e,1)}getScene(){return this._scene}hasSpecificTriggers(e){for(let t=0;t<this.actions.length;t++){const i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1}hasSpecificTriggers2(e,t){for(let i=0;i<this.actions.length;i++){const s=this.actions[i];if(e==s.trigger||t==s.trigger)return!0}return!1}hasSpecificTrigger(e,t){for(let i=0;i<this.actions.length;i++){const s=this.actions[i];if(s.trigger===e)if(t){if(t(s.getTriggerParameter()))return!0}else return!0}return!1}get hasPointerTriggers(){for(let e=0;e<this.actions.length;e++){const t=this.actions[e];if(t.trigger>=Pe.OnPickTrigger&&t.trigger<=Pe.OnPointerOutTrigger)return!0}return!1}get hasPickTriggers(){for(let e=0;e<this.actions.length;e++){const t=this.actions[e];if(t.trigger>=Pe.OnPickTrigger&&t.trigger<=Pe.OnPickUpTrigger)return!0}return!1}registerAction(e){return e.trigger===Pe.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(F.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),this.getScene()._registeredActions++,Pe.Triggers[e.trigger]?Pe.Triggers[e.trigger]++:Pe.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)}unregisterAction(e){const t=this.actions.indexOf(e);return t!==-1?(this.actions.splice(t,1),Pe.Triggers[e.trigger]-=1,Pe.Triggers[e.trigger]===0&&delete Pe.Triggers[e.trigger],e._actionManager=null,this.getScene()._registeredActions--,!0):!1}processTrigger(e,t){for(let i=0;i<this.actions.length;i++){const s=this.actions[i];if(s.trigger===e){if(t&&(e===Pe.OnKeyUpTrigger||e===Pe.OnKeyDownTrigger)){const r=s.getTriggerParameter();if(typeof r=="function"){if(!r(t))continue}else if(r&&r!==t.sourceEvent.keyCode){if(!r.toLowerCase)continue;const n=r.toLowerCase();if(n!==t.sourceEvent.key){const a=t.sourceEvent.charCode?t.sourceEvent.charCode:t.sourceEvent.keyCode;if(String.fromCharCode(a).toLowerCase()!==n)continue}}}s._executeCurrent(t)}}}_getEffectiveTarget(e,t){const i=t.split(".");for(let s=0;s<i.length-1;s++)e=e[i[s]];return e}_getProperty(e){const t=e.split(".");return t[t.length-1]}serialize(e){const t={children:new Array,name:e,type:3,properties:new Array};for(let i=0;i<this.actions.length;i++){const s={type:0,children:new Array,name:Pe.GetTriggerName(this.actions[i].trigger),properties:new Array},r=this.actions[i].triggerOptions;if(r&&typeof r!="number")if(r.parameter instanceof Node)s.properties.push($e._GetTargetProperty(r.parameter));else if(typeof r.parameter=="object"){const n={};pr.DeepCopy(r.parameter,n,["mesh"]),r.parameter&&r.parameter.mesh&&(n._meshId=r.parameter.mesh.id),s.properties.push({name:"parameter",targetType:null,value:n})}else s.properties.push({name:"parameter",targetType:null,value:r.parameter});this.actions[i].serialize(s),t.children.push(s)}return t}static Parse(e,t,i){const s=new Pe(i);t===null?i.actionManager=s:t.actionManager=s;const r=(o,h)=>{const c=Ri("BABYLON."+o);return c&&new c(...h)},n=(o,h,c,u)=>{if(u===null){const p=parseFloat(h);return h==="true"||h==="false"?h==="true":isNaN(p)?h:p}const f=u.split("."),d=h.split(",");for(let p=0;p<f.length;p++)c=c[f[p]];if(typeof c=="boolean")return d[0]==="true";if(typeof c=="string")return d[0];const _=new Array;for(let p=0;p<d.length;p++)_.push(parseFloat(d[p]));return c instanceof E?E.FromArray(_):c instanceof He?He.FromArray(_):c instanceof z?z.FromArray(_):c instanceof ge?ge.FromArray(_):parseFloat(d[0])},a=(o,h,c,u,f=null)=>{if(o.detached)return;const d=new Array;let _=null,p=null;const m=o.combine&&o.combine.length>0;if(o.type===2?d.push(s):d.push(h),m){const S=new Array;for(let x=0;x<o.combine.length;x++)a(o.combine[x],Pe.NothingTrigger,c,u,S);d.push(S)}else for(let S=0;S<o.properties.length;S++){let x=o.properties[S].value;const b=o.properties[S].name,I=o.properties[S].targetType;b==="target"?I==="SceneProperties"?x=_=i:I==="MaterialProperties"?x=_=i.getMaterialByName(x):x=_=i.getNodeByName(x):b==="parent"?x=i.getNodeByName(x):b==="sound"?i.getSoundByName&&(x=i.getSoundByName(x)):b!=="propertyPath"?o.type===2&&b==="operator"?x=_t[x]:x=n(b,x,_,b==="value"?p:null):p=x,d.push(x)}if(f===null?d.push(c):d.push(null),o.name==="InterpolateValueAction"){const S=d[d.length-2];d[d.length-1]=S,d[d.length-2]=c}let T=r(o.name,d);if(T instanceof kr&&c!==null){const S=new ml(h,c);u?u.then(S):s.registerAction(S),u=S}f===null?T instanceof kr?(c=T,T=u):(c=null,u?u.then(T):s.registerAction(T)):f.push(T);for(let S=0;S<o.children.length;S++)a(o.children[S],h,c,T,null)};for(let o=0;o<e.children.length;o++){let h;const c=e.children[o];if(c.properties.length>0){const u=c.properties[0].value,f=c.properties[0].targetType===null?u:i.getMeshByName(u);f._meshId&&(f.mesh=i.getMeshById(f._meshId)),h={trigger:Pe[c.name],parameter:f}}else h=Pe[c.name];for(let u=0;u<c.children.length;u++)c.detached||a(c.children[u],h,null,null)}}static GetTriggerName(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnDoublePickTrigger";case 7:return"OnPickUpTrigger";case 8:return"OnLongPressTrigger";case 9:return"OnPointerOverTrigger";case 10:return"OnPointerOutTrigger";case 11:return"OnEveryFrameTrigger";case 12:return"OnIntersectionEnterTrigger";case 13:return"OnIntersectionExitTrigger";case 14:return"OnKeyDownTrigger";case 15:return"OnKeyUpTrigger";case 16:return"OnPickOutTrigger";default:return""}}}Pe.NothingTrigger=0,Pe.OnPickTrigger=1,Pe.OnLeftPickTrigger=2,Pe.OnRightPickTrigger=3,Pe.OnCenterPickTrigger=4,Pe.OnPickDownTrigger=5,Pe.OnDoublePickTrigger=6,Pe.OnPickUpTrigger=7,Pe.OnPickOutTrigger=16,Pe.OnLongPressTrigger=8,Pe.OnPointerOverTrigger=9,Pe.OnPointerOutTrigger=10,Pe.OnEveryFrameTrigger=11,Pe.OnIntersectionEnterTrigger=12,Pe.OnIntersectionExitTrigger=13,Pe.OnKeyDownTrigger=14,Pe.OnKeyUpTrigger=15;const El=new Map;async function Tl(l,e,t){return new Promise((i,s)=>{const r=El.get(l);if(r&&r.scene.uid===e.uid)return i(r);Ce.LoadAssetContainerAsync(l,void 0,e,t).then(n=>{El.set(l,n),i(n)}).catch(s)})}re.prototype.createDynamicTexture=function(l,e,t,i){const s=new ht(this,Fe.Dynamic);return s.baseWidth=l,s.baseHeight=e,t&&(l=this.needPOTTextures?re.GetExponentOfTwo(l,this._caps.maxTextureSize):l,e=this.needPOTTextures?re.GetExponentOfTwo(e,this._caps.maxTextureSize):e),s.width=l,s.height=e,s.isReady=!1,s.generateMipMaps=t,s.samplingMode=i,this.updateTextureSamplingMode(i,s),this._internalTexturesCache.push(s),s},re.prototype.updateDynamicTexture=function(l,e,t,i=!1,s,r=!1,n=!1){if(!l)return;const a=this._gl,o=a.TEXTURE_2D,h=this._bindTextureDirectly(o,l,!0,r);this._unpackFlipY(t===void 0?l.invertY:t),i&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);const c=this._getWebGLTextureType(l.type),u=this._getInternalFormat(s||l.format),f=this._getRGBABufferInternalSizedFormat(l.type,u);a.texImage2D(o,0,f,u,c,e),l.generateMipMaps&&a.generateMipmap(o),h||this._bindTextureDirectly(o,null),i&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),l.isReady=!0};class rr extends O{constructor(e,t,i=null,s=!1,r=3,n=5,a){super(null,i,!s,a,r,void 0,void 0,void 0,void 0,n),this.name=e,this.wrapU=O.CLAMP_ADDRESSMODE,this.wrapV=O.CLAMP_ADDRESSMODE,this._generateMipMaps=s;const o=this._getEngine();if(!o)return;t.getContext?(this._canvas=t,this._texture=o.createDynamicTexture(t.width,t.height,s,r)):(this._canvas=o.createCanvas(1,1),t.width||t.width===0?this._texture=o.createDynamicTexture(t.width,t.height,s,r):this._texture=o.createDynamicTexture(t,t,s,r));const h=this.getSize();this._canvas.width!==h.width&&(this._canvas.width=h.width),this._canvas.height!==h.height&&(this._canvas.height=h.height),this._context=this._canvas.getContext("2d")}getClassName(){return"DynamicTexture"}get canRescale(){return!0}_recreate(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)}scale(e){const t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)}scaleTo(e,t){const i=this.getSize();i.width=e,i.height=t,this._recreate(i)}getContext(){return this._context}clear(){const e=this.getSize();this._context.fillRect(0,0,e.width,e.height)}update(e,t=!1,i=!1){this._getEngine().updateDynamicTexture(this._texture,this._canvas,e===void 0?!0:e,t,this._format||void 0,void 0,i)}drawText(e,t,i,s,r,n,a,o=!0){const h=this.getSize();if(n&&(this._context.fillStyle=n,this._context.fillRect(0,0,h.width,h.height)),this._context.font=s,t==null){const c=this._context.measureText(e);t=(h.width-c.width)/2}if(i==null){const c=parseInt(s.replace(/\D/g,""));i=h.height/2+c/3.65}this._context.fillStyle=r||"",this._context.fillText(e,t,i),o&&this.update(a)}clone(){const e=this.getScene();if(!e)return this;const t=this.getSize(),i=new rr(this.name,t,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i}serialize(){const e=this.getScene();e&&!e.isReady()&&F.Warn("The scene must be ready before serializing the dynamic texture");const t=super.serialize();return rr._IsCanvasElement(this._canvas)&&(t.base64String=this._canvas.toDataURL()),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t}static _IsCanvasElement(e){return e.toDataURL!==void 0}_rebuild(){this.update()}}function ym(l,e,t,i,s=""){t.forEach(r=>{const n=r.getID(),a=r.getName(),o=sr.getDynamicTextureResolution();l.filter(c=>c.name===s+a).forEach(c=>{const u=i.get(n),f=!1;if(u)Al(c,u),u.update(f);else{const d=Mm(a,e,o.width,o.height);i.set(n,d),r.setStaticContext(d.getContext()),Al(c,d),d.onLoadObservable.addOnce(()=>{d.update(f)})}})})}function Mm(l,e,t,i){const s=new rr(l,{width:t,height:i},e,sr.shouldMipMap(),O.TRILINEAR_SAMPLINGMODE,L.TEXTUREFORMAT_RGBA),r=s.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),s.update()),s}function Al(l,e){if(l instanceof j){const t=l,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=l,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Pm(){const l=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return l()+l()+"-"+l()+"-"+l()+"-"+l()+"-"+l()+l()+l()}const Gr=60,vl=1;function Sl(l){return l.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/l.targetedAnimations.length||0}function Om(l,e,t,i,s){const r=s?l.filter(n=>n.name===s):l;if(r.length===0){console.warn(`No animations found for name: ${s}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(n=>{n.stop();const a=Sl(n),o=i*a;n.start(e,vl,o,o)});return}r.forEach(n=>{n.stop();const a=Sl(n),o=i!==void 0?i*a:void 0,h=t!==void 0?t*a:void 0;n.start(e,vl,o,h)})}function Rl(l){l.forEach(e=>{e.stop()})}function Dm(l){const e=l.animationGroups;Rl(e)}function Lm(l,e,t){l.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Nm(e.alpha,0,2*Math.PI));const i=[],s=t.target,r=0,n=s?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(En("cameraTargetLerp","target",new E().copyFrom(e.target),new E(t.target.x,t.target.y,t.target.z),N.ANIMATIONTYPE_VECTOR3,r)),i.push(En("cameraAlphaLerp","alpha",e.alpha,xl(t.lonDeg),N.ANIMATIONTYPE_FLOAT,n)),i.push(En("cameraBetaLerp","beta",e.beta,xl(t.latDeg),N.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const h=Math.max(.01,t.radius);i.push(En("cameraRadiusLerp","radius",e.radius,h,N.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const o=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),l.beginAnimation(e,0,s?Gr*2:Gr,!1,1,()=>{e.animations=[],o&&e.enableAutoRotationBehavior()})}function xl(l){return l*Math.PI/180}function En(l,e,t,i,s,r=0,n=N.ANIMATIONLOOPMODE_CONSTANT){const a=new oc;a.setEasingMode(ri.EASINGMODE_EASEINOUT);const o=new N(l,e,Gr,s,n),h=[];return r>0&&h.push({frame:0,value:t}),h.push({frame:Gr*r,value:t}),h.push({frame:Gr*(r+1),value:i}),o.setKeys(h),o.setEasingFunction(a),o}function Nm(l,e,t){return l<e?l=t-(e-l)%(t-e):l=e+(l-e)%(t-e)}class _s{static ConvertPanoramaToCubemap(e,t,i,s,r=!1){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";const n=this.CreateCubemapTexture(s,this.FACE_FRONT,e,t,i,r),a=this.CreateCubemapTexture(s,this.FACE_BACK,e,t,i,r),o=this.CreateCubemapTexture(s,this.FACE_LEFT,e,t,i,r),h=this.CreateCubemapTexture(s,this.FACE_RIGHT,e,t,i,r),c=this.CreateCubemapTexture(s,this.FACE_UP,e,t,i,r),u=this.CreateCubemapTexture(s,this.FACE_DOWN,e,t,i,r);return{front:n,back:a,left:o,right:h,up:c,down:u,size:s,type:1,format:4,gammaSpace:!1}}static CreateCubemapTexture(e,t,i,s,r,n=!1){const a=new ArrayBuffer(e*e*4*3),o=new Float32Array(a),h=n?Math.max(1,Math.round(s/4/e)):1,c=1/h,u=c*c,f=t[1].subtract(t[0]).scale(c/e),d=t[3].subtract(t[2]).scale(c/e),_=1/e;let p=0;for(let m=0;m<e;m++)for(let T=0;T<h;T++){let S=t[0],x=t[2];for(let b=0;b<e;b++)for(let I=0;I<h;I++){const R=x.subtract(S).scale(p).add(S);R.normalize();const C=this.CalcProjectionSpherical(R,i,s,r);o[m*e*3+b*3+0]+=C.r*u,o[m*e*3+b*3+1]+=C.g*u,o[m*e*3+b*3+2]+=C.b*u,S=S.add(f),x=x.add(d)}p+=_*c}return o}static CalcProjectionSpherical(e,t,i,s){let r=Math.atan2(e.z,e.x);const n=Math.acos(e.y);for(;r<-Math.PI;)r+=2*Math.PI;for(;r>Math.PI;)r-=2*Math.PI;let a=r/Math.PI;const o=n/Math.PI;a=a*.5+.5;let h=Math.round(a*i);h<0?h=0:h>=i&&(h=i-1);let c=Math.round(o*s);c<0?c=0:c>=s&&(c=s-1);const u=s-c-1,f=t[u*i*3+h*3+0],d=t[u*i*3+h*3+1],_=t[u*i*3+h*3+2];return{r:f,g:d,b:_}}}_s.FACE_LEFT=[new E(-1,-1,-1),new E(1,-1,-1),new E(-1,1,-1),new E(1,1,-1)],_s.FACE_RIGHT=[new E(1,-1,1),new E(-1,-1,1),new E(1,1,1),new E(-1,1,1)],_s.FACE_FRONT=[new E(1,-1,-1),new E(1,-1,1),new E(1,1,-1),new E(1,1,1)],_s.FACE_BACK=[new E(-1,-1,1),new E(-1,-1,-1),new E(-1,1,1),new E(-1,1,-1)],_s.FACE_DOWN=[new E(1,1,-1),new E(1,1,1),new E(-1,1,-1),new E(-1,1,1)],_s.FACE_UP=[new E(-1,-1,-1),new E(-1,-1,1),new E(1,-1,-1),new E(1,-1,1)];class Fm{static _Ldexp(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)}static _Rgbe2float(e,t,i,s,r,n){r>0?(r=this._Ldexp(1,r-(128+8)),e[n+0]=t*r,e[n+1]=i*r,e[n+2]=s*r):(e[n+0]=0,e[n+1]=0,e[n+2]=0)}static _ReadStringLine(e,t){let i="",s="";for(let r=t;r<e.length-t&&(s=String.fromCharCode(e[r]),s!=`
7592
- `);r++)i+=s;return i}static RGBE_ReadHeader(e){let t=0,i=0,s=this._ReadStringLine(e,0);if(s[0]!="#"||s[1]!="?")throw"Bad HDR Format.";let r=!1,n=!1,a=0;do a+=s.length+1,s=this._ReadStringLine(e,a),s=="FORMAT=32-bit_rle_rgbe"?n=!0:s.length==0&&(r=!0);while(!r);if(!n)throw"HDR Bad header format, unsupported FORMAT";a+=s.length+1,s=this._ReadStringLine(e,a);const h=/^-Y (.*) \+X (.*)$/g.exec(s);if(!h||h.length<3)throw"HDR Bad header format, no size";if(i=parseInt(h[2]),t=parseInt(h[1]),i<8||i>32767)throw"HDR Bad header format, unsupported size";return a+=s.length+1,{height:t,width:i,dataPosition:a}}static GetCubeMapTextureData(e,t,i=!1){const s=new Uint8Array(e),r=this.RGBE_ReadHeader(s),n=this.RGBE_ReadPixels(s,r);return _s.ConvertPanoramaToCubemap(n,r.width,r.height,t,i)}static RGBE_ReadPixels(e,t){return this._RGBEReadPixelsRLE(e,t)}static _RGBEReadPixelsRLE(e,t){let i=t.height;const s=t.width;let r,n,a,o,h,c=t.dataPosition,u=0,f=0,d=0;const _=new ArrayBuffer(s*4),p=new Uint8Array(_),m=new ArrayBuffer(t.width*t.height*4*3),T=new Float32Array(m);for(;i>0;){if(r=e[c++],n=e[c++],a=e[c++],o=e[c++],r!=2||n!=2||a&128||t.width<8||t.width>32767)return this._RGBEReadPixelsNOTRLE(e,t);if((a<<8|o)!=s)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(f=(d+1)*s;u<f;)if(r=e[c++],n=e[c++],r>128){if(h=r-128,h==0||h>f-u)throw"HDR Bad Format, bad scanline data (run)";for(;h-- >0;)p[u++]=n}else{if(h=r,h==0||h>f-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=n,--h>0)for(let S=0;S<h;S++)p[u++]=e[c++]}for(d=0;d<s;d++)r=p[d],n=p[d+s],a=p[d+2*s],o=p[d+3*s],this._Rgbe2float(T,r,n,a,o,(t.height-i)*s*3+d*3);i--}return T}static _RGBEReadPixelsNOTRLE(e,t){let i=t.height;const s=t.width;let r,n,a,o,h,c=t.dataPosition;const u=new ArrayBuffer(t.width*t.height*4*3),f=new Float32Array(u);for(;i>0;){for(h=0;h<t.width;h++)r=e[c++],n=e[c++],a=e[c++],o=e[c++],this._Rgbe2float(f,r,n,a,o,(t.height-i)*s*3+h*3);i--}return f}}const wm="hdrFilteringVertexShader",Bm=`attribute vec2 position;
7591
+ `),this._engine.createEffect("glowMapMerge",[A.PositionKind],["offset"],["textureSampler","textureSampler2"],e)}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width,t=this._mainTextureDesiredSize.height;e=this._engine.needPOTTextures?L.GetExponentOfTwo(e,this._maxSize):e,t=this._engine.needPOTTextures?L.GetExponentOfTwo(t,this._maxSize):t;let i=0;this._engine.getCaps().textureHalfFloatRender?i=2:i=0,this._blurTexture1=new Dt("GlowLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,i),this._blurTexture1.wrapU=O.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=O.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(O.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;const s=Math.floor(e/2),r=Math.floor(t/2);this._blurTexture2=new Dt("GlowLayerBlurRTT2",{width:s,height:r},this._scene,!1,!0,i),this._blurTexture2.wrapU=O.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=O.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(O.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2];const n=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1=new gt("GlowLayerHBP1",new ae(1,0),n,{width:e,height:t},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._horizontalBlurPostprocess1.width=e,this._horizontalBlurPostprocess1.height=t,this._horizontalBlurPostprocess1.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess1.onApplyObservable.add(a=>{a.setTexture("textureSampler",this._mainTexture)}),this._verticalBlurPostprocess1=new gt("GlowLayerVBP1",new ae(0,1),n,{width:e,height:t},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._horizontalBlurPostprocess2=new gt("GlowLayerHBP2",new ae(1,0),n,{width:s,height:r},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._horizontalBlurPostprocess2.width=s,this._horizontalBlurPostprocess2.height=r,this._horizontalBlurPostprocess2.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess2.onApplyObservable.add(a=>{a.setTexture("textureSampler",this._blurTexture1)}),this._verticalBlurPostprocess2=new gt("GlowLayerVBP2",new ae(0,1),n,{width:s,height:r},null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add(()=>{const a=this._blurTexture1.renderTarget;if(a){this._scene.postProcessManager.directRender(this._postProcesses1,a,!0);const o=this._blurTexture2.renderTarget;o&&this._scene.postProcessManager.directRender(this._postProcesses2,o,!0),this._engine.unBindFramebuffer(o??a,!0)}}),this._postProcesses.map(a=>{a.autoClear=!1})}_getEffectiveBlurKernelSize(){return this._options.blurKernelSize/2}isReady(e,t){const i=e.getMaterial(),s=e.getRenderingMesh();if(!i||!s)return!1;const r=i.emissiveTexture;return super._isReady(e,t,r)}needStencil(){return!1}_canRenderMesh(e,t){return!0}_internalRender(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);const t=this._engine,i=t.getStencilBuffer();t.setStencilBuffer(!1),t.drawElementsType(V.TriangleFillMode,0,6),t.setStencilBuffer(i)}_setEmissiveTextureAndColor(e,t,i){var s;let r=1;if(this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(r=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector)this.customEmissiveColorSelector(e,t,i,this._emissiveTextureAndColor.color);else if(i.emissiveColor){const n=(s=i.emissiveIntensity)!==null&&s!==void 0?s:1;r*=n,this._emissiveTextureAndColor.color.set(i.emissiveColor.r*r,i.emissiveColor.g*r,i.emissiveColor.b*r,i.alpha)}else this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)}_shouldRenderMesh(e){return this.hasMesh(e)}_addCustomEffectDefines(e){e.push("#define GLOW")}addExcludedMesh(e){this._excludedMeshes.indexOf(e.uniqueId)===-1&&this._excludedMeshes.push(e.uniqueId)}removeExcludedMesh(e){const t=this._excludedMeshes.indexOf(e.uniqueId);t!==-1&&this._excludedMeshes.splice(t,1)}addIncludedOnlyMesh(e){this._includedOnlyMeshes.indexOf(e.uniqueId)===-1&&this._includedOnlyMeshes.push(e.uniqueId)}removeIncludedOnlyMesh(e){const t=this._includedOnlyMeshes.indexOf(e.uniqueId);t!==-1&&this._includedOnlyMeshes.splice(t,1)}hasMesh(e){return super.hasMesh(e)?this._includedOnlyMeshes.length?this._includedOnlyMeshes.indexOf(e.uniqueId)!==-1:this._excludedMeshes.length?this._excludedMeshes.indexOf(e.uniqueId)===-1:!0:!1}_useMeshMaterial(e){return this._meshesUsingTheirOwnMaterials.length==0?!1:this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1}referenceMeshToUseItsOwnMaterial(e){e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add(()=>{this._disposeMesh(e)})}unReferenceMeshFromUsingItsOwnMaterial(e){let t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);for(;t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);e.resetDrawCache(this._mainTexture.renderPassId)}_disposeMesh(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)}getClassName(){return"GlowLayer"}serialize(){const e=J.Serialize(this);e.customType="BABYLON.GlowLayer";let t;if(e.includedMeshes=[],this._includedOnlyMeshes.length)for(t=0;t<this._includedOnlyMeshes.length;t++){const i=this._scene.getMeshByUniqueId(this._includedOnlyMeshes[t]);i&&e.includedMeshes.push(i.id)}if(e.excludedMeshes=[],this._excludedMeshes.length)for(t=0;t<this._excludedMeshes.length;t++){const i=this._scene.getMeshByUniqueId(this._excludedMeshes[t]);i&&e.excludedMeshes.push(i.id)}return e}static Parse(e,t,i){const s=J.Parse(()=>new ei(e.name,t,e.options),e,t,i);let r;for(r=0;r<e.excludedMeshes.length;r++){const n=t.getMeshById(e.excludedMeshes[r]);n&&s.addExcludedMesh(n)}for(r=0;r<e.includedMeshes.length;r++){const n=t.getMeshById(e.includedMeshes[r]);n&&s.addIncludedOnlyMesh(n)}return s}}ei.EffectName="GlowLayer",ei.DefaultBlurKernelSize=32,ei.DefaultTextureRatio=.5,g([v()],ei.prototype,"blurKernelSize",null),g([v()],ei.prototype,"intensity",null),g([v("options")],ei.prototype,"_options",void 0),Re("BABYLON.GlowLayer",ei);class Em{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new ei("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}const Tm=Em;class $e{constructor(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new B,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,this._nextActiveAction=this,this._condition=t}_prepare(){}getTriggerParameter(){return this._triggerParameter}setTriggerParameter(e){this._triggerParameter=e}_evaluateConditionForCurrentFrame(){const e=this._condition;if(!e)return!0;const t=this._actionManager.getScene().getRenderId();return e._evaluationId!==t&&(e._evaluationId=t,e._currentResult=e.isValid()),e._currentResult}_executeCurrent(e){this._evaluateConditionForCurrentFrame()&&(this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction())}execute(e){}skipToNextActiveAction(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this}then(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e}_getProperty(e){return this._actionManager._getProperty(e)}_getEffectiveTarget(e,t){return this._actionManager._getEffectiveTarget(e,t)}serialize(e){}_serialize(e,t){const i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){const s=this._condition.serialize();return s.children.push(i),t&&t.children.push(s),s}return t&&t.children.push(i),i}}$e._SerializeValueAsString=l=>typeof l=="number"?l.toString():typeof l=="boolean"?l?"true":"false":l instanceof ae?l.x+", "+l.y:l instanceof E?l.x+", "+l.y+", "+l.z:l instanceof z?l.r+", "+l.g+", "+l.b:l instanceof ge?l.r+", "+l.g+", "+l.b+", "+l.a:l,$e._GetTargetProperty=l=>({name:"target",targetType:l._isMesh?"MeshProperties":l._isLight?"LightProperties":l._isCamera?"CameraProperties":l._isMaterial?"MaterialProperties":"SceneProperties",value:l._isScene?"Scene":l.name}),Re("BABYLON.Action",$e);class kr{constructor(e){this._actionManager=e}isValid(){return!0}_getProperty(e){return this._actionManager._getProperty(e)}_getEffectiveTarget(e,t){return this._actionManager._getEffectiveTarget(e,t)}serialize(){}_serialize(e){return{type:2,children:[],name:e.name,properties:e.properties}}}class _t extends kr{static get IsEqual(){return _t._IsEqual}static get IsDifferent(){return _t._IsDifferent}static get IsGreater(){return _t._IsGreater}static get IsLesser(){return _t._IsLesser}constructor(e,t,i,s,r=_t.IsEqual){super(e),this.propertyPath=i,this.value=s,this.operator=r,this._target=t,this._effectiveTarget=this._getEffectiveTarget(t,this.propertyPath),this._property=this._getProperty(this.propertyPath)}isValid(){switch(this.operator){case _t.IsGreater:return this._effectiveTarget[this._property]>this.value;case _t.IsLesser:return this._effectiveTarget[this._property]<this.value;case _t.IsEqual:case _t.IsDifferent:{let e;return this.value.equals?e=this.value.equals(this._effectiveTarget[this._property]):e=this.value===this._effectiveTarget[this._property],this.operator===_t.IsEqual?e:!e}}return!1}serialize(){return this._serialize({name:"ValueCondition",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:$e._SerializeValueAsString(this.value)},{name:"operator",value:_t.GetOperatorName(this.operator)}]})}static GetOperatorName(e){switch(e){case _t._IsEqual:return"IsEqual";case _t._IsDifferent:return"IsDifferent";case _t._IsGreater:return"IsGreater";case _t._IsLesser:return"IsLesser";default:return""}}}_t._IsEqual=0,_t._IsDifferent=1,_t._IsGreater=2,_t._IsLesser=3;class Am extends kr{constructor(e,t){super(e),this.predicate=t}isValid(){return this.predicate()}}class vm extends kr{constructor(e,t,i){super(e),this.value=i,this._target=t}isValid(){return this._target.state===this.value}serialize(){return this._serialize({name:"StateCondition",properties:[$e._GetTargetProperty(this._target),{name:"value",value:this.value}]})}}Re("BABYLON.ValueCondition",_t),Re("BABYLON.PredicateCondition",Am),Re("BABYLON.StateCondition",vm);class Sm extends $e{constructor(e,t,i,s){super(e,s),this.propertyPath=i,this._target=this._effectiveTarget=t}_prepare(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)}execute(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]}serialize(e){return super._serialize({name:"SwitchBooleanAction",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},e)}}class Rm extends $e{constructor(e,t,i,s){super(e,s),this.value=i,this._target=t}execute(){this._target.state=this.value}serialize(e){return super._serialize({name:"SetStateAction",properties:[$e._GetTargetProperty(this._target),{name:"value",value:this.value}]},e)}}class xm extends $e{constructor(e,t,i,s,r){super(e,r),this.propertyPath=i,this.value=s,this._target=this._effectiveTarget=t}_prepare(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)}execute(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)}serialize(e){return super._serialize({name:"SetValueAction",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:$e._SerializeValueAsString(this.value)}]},e)}}class Cm extends $e{constructor(e,t,i,s,r){super(e,r),this.propertyPath=i,this.value=s,this._target=this._effectiveTarget=t}_prepare(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),typeof this._effectiveTarget[this._property]!="number"&&F.Warn("Warning: IncrementValueAction can only be used with number values")}execute(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)}serialize(e){return super._serialize({name:"IncrementValueAction",properties:[$e._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:$e._SerializeValueAsString(this.value)}]},e)}}class bm extends $e{constructor(e,t,i,s,r,n){super(e,n),this.from=i,this.to=s,this.loop=r,this._target=t}_prepare(){}execute(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)}serialize(e){return super._serialize({name:"PlayAnimationAction",properties:[$e._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:$e._SerializeValueAsString(this.loop)||!1}]},e)}}class Im extends $e{constructor(e,t,i){super(e,i),this._target=t}_prepare(){}execute(){this._actionManager.getScene().stopAnimation(this._target)}serialize(e){return super._serialize({name:"StopAnimationAction",properties:[$e._GetTargetProperty(this._target)]},e)}}class ml extends $e{constructor(e=0,t){super(e,t)}execute(){}serialize(e){return super._serialize({name:"DoNothingAction",properties:[]},e)}}class ym extends $e{constructor(e,t,i,s=!0){super(e,i),this.children=t,this.enableChildrenConditions=s}_prepare(){for(let e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()}execute(e){for(const t of this.children)(!this.enableChildrenConditions||t._evaluateConditionForCurrentFrame())&&t.execute(e)}serialize(e){const t=super._serialize({name:"CombineAction",properties:[],combine:[]},e);for(let i=0;i<this.children.length;i++)t.combine.push(this.children[i].serialize(null));return t}}class Oa extends $e{constructor(e,t,i){super(e,i),this.func=t}execute(e){this.func(e)}}class gl extends $e{constructor(e,t,i,s){super(e,s),this._target=t,this._parent=i}_prepare(){}execute(){if(this._target.parent===this._parent)return;const e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=E.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}serialize(e){return super._serialize({name:"SetParentAction",properties:[$e._GetTargetProperty(this._target),$e._GetTargetProperty(this._parent)]},e)}}Re("BABYLON.SetParentAction",gl),Re("BABYLON.ExecuteCodeAction",Oa),Re("BABYLON.DoNothingAction",ml),Re("BABYLON.StopAnimationAction",Im),Re("BABYLON.PlayAnimationAction",bm),Re("BABYLON.IncrementValueAction",Cm),Re("BABYLON.SetValueAction",xm),Re("BABYLON.SetStateAction",Rm),Re("BABYLON.SetParentAction",gl),Re("BABYLON.SwitchBooleanAction",Sm),Re("BABYLON.CombineAction",ym);class Pe extends Qt{constructor(e){super(),e=e||Ee.LastCreatedScene,e&&(this._scene=e,e.actionManagers.push(this))}dispose(){const e=this._scene.actionManagers.indexOf(this);for(let t=0;t<this.actions.length;t++){const i=this.actions[t];Pe.Triggers[i.trigger]--,Pe.Triggers[i.trigger]===0&&delete Pe.Triggers[i.trigger]}e>-1&&this._scene.actionManagers.splice(e,1)}getScene(){return this._scene}hasSpecificTriggers(e){for(let t=0;t<this.actions.length;t++){const i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1}hasSpecificTriggers2(e,t){for(let i=0;i<this.actions.length;i++){const s=this.actions[i];if(e==s.trigger||t==s.trigger)return!0}return!1}hasSpecificTrigger(e,t){for(let i=0;i<this.actions.length;i++){const s=this.actions[i];if(s.trigger===e)if(t){if(t(s.getTriggerParameter()))return!0}else return!0}return!1}get hasPointerTriggers(){for(let e=0;e<this.actions.length;e++){const t=this.actions[e];if(t.trigger>=Pe.OnPickTrigger&&t.trigger<=Pe.OnPointerOutTrigger)return!0}return!1}get hasPickTriggers(){for(let e=0;e<this.actions.length;e++){const t=this.actions[e];if(t.trigger>=Pe.OnPickTrigger&&t.trigger<=Pe.OnPickUpTrigger)return!0}return!1}registerAction(e){return e.trigger===Pe.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(F.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),this.getScene()._registeredActions++,Pe.Triggers[e.trigger]?Pe.Triggers[e.trigger]++:Pe.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)}unregisterAction(e){const t=this.actions.indexOf(e);return t!==-1?(this.actions.splice(t,1),Pe.Triggers[e.trigger]-=1,Pe.Triggers[e.trigger]===0&&delete Pe.Triggers[e.trigger],e._actionManager=null,this.getScene()._registeredActions--,!0):!1}processTrigger(e,t){for(let i=0;i<this.actions.length;i++){const s=this.actions[i];if(s.trigger===e){if(t&&(e===Pe.OnKeyUpTrigger||e===Pe.OnKeyDownTrigger)){const r=s.getTriggerParameter();if(typeof r=="function"){if(!r(t))continue}else if(r&&r!==t.sourceEvent.keyCode){if(!r.toLowerCase)continue;const n=r.toLowerCase();if(n!==t.sourceEvent.key){const a=t.sourceEvent.charCode?t.sourceEvent.charCode:t.sourceEvent.keyCode;if(String.fromCharCode(a).toLowerCase()!==n)continue}}}s._executeCurrent(t)}}}_getEffectiveTarget(e,t){const i=t.split(".");for(let s=0;s<i.length-1;s++)e=e[i[s]];return e}_getProperty(e){const t=e.split(".");return t[t.length-1]}serialize(e){const t={children:new Array,name:e,type:3,properties:new Array};for(let i=0;i<this.actions.length;i++){const s={type:0,children:new Array,name:Pe.GetTriggerName(this.actions[i].trigger),properties:new Array},r=this.actions[i].triggerOptions;if(r&&typeof r!="number")if(r.parameter instanceof Node)s.properties.push($e._GetTargetProperty(r.parameter));else if(typeof r.parameter=="object"){const n={};pr.DeepCopy(r.parameter,n,["mesh"]),r.parameter&&r.parameter.mesh&&(n._meshId=r.parameter.mesh.id),s.properties.push({name:"parameter",targetType:null,value:n})}else s.properties.push({name:"parameter",targetType:null,value:r.parameter});this.actions[i].serialize(s),t.children.push(s)}return t}static Parse(e,t,i){const s=new Pe(i);t===null?i.actionManager=s:t.actionManager=s;const r=(o,h)=>{const c=Ri("BABYLON."+o);return c&&new c(...h)},n=(o,h,c,u)=>{if(u===null){const p=parseFloat(h);return h==="true"||h==="false"?h==="true":isNaN(p)?h:p}const f=u.split("."),d=h.split(",");for(let p=0;p<f.length;p++)c=c[f[p]];if(typeof c=="boolean")return d[0]==="true";if(typeof c=="string")return d[0];const _=new Array;for(let p=0;p<d.length;p++)_.push(parseFloat(d[p]));return c instanceof E?E.FromArray(_):c instanceof He?He.FromArray(_):c instanceof z?z.FromArray(_):c instanceof ge?ge.FromArray(_):parseFloat(d[0])},a=(o,h,c,u,f=null)=>{if(o.detached)return;const d=new Array;let _=null,p=null;const m=o.combine&&o.combine.length>0;if(o.type===2?d.push(s):d.push(h),m){const S=new Array;for(let x=0;x<o.combine.length;x++)a(o.combine[x],Pe.NothingTrigger,c,u,S);d.push(S)}else for(let S=0;S<o.properties.length;S++){let x=o.properties[S].value;const b=o.properties[S].name,I=o.properties[S].targetType;b==="target"?I==="SceneProperties"?x=_=i:I==="MaterialProperties"?x=_=i.getMaterialByName(x):x=_=i.getNodeByName(x):b==="parent"?x=i.getNodeByName(x):b==="sound"?i.getSoundByName&&(x=i.getSoundByName(x)):b!=="propertyPath"?o.type===2&&b==="operator"?x=_t[x]:x=n(b,x,_,b==="value"?p:null):p=x,d.push(x)}if(f===null?d.push(c):d.push(null),o.name==="InterpolateValueAction"){const S=d[d.length-2];d[d.length-1]=S,d[d.length-2]=c}let T=r(o.name,d);if(T instanceof kr&&c!==null){const S=new ml(h,c);u?u.then(S):s.registerAction(S),u=S}f===null?T instanceof kr?(c=T,T=u):(c=null,u?u.then(T):s.registerAction(T)):f.push(T);for(let S=0;S<o.children.length;S++)a(o.children[S],h,c,T,null)};for(let o=0;o<e.children.length;o++){let h;const c=e.children[o];if(c.properties.length>0){const u=c.properties[0].value,f=c.properties[0].targetType===null?u:i.getMeshByName(u);f._meshId&&(f.mesh=i.getMeshById(f._meshId)),h={trigger:Pe[c.name],parameter:f}}else h=Pe[c.name];for(let u=0;u<c.children.length;u++)c.detached||a(c.children[u],h,null,null)}}static GetTriggerName(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnDoublePickTrigger";case 7:return"OnPickUpTrigger";case 8:return"OnLongPressTrigger";case 9:return"OnPointerOverTrigger";case 10:return"OnPointerOutTrigger";case 11:return"OnEveryFrameTrigger";case 12:return"OnIntersectionEnterTrigger";case 13:return"OnIntersectionExitTrigger";case 14:return"OnKeyDownTrigger";case 15:return"OnKeyUpTrigger";case 16:return"OnPickOutTrigger";default:return""}}}Pe.NothingTrigger=0,Pe.OnPickTrigger=1,Pe.OnLeftPickTrigger=2,Pe.OnRightPickTrigger=3,Pe.OnCenterPickTrigger=4,Pe.OnPickDownTrigger=5,Pe.OnDoublePickTrigger=6,Pe.OnPickUpTrigger=7,Pe.OnPickOutTrigger=16,Pe.OnLongPressTrigger=8,Pe.OnPointerOverTrigger=9,Pe.OnPointerOutTrigger=10,Pe.OnEveryFrameTrigger=11,Pe.OnIntersectionEnterTrigger=12,Pe.OnIntersectionExitTrigger=13,Pe.OnKeyDownTrigger=14,Pe.OnKeyUpTrigger=15;const El=new Map;async function Tl(l,e,t){return new Promise((i,s)=>{const r=El.get(l);if(r&&r.scene.uid===e.uid)return i(r);Ce.LoadAssetContainerAsync(l,void 0,e,t).then(n=>{El.set(l,n),i(n)}).catch(s)})}re.prototype.createDynamicTexture=function(l,e,t,i){const s=new ht(this,Fe.Dynamic);return s.baseWidth=l,s.baseHeight=e,t&&(l=this.needPOTTextures?re.GetExponentOfTwo(l,this._caps.maxTextureSize):l,e=this.needPOTTextures?re.GetExponentOfTwo(e,this._caps.maxTextureSize):e),s.width=l,s.height=e,s.isReady=!1,s.generateMipMaps=t,s.samplingMode=i,this.updateTextureSamplingMode(i,s),this._internalTexturesCache.push(s),s},re.prototype.updateDynamicTexture=function(l,e,t,i=!1,s,r=!1,n=!1){if(!l)return;const a=this._gl,o=a.TEXTURE_2D,h=this._bindTextureDirectly(o,l,!0,r);this._unpackFlipY(t===void 0?l.invertY:t),i&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);const c=this._getWebGLTextureType(l.type),u=this._getInternalFormat(s||l.format),f=this._getRGBABufferInternalSizedFormat(l.type,u);a.texImage2D(o,0,f,u,c,e),l.generateMipMaps&&a.generateMipmap(o),h||this._bindTextureDirectly(o,null),i&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),l.isReady=!0};class rr extends O{constructor(e,t,i=null,s=!1,r=3,n=5,a){super(null,i,!s,a,r,void 0,void 0,void 0,void 0,n),this.name=e,this.wrapU=O.CLAMP_ADDRESSMODE,this.wrapV=O.CLAMP_ADDRESSMODE,this._generateMipMaps=s;const o=this._getEngine();if(!o)return;t.getContext?(this._canvas=t,this._texture=o.createDynamicTexture(t.width,t.height,s,r)):(this._canvas=o.createCanvas(1,1),t.width||t.width===0?this._texture=o.createDynamicTexture(t.width,t.height,s,r):this._texture=o.createDynamicTexture(t,t,s,r));const h=this.getSize();this._canvas.width!==h.width&&(this._canvas.width=h.width),this._canvas.height!==h.height&&(this._canvas.height=h.height),this._context=this._canvas.getContext("2d")}getClassName(){return"DynamicTexture"}get canRescale(){return!0}_recreate(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)}scale(e){const t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)}scaleTo(e,t){const i=this.getSize();i.width=e,i.height=t,this._recreate(i)}getContext(){return this._context}clear(){const e=this.getSize();this._context.fillRect(0,0,e.width,e.height)}update(e,t=!1,i=!1){this._getEngine().updateDynamicTexture(this._texture,this._canvas,e===void 0?!0:e,t,this._format||void 0,void 0,i)}drawText(e,t,i,s,r,n,a,o=!0){const h=this.getSize();if(n&&(this._context.fillStyle=n,this._context.fillRect(0,0,h.width,h.height)),this._context.font=s,t==null){const c=this._context.measureText(e);t=(h.width-c.width)/2}if(i==null){const c=parseInt(s.replace(/\D/g,""));i=h.height/2+c/3.65}this._context.fillStyle=r||"",this._context.fillText(e,t,i),o&&this.update(a)}clone(){const e=this.getScene();if(!e)return this;const t=this.getSize(),i=new rr(this.name,t,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i}serialize(){const e=this.getScene();e&&!e.isReady()&&F.Warn("The scene must be ready before serializing the dynamic texture");const t=super.serialize();return rr._IsCanvasElement(this._canvas)&&(t.base64String=this._canvas.toDataURL()),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t}static _IsCanvasElement(e){return e.toDataURL!==void 0}_rebuild(){this.update()}}function Mm(l,e,t,i,s=""){t.forEach(r=>{const n=r.getID(),a=r.getName(),o=sr.getDynamicTextureResolution();l.filter(c=>c.name===s+a).forEach(c=>{const u=i.get(n),f=!1;if(u)Al(c,u),u.update(f);else{const d=Pm(a,e,o.width,o.height);i.set(n,d),r.setStaticContext(d.getContext()),Al(c,d),d.onLoadObservable.addOnce(()=>{d.update(f)})}})})}function Pm(l,e,t,i){const s=new rr(l,{width:t,height:i},e,sr.shouldMipMap(),O.TRILINEAR_SAMPLINGMODE,L.TEXTUREFORMAT_RGBA),r=s.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),s.update()),s}function Al(l,e){if(l instanceof j){const t=l,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=l,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Om(){const l=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return l()+l()+"-"+l()+"-"+l()+"-"+l()+"-"+l()+l()+l()}const Gr=60,vl=1;function Sl(l){return l.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/l.targetedAnimations.length||0}function Dm(l,e,t,i,s){const r=s?l.filter(n=>n.name===s):l;if(r.length===0){console.warn(`No animations found for name: ${s}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(n=>{n.stop();const a=Sl(n),o=i*a;n.start(e,vl,o,o)});return}r.forEach(n=>{n.stop();const a=Sl(n),o=i!==void 0?i*a:void 0,h=t!==void 0?t*a:void 0;n.start(e,vl,o,h)})}function Rl(l){l.forEach(e=>{e.stop()})}function Lm(l){const e=l.animationGroups;Rl(e)}function Nm(l,e,t){l.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Fm(e.alpha,0,2*Math.PI));const i=[],s=t.target,r=0,n=s?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(En("cameraTargetLerp","target",new E().copyFrom(e.target),new E(t.target.x,t.target.y,t.target.z),N.ANIMATIONTYPE_VECTOR3,r)),i.push(En("cameraAlphaLerp","alpha",e.alpha,xl(t.lonDeg),N.ANIMATIONTYPE_FLOAT,n)),i.push(En("cameraBetaLerp","beta",e.beta,xl(t.latDeg),N.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const h=Math.max(.01,t.radius);i.push(En("cameraRadiusLerp","radius",e.radius,h,N.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const o=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),l.beginAnimation(e,0,s?Gr*2:Gr,!1,1,()=>{e.animations=[],o&&e.enableAutoRotationBehavior()})}function xl(l){return l*Math.PI/180}function En(l,e,t,i,s,r=0,n=N.ANIMATIONLOOPMODE_CONSTANT){const a=new oc;a.setEasingMode(ri.EASINGMODE_EASEINOUT);const o=new N(l,e,Gr,s,n),h=[];return r>0&&h.push({frame:0,value:t}),h.push({frame:Gr*r,value:t}),h.push({frame:Gr*(r+1),value:i}),o.setKeys(h),o.setEasingFunction(a),o}function Fm(l,e,t){return l<e?l=t-(e-l)%(t-e):l=e+(l-e)%(t-e)}class _s{static ConvertPanoramaToCubemap(e,t,i,s,r=!1){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";const n=this.CreateCubemapTexture(s,this.FACE_FRONT,e,t,i,r),a=this.CreateCubemapTexture(s,this.FACE_BACK,e,t,i,r),o=this.CreateCubemapTexture(s,this.FACE_LEFT,e,t,i,r),h=this.CreateCubemapTexture(s,this.FACE_RIGHT,e,t,i,r),c=this.CreateCubemapTexture(s,this.FACE_UP,e,t,i,r),u=this.CreateCubemapTexture(s,this.FACE_DOWN,e,t,i,r);return{front:n,back:a,left:o,right:h,up:c,down:u,size:s,type:1,format:4,gammaSpace:!1}}static CreateCubemapTexture(e,t,i,s,r,n=!1){const a=new ArrayBuffer(e*e*4*3),o=new Float32Array(a),h=n?Math.max(1,Math.round(s/4/e)):1,c=1/h,u=c*c,f=t[1].subtract(t[0]).scale(c/e),d=t[3].subtract(t[2]).scale(c/e),_=1/e;let p=0;for(let m=0;m<e;m++)for(let T=0;T<h;T++){let S=t[0],x=t[2];for(let b=0;b<e;b++)for(let I=0;I<h;I++){const R=x.subtract(S).scale(p).add(S);R.normalize();const C=this.CalcProjectionSpherical(R,i,s,r);o[m*e*3+b*3+0]+=C.r*u,o[m*e*3+b*3+1]+=C.g*u,o[m*e*3+b*3+2]+=C.b*u,S=S.add(f),x=x.add(d)}p+=_*c}return o}static CalcProjectionSpherical(e,t,i,s){let r=Math.atan2(e.z,e.x);const n=Math.acos(e.y);for(;r<-Math.PI;)r+=2*Math.PI;for(;r>Math.PI;)r-=2*Math.PI;let a=r/Math.PI;const o=n/Math.PI;a=a*.5+.5;let h=Math.round(a*i);h<0?h=0:h>=i&&(h=i-1);let c=Math.round(o*s);c<0?c=0:c>=s&&(c=s-1);const u=s-c-1,f=t[u*i*3+h*3+0],d=t[u*i*3+h*3+1],_=t[u*i*3+h*3+2];return{r:f,g:d,b:_}}}_s.FACE_LEFT=[new E(-1,-1,-1),new E(1,-1,-1),new E(-1,1,-1),new E(1,1,-1)],_s.FACE_RIGHT=[new E(1,-1,1),new E(-1,-1,1),new E(1,1,1),new E(-1,1,1)],_s.FACE_FRONT=[new E(1,-1,-1),new E(1,-1,1),new E(1,1,-1),new E(1,1,1)],_s.FACE_BACK=[new E(-1,-1,1),new E(-1,-1,-1),new E(-1,1,1),new E(-1,1,-1)],_s.FACE_DOWN=[new E(1,1,-1),new E(1,1,1),new E(-1,1,-1),new E(-1,1,1)],_s.FACE_UP=[new E(-1,-1,-1),new E(-1,-1,1),new E(1,-1,-1),new E(1,-1,1)];class wm{static _Ldexp(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)}static _Rgbe2float(e,t,i,s,r,n){r>0?(r=this._Ldexp(1,r-(128+8)),e[n+0]=t*r,e[n+1]=i*r,e[n+2]=s*r):(e[n+0]=0,e[n+1]=0,e[n+2]=0)}static _ReadStringLine(e,t){let i="",s="";for(let r=t;r<e.length-t&&(s=String.fromCharCode(e[r]),s!=`
7592
+ `);r++)i+=s;return i}static RGBE_ReadHeader(e){let t=0,i=0,s=this._ReadStringLine(e,0);if(s[0]!="#"||s[1]!="?")throw"Bad HDR Format.";let r=!1,n=!1,a=0;do a+=s.length+1,s=this._ReadStringLine(e,a),s=="FORMAT=32-bit_rle_rgbe"?n=!0:s.length==0&&(r=!0);while(!r);if(!n)throw"HDR Bad header format, unsupported FORMAT";a+=s.length+1,s=this._ReadStringLine(e,a);const h=/^-Y (.*) \+X (.*)$/g.exec(s);if(!h||h.length<3)throw"HDR Bad header format, no size";if(i=parseInt(h[2]),t=parseInt(h[1]),i<8||i>32767)throw"HDR Bad header format, unsupported size";return a+=s.length+1,{height:t,width:i,dataPosition:a}}static GetCubeMapTextureData(e,t,i=!1){const s=new Uint8Array(e),r=this.RGBE_ReadHeader(s),n=this.RGBE_ReadPixels(s,r);return _s.ConvertPanoramaToCubemap(n,r.width,r.height,t,i)}static RGBE_ReadPixels(e,t){return this._RGBEReadPixelsRLE(e,t)}static _RGBEReadPixelsRLE(e,t){let i=t.height;const s=t.width;let r,n,a,o,h,c=t.dataPosition,u=0,f=0,d=0;const _=new ArrayBuffer(s*4),p=new Uint8Array(_),m=new ArrayBuffer(t.width*t.height*4*3),T=new Float32Array(m);for(;i>0;){if(r=e[c++],n=e[c++],a=e[c++],o=e[c++],r!=2||n!=2||a&128||t.width<8||t.width>32767)return this._RGBEReadPixelsNOTRLE(e,t);if((a<<8|o)!=s)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(f=(d+1)*s;u<f;)if(r=e[c++],n=e[c++],r>128){if(h=r-128,h==0||h>f-u)throw"HDR Bad Format, bad scanline data (run)";for(;h-- >0;)p[u++]=n}else{if(h=r,h==0||h>f-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=n,--h>0)for(let S=0;S<h;S++)p[u++]=e[c++]}for(d=0;d<s;d++)r=p[d],n=p[d+s],a=p[d+2*s],o=p[d+3*s],this._Rgbe2float(T,r,n,a,o,(t.height-i)*s*3+d*3);i--}return T}static _RGBEReadPixelsNOTRLE(e,t){let i=t.height;const s=t.width;let r,n,a,o,h,c=t.dataPosition;const u=new ArrayBuffer(t.width*t.height*4*3),f=new Float32Array(u);for(;i>0;){for(h=0;h<t.width;h++)r=e[c++],n=e[c++],a=e[c++],o=e[c++],this._Rgbe2float(f,r,n,a,o,(t.height-i)*s*3+h*3);i--}return f}}const Bm="hdrFilteringVertexShader",Um=`attribute vec2 position;
7593
7593
  varying vec3 direction;
7594
7594
  uniform vec3 up;
7595
7595
  uniform vec3 right;
@@ -7601,7 +7601,7 @@ mat3 view=mat3(up,right,front);
7601
7601
  direction=view*vec3(position,1.0);
7602
7602
  gl_Position=vec4(position,0.0,1.0);
7603
7603
  #define CUSTOM_VERTEX_MAIN_END
7604
- }`;U.ShadersStore[wm]=Bm;const Um="hdrFilteringPixelShader",Vm=`#include<helperFunctions>
7604
+ }`;U.ShadersStore[Bm]=Um;const Vm="hdrFilteringPixelShader",km=`#include<helperFunctions>
7605
7605
  #include<importanceSampling>
7606
7606
  #include<pbrBRDFFunctions>
7607
7607
  #include<hdrFilteringFunctions>
@@ -7613,7 +7613,7 @@ varying vec3 direction;
7613
7613
  void main() {
7614
7614
  vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);
7615
7615
  gl_FragColor=vec4(color*hdrScale,1.0);
7616
- }`;U.ShadersStore[Um]=Vm;class km{constructor(e,t={}){this._lodGenerationOffset=0,this._lodGenerationScale=.8,this.quality=4096,this.hdrScale=1,this._engine=e,this.hdrScale=t.hdrScale||this.hdrScale,this.quality=t.quality||this.quality}_createRenderTarget(e){let t=0;this._engine.getCaps().textureHalfFloatRender?t=2:this._engine.getCaps().textureFloatRender&&(t=1);const i=this._engine.createRenderTargetCubeTexture(e,{format:5,type:t,createMipMaps:!0,generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,samplingMode:1});return this._engine.updateTextureWrappingMode(i.texture,0,0,0),this._engine.updateTextureSamplingMode(3,i.texture,!0),i}_prefilterInternal(e){const t=e.getSize().width,i=$.ILog2(t)+1,s=this._effectWrapper.effect,r=this._createRenderTarget(t);this._effectRenderer.setViewport();const n=e.getInternalTexture();n&&this._engine.updateTextureSamplingMode(3,n,!0),this._effectRenderer.applyEffectWrapper(this._effectWrapper);const a=[[new E(0,0,-1),new E(0,-1,0),new E(1,0,0)],[new E(0,0,1),new E(0,-1,0),new E(-1,0,0)],[new E(1,0,0),new E(0,0,1),new E(0,1,0)],[new E(1,0,0),new E(0,0,-1),new E(0,-1,0)],[new E(1,0,0),new E(0,-1,0),new E(0,0,1)],[new E(-1,0,0),new E(0,-1,0),new E(0,0,-1)]];s.setFloat("hdrScale",this.hdrScale),s.setFloat2("vFilteringInfo",e.getSize().width,i),s.setTexture("inputTexture",e);for(let c=0;c<6;c++){s.setVector3("up",a[c][0]),s.setVector3("right",a[c][1]),s.setVector3("front",a[c][2]);for(let u=0;u<i;u++){this._engine.bindFramebuffer(r,c,void 0,void 0,!0,u),this._effectRenderer.applyEffectWrapper(this._effectWrapper);let f=Math.pow(2,(u-this._lodGenerationOffset)/this._lodGenerationScale)/t;u===0&&(f=0),s.setFloat("alphaG",f),this._effectRenderer.draw()}}this._effectRenderer.restoreStates(),this._engine.restoreDefaultFramebuffer(),this._engine._releaseTexture(e._texture);const o=r.texture.type,h=r.texture.format;return r._swapAndDie(e._texture),e._texture.type=o,e._texture.format=h,e.gammaSpace=!1,e.lodGenerationOffset=this._lodGenerationOffset,e.lodGenerationScale=this._lodGenerationScale,e._prefiltered=!0,e}_createEffect(e,t){const i=[];return e.gammaSpace&&i.push("#define GAMMA_INPUT"),i.push("#define NUM_SAMPLES "+this.quality+"u"),new No({engine:this._engine,name:"hdrFiltering",vertexShader:"hdrFiltering",fragmentShader:"hdrFiltering",samplerNames:["inputTexture"],uniformNames:["vSampleDirections","vWeights","up","right","front","vFilteringInfo","hdrScale","alphaG"],useShaderStore:!0,defines:i,onCompiled:t})}isReady(e){return e.isReady()&&this._effectWrapper.effect.isReady()}prefilter(e,t=null){return this._engine._features.allowTexturePrefiltering?new Promise(i=>{this._effectRenderer=new Lo(this._engine),this._effectWrapper=this._createEffect(e),this._effectWrapper.effect.executeWhenCompiled(()=>{this._prefilterInternal(e),this._effectRenderer.dispose(),this._effectWrapper.dispose(),i(),t&&t()})}):(F.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."),Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."))}}class Ms extends Ge{set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}set rotationY(e){this._rotationY=e,this.setReflectionTextureMatrix(M.RotationY(this._rotationY))}get rotationY(){return this._rotationY}set boundingBoxSize(e){if(this._boundingBoxSize&&this._boundingBoxSize.equals(e))return;this._boundingBoxSize=e;const t=this.getScene();t&&t.markAllMaterialsAsDirty(1)}get boundingBoxSize(){return this._boundingBoxSize}constructor(e,t,i,s=!1,r=!0,n=!1,a=!1,o=null,h=null,c=!1){var u;super(t),this._generateHarmonics=!0,this._onError=null,this._isBlocking=!0,this._rotationY=0,this.boundingBoxPosition=E.Zero(),this.onLoadObservable=new B,e&&(this._coordinatesMode=O.CUBIC_MODE,this.name=e,this.url=e,this.hasAlpha=!1,this.isCube=!0,this._textureMatrix=M.Identity(),this._prefilterOnLoad=a,this._onLoad=()=>{this.onLoadObservable.notifyObservers(this),o&&o()},this._onError=h,this.gammaSpace=n,this._noMipmap=s,this._size=i,this._supersample=c,this._generateHarmonics=r,this._texture=this._getFromCache(e,this._noMipmap,void 0,void 0,void 0,this.isCube),this._texture?this._texture.isReady?k.SetImmediate(()=>this._onLoad()):this._texture.onLoadedObservable.add(this._onLoad):!((u=this.getScene())===null||u===void 0)&&u.useDelayedTextureLoading?this.delayLoadState=4:this._loadTexture())}getClassName(){return"HDRCubeTexture"}_loadTexture(){const e=this._getEngine(),t=e.getCaps();let i=0;t.textureFloat&&t.textureFloatLinearFiltering?i=1:t.textureHalfFloat&&t.textureHalfFloatLinearFiltering&&(i=2);const s=r=>{this.lodGenerationOffset=0,this.lodGenerationScale=.8;const n=Fm.GetCubeMapTextureData(r,this._size,this._supersample);if(this._generateHarmonics){const c=Js.ConvertCubeMapToSphericalPolynomial(n);this.sphericalPolynomial=c}const a=[];let o=null,h=null;for(let c=0;c<6;c++){i===2?h=new Uint16Array(this._size*this._size*3):i===0&&(o=new Uint8Array(this._size*this._size*3));const u=n[Ms._FacesMapping[c]];if(this.gammaSpace||h||o){for(let f=0;f<this._size*this._size;f++)if(this.gammaSpace&&(u[f*3+0]=Math.pow(u[f*3+0],fr),u[f*3+1]=Math.pow(u[f*3+1],fr),u[f*3+2]=Math.pow(u[f*3+2],fr)),h&&(h[f*3+0]=ki(u[f*3+0]),h[f*3+1]=ki(u[f*3+1]),h[f*3+2]=ki(u[f*3+2])),o){let d=Math.max(u[f*3+0]*255,0),_=Math.max(u[f*3+1]*255,0),p=Math.max(u[f*3+2]*255,0);const m=Math.max(Math.max(d,_),p);if(m>255){const T=255/m;d*=T,_*=T,p*=T}o[f*3+0]=d,o[f*3+1]=_,o[f*3+2]=p}}h?a.push(h):o?a.push(o):a.push(u)}return a};if(e._features.allowTexturePrefiltering&&this._prefilterOnLoad){const r=this._onLoad,n=new km(e);this._onLoad=()=>{n.prefilter(this,r)}}this._texture=e.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,4,i,this._noMipmap,s,null,this._onLoad,this._onError)}clone(){const e=new Ms(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e}delayLoad(){this.delayLoadState===4&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this._loadTexture())}getReflectionTextureMatrix(){return this._textureMatrix}setReflectionTextureMatrix(e){var t;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&((t=this.getScene())===null||t===void 0||t.markAllMaterialsAsDirty(1,i=>i.getActiveTextures().indexOf(this)!==-1))}dispose(){this.onLoadObservable.clear(),super.dispose()}static Parse(e,t,i){let s=null;return e.name&&!e.isRenderTarget&&(s=new Ms(i+e.name,t,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace),s.name=e.name,s.hasAlpha=e.hasAlpha,s.level=e.level,s.coordinatesMode=e.coordinatesMode,s.isBlocking=e.isBlocking),s&&(e.boundingBoxPosition&&(s.boundingBoxPosition=E.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(s.boundingBoxSize=E.FromArray(e.boundingBoxSize)),e.rotationY&&(s.rotationY=e.rotationY)),s}serialize(){if(!this.name)return null;const e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e}}Ms._FacesMapping=["right","left","up","down","front","back"],Re("BABYLON.HDRCubeTexture",Ms);class Hr extends Ge{constructor(e,t,i,s=!1,r=!0,n=null,a=null,o=!1){if(super(t),this._onLoad=null,this._onError=null,!e)throw new Error("Image url is not set");this._coordinatesMode=O.CUBIC_MODE,this.name=e,this.url=e,this._size=i,this._supersample=o,this._noMipmap=s,this.gammaSpace=r,this._onLoad=n,this._onError=a,this.hasAlpha=!1,this.isCube=!0,this._texture=this._getFromCache(e,this._noMipmap,void 0,void 0,void 0,this.isCube),this._texture?n&&(this._texture.isReady?k.SetImmediate(()=>n()):this._texture.onLoadedObservable.add(n)):t.useDelayedTextureLoading?this.delayLoadState=4:this._loadImage(this._loadTexture.bind(this),this._onError)}_loadImage(e,t){const i=document.createElement("canvas");Ar(this.url,s=>{this._width=s.width,this._height=s.height,i.width=this._width,i.height=this._height;const r=i.getContext("2d");r.drawImage(s,0,0);const n=r.getImageData(0,0,s.width,s.height);this._buffer=n.data.buffer,i.remove(),e()},(s,r)=>{t&&t(`${this.getClassName()} could not be loaded`,r)},null)}_loadTexture(){const e=this.getScene(),t=()=>{const i=this._getFloat32ArrayFromArrayBuffer(this._buffer),s=_s.ConvertPanoramaToCubemap(i,this._width,this._height,this._size,this._supersample),r=[];for(let n=0;n<6;n++){const a=s[Hr._FacesMapping[n]];r.push(a)}return r};e&&(this._texture=e.getEngine().createRawCubeTextureFromUrl(this.url,e,this._size,4,e.getEngine().getCaps().textureFloat?1:7,this._noMipmap,t,null,this._onLoad,this._onError))}_getFloat32ArrayFromArrayBuffer(e){const t=new DataView(e),i=new Float32Array(e.byteLength*3/4);let s=0;for(let r=0;r<e.byteLength;r++)(r+1)%4!==0&&(i[s++]=t.getUint8(r)/255);return i}getClassName(){return"EquiRectangularCubeTexture"}clone(){const e=this.getScene();if(!e)return this;const t=new Hr(this.url,e,this._size,this._noMipmap,this.gammaSpace);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t}}Hr._FacesMapping=["right","left","up","down","front","back"];var Xi;(function(l){l[l.INIT=0]="INIT",l[l.RUNNING=1]="RUNNING",l[l.DONE=2]="DONE",l[l.ERROR=3]="ERROR"})(Xi||(Xi={}));class Yi{constructor(e){this.name=e,this._isCompleted=!1,this._taskState=Xi.INIT}get isCompleted(){return this._isCompleted}get taskState(){return this._taskState}get errorObject(){return this._errorObject}_setErrorObject(e,t){this._errorObject||(this._errorObject={message:e,exception:t})}run(e,t,i){this._taskState=Xi.RUNNING,this.runTask(e,()=>{this._onDoneCallback(t,i)},(s,r)=>{this._onErrorCallback(i,s,r)})}runTask(e,t,i){throw new Error("runTask is not implemented")}reset(){this._taskState=Xi.INIT}_onErrorCallback(e,t,i){this._taskState=Xi.ERROR,this._errorObject={message:t,exception:i},this.onError&&this.onError(this,t,i),e()}_onDoneCallback(e,t){try{this._taskState=Xi.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),e()}catch(i){this._onErrorCallback(t,"Task is done, error executing success callback(s)",i)}}}class Gm{constructor(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i}}class Hm extends Yi{constructor(e,t,i,s,r){super(e),this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=s,this.extension=r}runTask(e,t,i){Ce.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,s=>{this.loadedContainer=s,this.loadedMeshes=s.meshes,this.loadedTransformNodes=s.transformNodes,this.loadedParticleSystems=s.particleSystems,this.loadedSkeletons=s.skeletons,this.loadedAnimationGroups=s.animationGroups,t()},null,(s,r,n)=>{i(r,n)},this.extension)}}class Wm extends Yi{constructor(e,t,i,s,r){super(e),this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=s,this.extension=r}runTask(e,t,i){Ce.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,(s,r,n,a,o)=>{this.loadedMeshes=s,this.loadedTransformNodes=o,this.loadedParticleSystems=r,this.loadedSkeletons=n,this.loadedAnimationGroups=a,t()},null,(s,r,n)=>{i(r,n)},this.extension)}}class zm extends Yi{constructor(e,t){super(e),this.name=e,this.url=t}runTask(e,t,i){e._loadFile(this.url,s=>{this.text=s,t()},void 0,!1,!1,(s,r)=>{s&&i(s.status+" "+s.statusText,r)})}}class Xm extends Yi{constructor(e,t){super(e),this.name=e,this.url=t}runTask(e,t,i){e._loadFile(this.url,s=>{this.data=s,t()},void 0,!0,!0,(s,r)=>{s&&i(s.status+" "+s.statusText,r)})}}class Ym extends Yi{constructor(e,t){super(e),this.name=e,this.url=t}runTask(e,t,i){const s=new Image;k.SetCorsBehavior(this.url,s),s.onload=()=>{this.image=s,t()},s.onerror=r=>{i("Error loading image",r)},s.src=this.url}}class Km extends Yi{constructor(e,t,i,s=!0,r=O.TRILINEAR_SAMPLINGMODE){super(e),this.name=e,this.url=t,this.noMipmap=i,this.invertY=s,this.samplingMode=r}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new O(this.url,e,this.noMipmap,this.invertY,this.samplingMode,s,r)}}class jm extends Yi{constructor(e,t,i,s,r,n){super(e),this.name=e,this.url=t,this.extensions=i,this.noMipmap=s,this.files=r,this.prefiltered=n}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new It(this.url,e,this.extensions,this.noMipmap,this.files,s,r,void 0,this.prefiltered)}}class qm extends Yi{constructor(e,t,i,s=!1,r=!0,n=!1,a=!1){super(e),this.name=e,this.url=t,this.size=i,this.noMipmap=s,this.generateHarmonics=r,this.gammaSpace=n,this.reserved=a}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new Ms(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,s,r)}}class Zm extends Yi{constructor(e,t,i,s=!1,r=!0){super(e),this.name=e,this.url=t,this.size=i,this.noMipmap=s,this.gammaSpace=r}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new Hr(this.url,e,this.size,this.noMipmap,this.gammaSpace,s,r)}}class Qm{constructor(e){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new B,this.onTaskErrorObservable=new B,this.onTasksDoneObservable=new B,this.onProgressObservable=new B,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=e||Ee.LastCreatedScene}addContainerTask(e,t,i,s,r){const n=new Hm(e,t,i,s,r);return this._tasks.push(n),n}addMeshTask(e,t,i,s,r){const n=new Wm(e,t,i,s,r);return this._tasks.push(n),n}addTextFileTask(e,t){const i=new zm(e,t);return this._tasks.push(i),i}addBinaryFileTask(e,t){const i=new Xm(e,t);return this._tasks.push(i),i}addImageTask(e,t){const i=new Ym(e,t);return this._tasks.push(i),i}addTextureTask(e,t,i,s,r=O.TRILINEAR_SAMPLINGMODE){const n=new Km(e,t,i,s,r);return this._tasks.push(n),n}addCubeTextureTask(e,t,i,s,r,n){const a=new jm(e,t,i,s,r,n);return this._tasks.push(a),a}addHDRCubeTextureTask(e,t,i,s=!1,r=!0,n=!1,a=!1){const o=new qm(e,t,i,s,r,n,a);return this._tasks.push(o),o}addEquiRectangularCubeTextureAssetTask(e,t,i,s=!1,r=!0){const n=new Zm(e,t,i,s,r);return this._tasks.push(n),n}removeTask(e){const t=this._tasks.indexOf(e);t>-1&&this._tasks.splice(t,1)}_decreaseWaitingTasksCount(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new Gm(this._waitingTasksCount,this._totalTasksCount,e))}catch(t){F.Error("Error running progress callbacks."),console.log(t)}if(this._waitingTasksCount===0){try{const t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(const i of t)if(i.taskState===Xi.DONE){const s=this._tasks.indexOf(i);s>-1&&this._tasks.splice(s,1)}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(t){F.Error("Error running tasks-done callbacks."),console.log(t)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}}_runTask(e){const t=()=>{try{this.onTaskSuccess&&this.onTaskSuccess(e),this.onTaskSuccessObservable.notifyObservers(e),this._decreaseWaitingTasksCount(e)}catch(s){i("Error executing task success callbacks",s)}},i=(s,r)=>{e._setErrorObject(s,r),this.onTaskError?this.onTaskError(e):e.onError||F.Error(this._formatTaskErrorMessage(e)),this.onTaskErrorObservable.notifyObservers(e),this._decreaseWaitingTasksCount(e)};e.run(this._scene,t,i)}_formatTaskErrorMessage(e){let t="Unable to complete task "+e.name;return e.errorObject.message&&(t+=`: ${e.errorObject.message}`),e.errorObject.exception&&(t+=`: ${e.errorObject.exception}`),t}reset(){return this._isLoading=!1,this._tasks=new Array,this}load(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,this._waitingTasksCount===0)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(let e=0;e<this._tasks.length;e++){const t=this._tasks[e];t.taskState===Xi.INIT&&this._runTask(t)}return this}loadAsync(){return new Promise((e,t)=>{if(this._isLoading){e();return}this.onTasksDoneObservable.addOnce(i=>{i&&i.length?t(i):e()}),this.load()})}}const $m={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function Jm(l,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{eg(r,l,e,t,i)}),sg(l,e)}function eg(l,e,t,i,s){const r=$m[l];if(!r)throw new Error("Unexpected texture name encountered.");const n=e[r],a=n==null?void 0:n.fileLink;a?i.addTextureTask(l,a,!1,!1):s&&t[l]&&(t[l]&&t[l].dispose(),t[l]=null,tg(l,t))}function tg(l,e){l==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),l==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),l==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),l==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new z(0,0,0))}function ig(l,e,t,i){l==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),l==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),l==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[l]=i,l==="emissiveTexture"&&(e.emissiveColor=new z(1,1,1),e.emissiveIntensity=1)}function sg(l,e){l.clearCoat&&(l.clearCoat===Xr.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):l.clearCoat===Xr.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=l.clearCoatIOR||e.clearCoat.indexOfRefraction))}class rg{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,s){return new Promise(r=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const a=this.renameClonedAsset(e),o=this.scene.materials.filter(c=>c.name===a);if(o.length===0){r();return}const h=new Qm(this.scene);h.useDefaultLoadingScreen=!1,o.forEach(c=>Jm(t,c,h,s)),h.onProgress=(c,u,f)=>{i&&i(c/u*100,100,f.name)},h.onFinish=c=>{c.forEach(u=>{const f=u;i&&i(100,100,u.name),o.forEach(d=>ig(u.name,d,t,f.texture))}),r()},h.loadAsync()})}async applyModel(e,t,i,s){var o,h;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(o=this.loadedContainerForKey.get(e))==null||o.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((h=this.loadedContainerForKey.get(e))==null||h.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const n=(await Tl(i,this.scene,s)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,Cl(n));const a=[];return this.materialVariantMap.forEach(async(c,u)=>{a.push(this.applyMaterial(u,c))}),await Promise.all(a),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function Cl(l){const e=[];return l.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(s=>{const r=s.getMaterial(!1);r&&!e.includes(r)&&e.push(r)})})}),e}function bl(l,e=""){return l.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class ng{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new B,this.materialDeselectedObservable=new B,this.materialVariantObservable=new B,this.modelVariantObservable=new B,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:s,progressHandler:r,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Pm(),this.previewService=s,this.scene=n,this.variantManager=new rg(n,this.renameClonedAsset.bind(this),this.setEnabled.bind(this)),this.previewService.registerInitializedListener(async()=>await this.processQueuedEvents()),this.transformRoot=new pe("root",this.scene);const a=async()=>(this.assetContainer=await Tl(i.model,n,r),this.initialized=!0,this.instantiate(),this);this.importPromise=a()}async applyMaterialVariant(e,t,i,s){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,s))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,s))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(n,a,o)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:a,taskName:o})},s)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async a=>{await a()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const s=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,s);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let a=await s();return this.queuedModelChanges.has(e)&&(a=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();this.modelInstance&&Rl(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&Om([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?bl(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new E(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new E(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){this.transformRoot.scaling=new E(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new Pe(this.scene)),i.actionManager.registerAction(new Oa(Pe.OnPointerOverTrigger,s=>{s.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new Oa(Pe.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof j&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var r;const t=this.transformRoot.position,i=this.transformRoot.rotation,s=this.transformRoot.scaling;this.transformRoot.position=E.Zero(),this.transformRoot.rotation=E.Zero(),this.transformRoot.scaling=E.One(),e.rootNodes.forEach(n=>{n.parent=this.transformRoot}),this.transformRoot.position=t,this.transformRoot.rotation=i,this.transformRoot.scaling=s,this.canvasPanels=((r=this.contextService)==null?void 0:r.getAll())||new Map,ym(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof ne)).flat()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=Cl(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=bl(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const s=this.dynamicTextures.get(i);s&&t.getStaticContextDirty()&&s.isReady()&&(s.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0))}}class Da extends je{constructor(e,t,i,s,r,n,a,o){super(e,t,i,s,r,n,o),this.lastFocus=new E(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=La(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const s=()=>{e&&e()},r=La(this._scene),n=r.max.subtract(r.min),a=r.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=n.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,s),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const s=La(e),r=s.max.subtract(s.min),n=s.min.add(r.scale(.5)),a=new Da("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,n,e,t);return a.panningInertia=0,a.panningOriginTarget.copyFrom(n),a.panDenominator=r.length(),a.onAfterCheckInputsObservable.add(()=>{a.panningSensibility=1e3/a.panDenominator}),i&&(e.activeCamera=a),a}}function La(l){if(l.meshes.length===0)return{min:new E(-1,-1,-1),max:new E(1,1,1)};const e=l.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return l.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}const ag="sharpenPixelShader",og=`varying vec2 vUV;
7616
+ }`;U.ShadersStore[Vm]=km;class Gm{constructor(e,t={}){this._lodGenerationOffset=0,this._lodGenerationScale=.8,this.quality=4096,this.hdrScale=1,this._engine=e,this.hdrScale=t.hdrScale||this.hdrScale,this.quality=t.quality||this.quality}_createRenderTarget(e){let t=0;this._engine.getCaps().textureHalfFloatRender?t=2:this._engine.getCaps().textureFloatRender&&(t=1);const i=this._engine.createRenderTargetCubeTexture(e,{format:5,type:t,createMipMaps:!0,generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,samplingMode:1});return this._engine.updateTextureWrappingMode(i.texture,0,0,0),this._engine.updateTextureSamplingMode(3,i.texture,!0),i}_prefilterInternal(e){const t=e.getSize().width,i=$.ILog2(t)+1,s=this._effectWrapper.effect,r=this._createRenderTarget(t);this._effectRenderer.setViewport();const n=e.getInternalTexture();n&&this._engine.updateTextureSamplingMode(3,n,!0),this._effectRenderer.applyEffectWrapper(this._effectWrapper);const a=[[new E(0,0,-1),new E(0,-1,0),new E(1,0,0)],[new E(0,0,1),new E(0,-1,0),new E(-1,0,0)],[new E(1,0,0),new E(0,0,1),new E(0,1,0)],[new E(1,0,0),new E(0,0,-1),new E(0,-1,0)],[new E(1,0,0),new E(0,-1,0),new E(0,0,1)],[new E(-1,0,0),new E(0,-1,0),new E(0,0,-1)]];s.setFloat("hdrScale",this.hdrScale),s.setFloat2("vFilteringInfo",e.getSize().width,i),s.setTexture("inputTexture",e);for(let c=0;c<6;c++){s.setVector3("up",a[c][0]),s.setVector3("right",a[c][1]),s.setVector3("front",a[c][2]);for(let u=0;u<i;u++){this._engine.bindFramebuffer(r,c,void 0,void 0,!0,u),this._effectRenderer.applyEffectWrapper(this._effectWrapper);let f=Math.pow(2,(u-this._lodGenerationOffset)/this._lodGenerationScale)/t;u===0&&(f=0),s.setFloat("alphaG",f),this._effectRenderer.draw()}}this._effectRenderer.restoreStates(),this._engine.restoreDefaultFramebuffer(),this._engine._releaseTexture(e._texture);const o=r.texture.type,h=r.texture.format;return r._swapAndDie(e._texture),e._texture.type=o,e._texture.format=h,e.gammaSpace=!1,e.lodGenerationOffset=this._lodGenerationOffset,e.lodGenerationScale=this._lodGenerationScale,e._prefiltered=!0,e}_createEffect(e,t){const i=[];return e.gammaSpace&&i.push("#define GAMMA_INPUT"),i.push("#define NUM_SAMPLES "+this.quality+"u"),new No({engine:this._engine,name:"hdrFiltering",vertexShader:"hdrFiltering",fragmentShader:"hdrFiltering",samplerNames:["inputTexture"],uniformNames:["vSampleDirections","vWeights","up","right","front","vFilteringInfo","hdrScale","alphaG"],useShaderStore:!0,defines:i,onCompiled:t})}isReady(e){return e.isReady()&&this._effectWrapper.effect.isReady()}prefilter(e,t=null){return this._engine._features.allowTexturePrefiltering?new Promise(i=>{this._effectRenderer=new Lo(this._engine),this._effectWrapper=this._createEffect(e),this._effectWrapper.effect.executeWhenCompiled(()=>{this._prefilterInternal(e),this._effectRenderer.dispose(),this._effectWrapper.dispose(),i(),t&&t()})}):(F.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."),Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."))}}class Ms extends Ge{set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}set rotationY(e){this._rotationY=e,this.setReflectionTextureMatrix(M.RotationY(this._rotationY))}get rotationY(){return this._rotationY}set boundingBoxSize(e){if(this._boundingBoxSize&&this._boundingBoxSize.equals(e))return;this._boundingBoxSize=e;const t=this.getScene();t&&t.markAllMaterialsAsDirty(1)}get boundingBoxSize(){return this._boundingBoxSize}constructor(e,t,i,s=!1,r=!0,n=!1,a=!1,o=null,h=null,c=!1){var u;super(t),this._generateHarmonics=!0,this._onError=null,this._isBlocking=!0,this._rotationY=0,this.boundingBoxPosition=E.Zero(),this.onLoadObservable=new B,e&&(this._coordinatesMode=O.CUBIC_MODE,this.name=e,this.url=e,this.hasAlpha=!1,this.isCube=!0,this._textureMatrix=M.Identity(),this._prefilterOnLoad=a,this._onLoad=()=>{this.onLoadObservable.notifyObservers(this),o&&o()},this._onError=h,this.gammaSpace=n,this._noMipmap=s,this._size=i,this._supersample=c,this._generateHarmonics=r,this._texture=this._getFromCache(e,this._noMipmap,void 0,void 0,void 0,this.isCube),this._texture?this._texture.isReady?k.SetImmediate(()=>this._onLoad()):this._texture.onLoadedObservable.add(this._onLoad):!((u=this.getScene())===null||u===void 0)&&u.useDelayedTextureLoading?this.delayLoadState=4:this._loadTexture())}getClassName(){return"HDRCubeTexture"}_loadTexture(){const e=this._getEngine(),t=e.getCaps();let i=0;t.textureFloat&&t.textureFloatLinearFiltering?i=1:t.textureHalfFloat&&t.textureHalfFloatLinearFiltering&&(i=2);const s=r=>{this.lodGenerationOffset=0,this.lodGenerationScale=.8;const n=wm.GetCubeMapTextureData(r,this._size,this._supersample);if(this._generateHarmonics){const c=Js.ConvertCubeMapToSphericalPolynomial(n);this.sphericalPolynomial=c}const a=[];let o=null,h=null;for(let c=0;c<6;c++){i===2?h=new Uint16Array(this._size*this._size*3):i===0&&(o=new Uint8Array(this._size*this._size*3));const u=n[Ms._FacesMapping[c]];if(this.gammaSpace||h||o){for(let f=0;f<this._size*this._size;f++)if(this.gammaSpace&&(u[f*3+0]=Math.pow(u[f*3+0],fr),u[f*3+1]=Math.pow(u[f*3+1],fr),u[f*3+2]=Math.pow(u[f*3+2],fr)),h&&(h[f*3+0]=ki(u[f*3+0]),h[f*3+1]=ki(u[f*3+1]),h[f*3+2]=ki(u[f*3+2])),o){let d=Math.max(u[f*3+0]*255,0),_=Math.max(u[f*3+1]*255,0),p=Math.max(u[f*3+2]*255,0);const m=Math.max(Math.max(d,_),p);if(m>255){const T=255/m;d*=T,_*=T,p*=T}o[f*3+0]=d,o[f*3+1]=_,o[f*3+2]=p}}h?a.push(h):o?a.push(o):a.push(u)}return a};if(e._features.allowTexturePrefiltering&&this._prefilterOnLoad){const r=this._onLoad,n=new Gm(e);this._onLoad=()=>{n.prefilter(this,r)}}this._texture=e.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,4,i,this._noMipmap,s,null,this._onLoad,this._onError)}clone(){const e=new Ms(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e}delayLoad(){this.delayLoadState===4&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this._loadTexture())}getReflectionTextureMatrix(){return this._textureMatrix}setReflectionTextureMatrix(e){var t;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&((t=this.getScene())===null||t===void 0||t.markAllMaterialsAsDirty(1,i=>i.getActiveTextures().indexOf(this)!==-1))}dispose(){this.onLoadObservable.clear(),super.dispose()}static Parse(e,t,i){let s=null;return e.name&&!e.isRenderTarget&&(s=new Ms(i+e.name,t,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace),s.name=e.name,s.hasAlpha=e.hasAlpha,s.level=e.level,s.coordinatesMode=e.coordinatesMode,s.isBlocking=e.isBlocking),s&&(e.boundingBoxPosition&&(s.boundingBoxPosition=E.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(s.boundingBoxSize=E.FromArray(e.boundingBoxSize)),e.rotationY&&(s.rotationY=e.rotationY)),s}serialize(){if(!this.name)return null;const e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e}}Ms._FacesMapping=["right","left","up","down","front","back"],Re("BABYLON.HDRCubeTexture",Ms);class Hr extends Ge{constructor(e,t,i,s=!1,r=!0,n=null,a=null,o=!1){if(super(t),this._onLoad=null,this._onError=null,!e)throw new Error("Image url is not set");this._coordinatesMode=O.CUBIC_MODE,this.name=e,this.url=e,this._size=i,this._supersample=o,this._noMipmap=s,this.gammaSpace=r,this._onLoad=n,this._onError=a,this.hasAlpha=!1,this.isCube=!0,this._texture=this._getFromCache(e,this._noMipmap,void 0,void 0,void 0,this.isCube),this._texture?n&&(this._texture.isReady?k.SetImmediate(()=>n()):this._texture.onLoadedObservable.add(n)):t.useDelayedTextureLoading?this.delayLoadState=4:this._loadImage(this._loadTexture.bind(this),this._onError)}_loadImage(e,t){const i=document.createElement("canvas");Ar(this.url,s=>{this._width=s.width,this._height=s.height,i.width=this._width,i.height=this._height;const r=i.getContext("2d");r.drawImage(s,0,0);const n=r.getImageData(0,0,s.width,s.height);this._buffer=n.data.buffer,i.remove(),e()},(s,r)=>{t&&t(`${this.getClassName()} could not be loaded`,r)},null)}_loadTexture(){const e=this.getScene(),t=()=>{const i=this._getFloat32ArrayFromArrayBuffer(this._buffer),s=_s.ConvertPanoramaToCubemap(i,this._width,this._height,this._size,this._supersample),r=[];for(let n=0;n<6;n++){const a=s[Hr._FacesMapping[n]];r.push(a)}return r};e&&(this._texture=e.getEngine().createRawCubeTextureFromUrl(this.url,e,this._size,4,e.getEngine().getCaps().textureFloat?1:7,this._noMipmap,t,null,this._onLoad,this._onError))}_getFloat32ArrayFromArrayBuffer(e){const t=new DataView(e),i=new Float32Array(e.byteLength*3/4);let s=0;for(let r=0;r<e.byteLength;r++)(r+1)%4!==0&&(i[s++]=t.getUint8(r)/255);return i}getClassName(){return"EquiRectangularCubeTexture"}clone(){const e=this.getScene();if(!e)return this;const t=new Hr(this.url,e,this._size,this._noMipmap,this.gammaSpace);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t}}Hr._FacesMapping=["right","left","up","down","front","back"];var Xi;(function(l){l[l.INIT=0]="INIT",l[l.RUNNING=1]="RUNNING",l[l.DONE=2]="DONE",l[l.ERROR=3]="ERROR"})(Xi||(Xi={}));class Yi{constructor(e){this.name=e,this._isCompleted=!1,this._taskState=Xi.INIT}get isCompleted(){return this._isCompleted}get taskState(){return this._taskState}get errorObject(){return this._errorObject}_setErrorObject(e,t){this._errorObject||(this._errorObject={message:e,exception:t})}run(e,t,i){this._taskState=Xi.RUNNING,this.runTask(e,()=>{this._onDoneCallback(t,i)},(s,r)=>{this._onErrorCallback(i,s,r)})}runTask(e,t,i){throw new Error("runTask is not implemented")}reset(){this._taskState=Xi.INIT}_onErrorCallback(e,t,i){this._taskState=Xi.ERROR,this._errorObject={message:t,exception:i},this.onError&&this.onError(this,t,i),e()}_onDoneCallback(e,t){try{this._taskState=Xi.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),e()}catch(i){this._onErrorCallback(t,"Task is done, error executing success callback(s)",i)}}}class Hm{constructor(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i}}class Wm extends Yi{constructor(e,t,i,s,r){super(e),this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=s,this.extension=r}runTask(e,t,i){Ce.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,s=>{this.loadedContainer=s,this.loadedMeshes=s.meshes,this.loadedTransformNodes=s.transformNodes,this.loadedParticleSystems=s.particleSystems,this.loadedSkeletons=s.skeletons,this.loadedAnimationGroups=s.animationGroups,t()},null,(s,r,n)=>{i(r,n)},this.extension)}}class zm extends Yi{constructor(e,t,i,s,r){super(e),this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=s,this.extension=r}runTask(e,t,i){Ce.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,(s,r,n,a,o)=>{this.loadedMeshes=s,this.loadedTransformNodes=o,this.loadedParticleSystems=r,this.loadedSkeletons=n,this.loadedAnimationGroups=a,t()},null,(s,r,n)=>{i(r,n)},this.extension)}}class Xm extends Yi{constructor(e,t){super(e),this.name=e,this.url=t}runTask(e,t,i){e._loadFile(this.url,s=>{this.text=s,t()},void 0,!1,!1,(s,r)=>{s&&i(s.status+" "+s.statusText,r)})}}class Ym extends Yi{constructor(e,t){super(e),this.name=e,this.url=t}runTask(e,t,i){e._loadFile(this.url,s=>{this.data=s,t()},void 0,!0,!0,(s,r)=>{s&&i(s.status+" "+s.statusText,r)})}}class Km extends Yi{constructor(e,t){super(e),this.name=e,this.url=t}runTask(e,t,i){const s=new Image;k.SetCorsBehavior(this.url,s),s.onload=()=>{this.image=s,t()},s.onerror=r=>{i("Error loading image",r)},s.src=this.url}}class jm extends Yi{constructor(e,t,i,s=!0,r=O.TRILINEAR_SAMPLINGMODE){super(e),this.name=e,this.url=t,this.noMipmap=i,this.invertY=s,this.samplingMode=r}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new O(this.url,e,this.noMipmap,this.invertY,this.samplingMode,s,r)}}class qm extends Yi{constructor(e,t,i,s,r,n){super(e),this.name=e,this.url=t,this.extensions=i,this.noMipmap=s,this.files=r,this.prefiltered=n}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new It(this.url,e,this.extensions,this.noMipmap,this.files,s,r,void 0,this.prefiltered)}}class Zm extends Yi{constructor(e,t,i,s=!1,r=!0,n=!1,a=!1){super(e),this.name=e,this.url=t,this.size=i,this.noMipmap=s,this.generateHarmonics=r,this.gammaSpace=n,this.reserved=a}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new Ms(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,s,r)}}class Qm extends Yi{constructor(e,t,i,s=!1,r=!0){super(e),this.name=e,this.url=t,this.size=i,this.noMipmap=s,this.gammaSpace=r}runTask(e,t,i){const s=()=>{t()},r=(n,a)=>{i(n,a)};this.texture=new Hr(this.url,e,this.size,this.noMipmap,this.gammaSpace,s,r)}}class $m{constructor(e){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new B,this.onTaskErrorObservable=new B,this.onTasksDoneObservable=new B,this.onProgressObservable=new B,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=e||Ee.LastCreatedScene}addContainerTask(e,t,i,s,r){const n=new Wm(e,t,i,s,r);return this._tasks.push(n),n}addMeshTask(e,t,i,s,r){const n=new zm(e,t,i,s,r);return this._tasks.push(n),n}addTextFileTask(e,t){const i=new Xm(e,t);return this._tasks.push(i),i}addBinaryFileTask(e,t){const i=new Ym(e,t);return this._tasks.push(i),i}addImageTask(e,t){const i=new Km(e,t);return this._tasks.push(i),i}addTextureTask(e,t,i,s,r=O.TRILINEAR_SAMPLINGMODE){const n=new jm(e,t,i,s,r);return this._tasks.push(n),n}addCubeTextureTask(e,t,i,s,r,n){const a=new qm(e,t,i,s,r,n);return this._tasks.push(a),a}addHDRCubeTextureTask(e,t,i,s=!1,r=!0,n=!1,a=!1){const o=new Zm(e,t,i,s,r,n,a);return this._tasks.push(o),o}addEquiRectangularCubeTextureAssetTask(e,t,i,s=!1,r=!0){const n=new Qm(e,t,i,s,r);return this._tasks.push(n),n}removeTask(e){const t=this._tasks.indexOf(e);t>-1&&this._tasks.splice(t,1)}_decreaseWaitingTasksCount(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new Hm(this._waitingTasksCount,this._totalTasksCount,e))}catch(t){F.Error("Error running progress callbacks."),console.log(t)}if(this._waitingTasksCount===0){try{const t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(const i of t)if(i.taskState===Xi.DONE){const s=this._tasks.indexOf(i);s>-1&&this._tasks.splice(s,1)}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(t){F.Error("Error running tasks-done callbacks."),console.log(t)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}}_runTask(e){const t=()=>{try{this.onTaskSuccess&&this.onTaskSuccess(e),this.onTaskSuccessObservable.notifyObservers(e),this._decreaseWaitingTasksCount(e)}catch(s){i("Error executing task success callbacks",s)}},i=(s,r)=>{e._setErrorObject(s,r),this.onTaskError?this.onTaskError(e):e.onError||F.Error(this._formatTaskErrorMessage(e)),this.onTaskErrorObservable.notifyObservers(e),this._decreaseWaitingTasksCount(e)};e.run(this._scene,t,i)}_formatTaskErrorMessage(e){let t="Unable to complete task "+e.name;return e.errorObject.message&&(t+=`: ${e.errorObject.message}`),e.errorObject.exception&&(t+=`: ${e.errorObject.exception}`),t}reset(){return this._isLoading=!1,this._tasks=new Array,this}load(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,this._waitingTasksCount===0)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(let e=0;e<this._tasks.length;e++){const t=this._tasks[e];t.taskState===Xi.INIT&&this._runTask(t)}return this}loadAsync(){return new Promise((e,t)=>{if(this._isLoading){e();return}this.onTasksDoneObservable.addOnce(i=>{i&&i.length?t(i):e()}),this.load()})}}const Jm={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function eg(l,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{tg(r,l,e,t,i)}),rg(l,e)}function tg(l,e,t,i,s){const r=Jm[l];if(!r)throw new Error("Unexpected texture name encountered.");const n=e[r],a=n==null?void 0:n.fileLink;a?i.addTextureTask(l,a,!1,!1):s&&t[l]&&(t[l]&&t[l].dispose(),t[l]=null,ig(l,t))}function ig(l,e){l==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),l==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),l==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),l==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new z(0,0,0))}function sg(l,e,t,i){l==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),l==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),l==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[l]=i,l==="emissiveTexture"&&(e.emissiveColor=new z(1,1,1),e.emissiveIntensity=1)}function rg(l,e){l.clearCoat&&(l.clearCoat===Xr.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):l.clearCoat===Xr.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=l.clearCoatIOR||e.clearCoat.indexOfRefraction))}class ng{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,s){return new Promise(r=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const a=this.renameClonedAsset(e),o=this.scene.materials.filter(c=>c.name===a);if(o.length===0){r();return}const h=new $m(this.scene);h.useDefaultLoadingScreen=!1,o.forEach(c=>eg(t,c,h,s)),h.onProgress=(c,u,f)=>{i&&i(c/u*100,100,f.name)},h.onFinish=c=>{c.forEach(u=>{const f=u;i&&i(100,100,u.name),o.forEach(d=>sg(u.name,d,t,f.texture))}),r()},h.loadAsync()})}async applyModel(e,t,i,s){var o,h;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(o=this.loadedContainerForKey.get(e))==null||o.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((h=this.loadedContainerForKey.get(e))==null||h.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const n=(await Tl(i,this.scene,s)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,Cl(n));const a=[];return this.materialVariantMap.forEach(async(c,u)=>{a.push(this.applyMaterial(u,c))}),await Promise.all(a),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function Cl(l){const e=[];return l.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(s=>{const r=s.getMaterial(!1);r&&!e.includes(r)&&e.push(r)})})}),e}function bl(l,e=""){return l.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class ag{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new B,this.materialDeselectedObservable=new B,this.materialVariantObservable=new B,this.modelVariantObservable=new B,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:s,progressHandler:r,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Om(),this.previewService=s,this.scene=n,this.variantManager=new ng(n,this.renameClonedAsset.bind(this),this.setEnabled.bind(this)),this.previewService.registerInitializedListener(async()=>await this.processQueuedEvents()),this.transformRoot=new pe("root",this.scene);const a=async()=>(this.assetContainer=await Tl(i.model,n,r),this.initialized=!0,this.instantiate(),this);this.importPromise=a()}async applyMaterialVariant(e,t,i,s){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,s))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,s))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(n,a,o)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:a,taskName:o})},s)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async a=>{await a()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const s=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,s);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let a=await s();return this.queuedModelChanges.has(e)&&(a=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();this.modelInstance&&Rl(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&Dm([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?bl(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new E(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new E(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){this.transformRoot.scaling=new E(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new Pe(this.scene)),i.actionManager.registerAction(new Oa(Pe.OnPointerOverTrigger,s=>{s.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new Oa(Pe.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof j&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var r;const t=this.transformRoot.position,i=this.transformRoot.rotation,s=this.transformRoot.scaling;this.transformRoot.position=E.Zero(),this.transformRoot.rotation=E.Zero(),this.transformRoot.scaling=E.One(),e.rootNodes.forEach(n=>{n.parent=this.transformRoot}),this.transformRoot.position=t,this.transformRoot.rotation=i,this.transformRoot.scaling=s,this.canvasPanels=((r=this.contextService)==null?void 0:r.getAll())||new Map,Mm(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof ne)).flat()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=Cl(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=bl(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const s=this.dynamicTextures.get(i);s&&t.getStaticContextDirty()&&s.isReady()&&(s.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0))}}class Da extends je{constructor(e,t,i,s,r,n,a,o){super(e,t,i,s,r,n,o),this.lastFocus=new E(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=La(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const s=()=>{e&&e()},r=La(this._scene),n=r.max.subtract(r.min),a=r.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=n.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,s),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const s=La(e),r=s.max.subtract(s.min),n=s.min.add(r.scale(.5)),a=new Da("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,n,e,t);return a.panningInertia=0,a.panningOriginTarget.copyFrom(n),a.panDenominator=r.length(),a.onAfterCheckInputsObservable.add(()=>{a.panningSensibility=1e3/a.panDenominator}),i&&(e.activeCamera=a),a}}function La(l){if(l.meshes.length===0)return{min:new E(-1,-1,-1),max:new E(1,1,1)};const e=l.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return l.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}const og="sharpenPixelShader",lg=`varying vec2 vUV;
7617
7617
  uniform sampler2D textureSampler;
7618
7618
  uniform vec2 screenSize;
7619
7619
  uniform vec2 sharpnessAmounts;
@@ -7628,7 +7628,7 @@ texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
7628
7628
  texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
7629
7629
  color*4.0;
7630
7630
  gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);
7631
- }`;U.ShadersStore[ag]=og;class nr extends ue{getClassName(){return"SharpenPostProcess"}constructor(e,t,i,s,r,n,a=0,o=!1){super(e,"sharpen",["sharpnessAmounts","screenSize"],null,t,i,s,r,n,null,a,void 0,null,o),this.colorAmount=1,this.edgeAmount=.3,this.onApply=h=>{h.setFloat2("screenSize",this.width,this.height),h.setFloat2("sharpnessAmounts",this.edgeAmount,this.colorAmount)}}static _Parse(e,t,i,s){return J.Parse(()=>new nr(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable),e,i,s)}}g([v()],nr.prototype,"colorAmount",void 0),g([v()],nr.prototype,"edgeAmount",void 0),Re("BABYLON.SharpenPostProcess",nr);const lg="imageProcessingPixelShader",hg=`varying vec2 vUV;
7631
+ }`;U.ShadersStore[og]=lg;class nr extends ue{getClassName(){return"SharpenPostProcess"}constructor(e,t,i,s,r,n,a=0,o=!1){super(e,"sharpen",["sharpnessAmounts","screenSize"],null,t,i,s,r,n,null,a,void 0,null,o),this.colorAmount=1,this.edgeAmount=.3,this.onApply=h=>{h.setFloat2("screenSize",this.width,this.height),h.setFloat2("sharpnessAmounts",this.edgeAmount,this.colorAmount)}}static _Parse(e,t,i,s){return J.Parse(()=>new nr(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable),e,i,s)}}g([v()],nr.prototype,"colorAmount",void 0),g([v()],nr.prototype,"edgeAmount",void 0),Re("BABYLON.SharpenPostProcess",nr);const hg="imageProcessingPixelShader",cg=`varying vec2 vUV;
7632
7632
  uniform sampler2D textureSampler;
7633
7633
  #include<imageProcessingDeclaration>
7634
7634
  #include<helperFunctions>
@@ -7648,8 +7648,8 @@ result=applyImageProcessing(result);
7648
7648
  #endif
7649
7649
  #endif
7650
7650
  gl_FragColor=result;
7651
- }`;U.ShadersStore[lg]=hg;class Il extends ue{get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)}_attachImageProcessingConfiguration(e,t=!1){if(e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{let i=null;const s=this.getEngine(),r=this.getCamera();if(r)i=r.getScene();else if(s&&s.scenes){const n=s.scenes;i=n[n.length-1]}else i=Ee.LastCreatedScene;i?this._imageProcessingConfiguration=i.imageProcessingConfiguration:this._imageProcessingConfiguration=new Se}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._updateParameters()})),t||this._updateParameters()}}get isSupported(){const e=this.getEffect();return!e||e.isSupported}get colorCurves(){return this.imageProcessingConfiguration.colorCurves}set colorCurves(e){this.imageProcessingConfiguration.colorCurves=e}get colorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set colorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get colorGradingTexture(){return this.imageProcessingConfiguration.colorGradingTexture}set colorGradingTexture(e){this.imageProcessingConfiguration.colorGradingTexture=e}get colorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set colorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get exposure(){return this.imageProcessingConfiguration.exposure}set exposure(e){this.imageProcessingConfiguration.exposure=e}get toneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set toneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get toneMappingType(){return this._imageProcessingConfiguration.toneMappingType}set toneMappingType(e){this._imageProcessingConfiguration.toneMappingType=e}get contrast(){return this.imageProcessingConfiguration.contrast}set contrast(e){this.imageProcessingConfiguration.contrast=e}get vignetteStretch(){return this.imageProcessingConfiguration.vignetteStretch}set vignetteStretch(e){this.imageProcessingConfiguration.vignetteStretch=e}get vignetteCentreX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCentreX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteCentreY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCentreY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCenterY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCenterX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteWeight(){return this.imageProcessingConfiguration.vignetteWeight}set vignetteWeight(e){this.imageProcessingConfiguration.vignetteWeight=e}get vignetteColor(){return this.imageProcessingConfiguration.vignetteColor}set vignetteColor(e){this.imageProcessingConfiguration.vignetteColor=e}get vignetteCameraFov(){return this.imageProcessingConfiguration.vignetteCameraFov}set vignetteCameraFov(e){this.imageProcessingConfiguration.vignetteCameraFov=e}get vignetteBlendMode(){return this.imageProcessingConfiguration.vignetteBlendMode}set vignetteBlendMode(e){this.imageProcessingConfiguration.vignetteBlendMode=e}get vignetteEnabled(){return this.imageProcessingConfiguration.vignetteEnabled}set vignetteEnabled(e){this.imageProcessingConfiguration.vignetteEnabled=e}get ditheringIntensity(){return this.imageProcessingConfiguration.ditheringIntensity}set ditheringIntensity(e){this.imageProcessingConfiguration.ditheringIntensity=e}get ditheringEnabled(){return this.imageProcessingConfiguration.ditheringEnabled}set ditheringEnabled(e){this.imageProcessingConfiguration.ditheringEnabled=e}get fromLinearSpace(){return this._fromLinearSpace}set fromLinearSpace(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())}constructor(e,t,i=null,s,r,n,a=0,o){super(e,"imageProcessing",[],[],t,i,s,r,n,null,a,"postprocess",null,!0),this._fromLinearSpace=!0,this._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},o?(o.applyByPostProcess=!0,this._attachImageProcessingConfiguration(o,!0),this._updateParameters()):(this._attachImageProcessingConfiguration(null,!0),this.imageProcessingConfiguration.applyByPostProcess=!0),this.onApply=h=>{this.imageProcessingConfiguration.bind(h,this.aspectRatio)}}getClassName(){return"ImageProcessingPostProcess"}_updateParameters(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);let e="";for(const s in this._defines)this._defines[s]&&(e+=`#define ${s};\r
7652
- `);const t=["textureSampler"],i=["scale"];Se&&(Se.PrepareSamplers(t,this._defines),Se.PrepareUniforms(i,this._defines)),this.updateEffect(e,i,t)}dispose(e){super.dispose(e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)}}g([v()],Il.prototype,"_fromLinearSpace",void 0);const cg="chromaticAberrationPixelShader",ug=`uniform sampler2D textureSampler;
7651
+ }`;U.ShadersStore[hg]=cg;class Il extends ue{get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)}_attachImageProcessingConfiguration(e,t=!1){if(e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{let i=null;const s=this.getEngine(),r=this.getCamera();if(r)i=r.getScene();else if(s&&s.scenes){const n=s.scenes;i=n[n.length-1]}else i=Ee.LastCreatedScene;i?this._imageProcessingConfiguration=i.imageProcessingConfiguration:this._imageProcessingConfiguration=new Se}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._updateParameters()})),t||this._updateParameters()}}get isSupported(){const e=this.getEffect();return!e||e.isSupported}get colorCurves(){return this.imageProcessingConfiguration.colorCurves}set colorCurves(e){this.imageProcessingConfiguration.colorCurves=e}get colorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set colorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get colorGradingTexture(){return this.imageProcessingConfiguration.colorGradingTexture}set colorGradingTexture(e){this.imageProcessingConfiguration.colorGradingTexture=e}get colorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set colorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get exposure(){return this.imageProcessingConfiguration.exposure}set exposure(e){this.imageProcessingConfiguration.exposure=e}get toneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set toneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get toneMappingType(){return this._imageProcessingConfiguration.toneMappingType}set toneMappingType(e){this._imageProcessingConfiguration.toneMappingType=e}get contrast(){return this.imageProcessingConfiguration.contrast}set contrast(e){this.imageProcessingConfiguration.contrast=e}get vignetteStretch(){return this.imageProcessingConfiguration.vignetteStretch}set vignetteStretch(e){this.imageProcessingConfiguration.vignetteStretch=e}get vignetteCentreX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCentreX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteCentreY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCentreY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCenterY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCenterX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteWeight(){return this.imageProcessingConfiguration.vignetteWeight}set vignetteWeight(e){this.imageProcessingConfiguration.vignetteWeight=e}get vignetteColor(){return this.imageProcessingConfiguration.vignetteColor}set vignetteColor(e){this.imageProcessingConfiguration.vignetteColor=e}get vignetteCameraFov(){return this.imageProcessingConfiguration.vignetteCameraFov}set vignetteCameraFov(e){this.imageProcessingConfiguration.vignetteCameraFov=e}get vignetteBlendMode(){return this.imageProcessingConfiguration.vignetteBlendMode}set vignetteBlendMode(e){this.imageProcessingConfiguration.vignetteBlendMode=e}get vignetteEnabled(){return this.imageProcessingConfiguration.vignetteEnabled}set vignetteEnabled(e){this.imageProcessingConfiguration.vignetteEnabled=e}get ditheringIntensity(){return this.imageProcessingConfiguration.ditheringIntensity}set ditheringIntensity(e){this.imageProcessingConfiguration.ditheringIntensity=e}get ditheringEnabled(){return this.imageProcessingConfiguration.ditheringEnabled}set ditheringEnabled(e){this.imageProcessingConfiguration.ditheringEnabled=e}get fromLinearSpace(){return this._fromLinearSpace}set fromLinearSpace(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())}constructor(e,t,i=null,s,r,n,a=0,o){super(e,"imageProcessing",[],[],t,i,s,r,n,null,a,"postprocess",null,!0),this._fromLinearSpace=!0,this._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},o?(o.applyByPostProcess=!0,this._attachImageProcessingConfiguration(o,!0),this._updateParameters()):(this._attachImageProcessingConfiguration(null,!0),this.imageProcessingConfiguration.applyByPostProcess=!0),this.onApply=h=>{this.imageProcessingConfiguration.bind(h,this.aspectRatio)}}getClassName(){return"ImageProcessingPostProcess"}_updateParameters(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);let e="";for(const s in this._defines)this._defines[s]&&(e+=`#define ${s};\r
7652
+ `);const t=["textureSampler"],i=["scale"];Se&&(Se.PrepareSamplers(t,this._defines),Se.PrepareUniforms(i,this._defines)),this.updateEffect(e,i,t)}dispose(e){super.dispose(e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)}}g([v()],Il.prototype,"_fromLinearSpace",void 0);const ug="chromaticAberrationPixelShader",fg=`uniform sampler2D textureSampler;
7653
7653
  uniform float chromatic_aberration;
7654
7654
  uniform float radialIntensity;
7655
7655
  uniform vec2 direction;
@@ -7680,7 +7680,7 @@ original.g=texture2D(textureSampler,ref_coords_g).g;
7680
7680
  original.b=texture2D(textureSampler,ref_coords_b).b;
7681
7681
  original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);
7682
7682
  gl_FragColor=original;
7683
- }`;U.ShadersStore[cg]=ug;class Pi extends ue{getClassName(){return"ChromaticAberrationPostProcess"}constructor(e,t,i,s,r,n,a,o,h=0,c=!1){super(e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],s,r,n,a,o,null,h,void 0,null,c),this.aberrationAmount=30,this.radialIntensity=0,this.direction=new ae(.707,.707),this.centerPosition=new ae(.5,.5),this.screenWidth=t,this.screenHeight=i,this.onApplyObservable.add(u=>{u.setFloat("chromatic_aberration",this.aberrationAmount),u.setFloat("screen_width",t),u.setFloat("screen_height",i),u.setFloat("radialIntensity",this.radialIntensity),u.setFloat2("direction",this.direction.x,this.direction.y),u.setFloat2("centerPosition",this.centerPosition.x,this.centerPosition.y)})}static _Parse(e,t,i,s){return J.Parse(()=>new Pi(e.name,e.screenWidth,e.screenHeight,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1),e,i,s)}}g([v()],Pi.prototype,"aberrationAmount",void 0),g([v()],Pi.prototype,"radialIntensity",void 0),g([v()],Pi.prototype,"direction",void 0),g([v()],Pi.prototype,"centerPosition",void 0),g([v()],Pi.prototype,"screenWidth",void 0),g([v()],Pi.prototype,"screenHeight",void 0),Re("BABYLON.ChromaticAberrationPostProcess",Pi);const fg="grainPixelShader",dg=`#include<helperFunctions>
7683
+ }`;U.ShadersStore[ug]=fg;class Pi extends ue{getClassName(){return"ChromaticAberrationPostProcess"}constructor(e,t,i,s,r,n,a,o,h=0,c=!1){super(e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],s,r,n,a,o,null,h,void 0,null,c),this.aberrationAmount=30,this.radialIntensity=0,this.direction=new ae(.707,.707),this.centerPosition=new ae(.5,.5),this.screenWidth=t,this.screenHeight=i,this.onApplyObservable.add(u=>{u.setFloat("chromatic_aberration",this.aberrationAmount),u.setFloat("screen_width",t),u.setFloat("screen_height",i),u.setFloat("radialIntensity",this.radialIntensity),u.setFloat2("direction",this.direction.x,this.direction.y),u.setFloat2("centerPosition",this.centerPosition.x,this.centerPosition.y)})}static _Parse(e,t,i,s){return J.Parse(()=>new Pi(e.name,e.screenWidth,e.screenHeight,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1),e,i,s)}}g([v()],Pi.prototype,"aberrationAmount",void 0),g([v()],Pi.prototype,"radialIntensity",void 0),g([v()],Pi.prototype,"direction",void 0),g([v()],Pi.prototype,"centerPosition",void 0),g([v()],Pi.prototype,"screenWidth",void 0),g([v()],Pi.prototype,"screenHeight",void 0),Re("BABYLON.ChromaticAberrationPostProcess",Pi);const dg="grainPixelShader",_g=`#include<helperFunctions>
7684
7684
  uniform sampler2D textureSampler;
7685
7685
  uniform float intensity;
7686
7686
  uniform float animatedSeed;
@@ -7695,7 +7695,7 @@ float lum=getLuminance(gl_FragColor.rgb);
7695
7695
  float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;
7696
7696
  gl_FragColor.rgb+=grain*grainAmount;
7697
7697
  gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);
7698
- }`;U.ShadersStore[fg]=dg;class ar extends ue{getClassName(){return"GrainPostProcess"}constructor(e,t,i,s,r,n,a=0,o=!1){super(e,"grain",["intensity","animatedSeed"],[],t,i,s,r,n,null,a,void 0,null,o),this.intensity=30,this.animated=!1,this.onApplyObservable.add(h=>{h.setFloat("intensity",this.intensity),h.setFloat("animatedSeed",this.animated?Math.random()+1:1)})}static _Parse(e,t,i,s){return J.Parse(()=>new ar(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable),e,i,s)}}g([v()],ar.prototype,"intensity",void 0),g([v()],ar.prototype,"animated",void 0),Re("BABYLON.GrainPostProcess",ar);const _g="fxaaPixelShader",pg=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
7698
+ }`;U.ShadersStore[dg]=_g;class ar extends ue{getClassName(){return"GrainPostProcess"}constructor(e,t,i,s,r,n,a=0,o=!1){super(e,"grain",["intensity","animatedSeed"],[],t,i,s,r,n,null,a,void 0,null,o),this.intensity=30,this.animated=!1,this.onApplyObservable.add(h=>{h.setFloat("intensity",this.intensity),h.setFloat("animatedSeed",this.animated?Math.random()+1:1)})}static _Parse(e,t,i,s){return J.Parse(()=>new ar(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable),e,i,s)}}g([v()],ar.prototype,"intensity",void 0),g([v()],ar.prototype,"animated",void 0),Re("BABYLON.GrainPostProcess",ar);const pg="fxaaPixelShader",mg=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
7699
7699
  #define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
7700
7700
  #else
7701
7701
  #define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
@@ -7903,7 +7903,7 @@ gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);
7903
7903
  #else
7904
7904
  gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);
7905
7905
  #endif
7906
- }`;U.ShadersStore[_g]=pg;const mg="fxaaVertexShader",gg=`attribute vec2 position;
7906
+ }`;U.ShadersStore[pg]=mg;const gg="fxaaVertexShader",Eg=`attribute vec2 position;
7907
7907
  uniform vec2 texelSize;
7908
7908
  varying vec2 vUV;
7909
7909
  varying vec2 sampleCoordS;
@@ -7929,8 +7929,8 @@ sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;
7929
7929
  sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;
7930
7930
  gl_Position=vec4(position,0.0,1.0);
7931
7931
  #define CUSTOM_VERTEX_MAIN_END
7932
- }`;U.ShadersStore[mg]=gg;class or extends ue{getClassName(){return"FxaaPostProcess"}constructor(e,t,i=null,s,r,n,a=0){super(e,"fxaa",["texelSize"],null,t,i,s||O.BILINEAR_SAMPLINGMODE,r,n,null,a,"fxaa",void 0,!0);const o=this._getDefines();this.updateEffect(o),this.onApplyObservable.add(h=>{const c=this.texelSize;h.setFloat2("texelSize",c.x,c.y)})}_getDefines(){const e=this.getEngine();if(!e)return null;const t=e.getGlInfo();return t&&t.renderer&&t.renderer.toLowerCase().indexOf("mali")>-1?`#define MALI 1
7933
- `:null}static _Parse(e,t,i,s){return J.Parse(()=>new or(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable),e,i,s)}}Re("BABYLON.FxaaPostProcess",or);class lr{get name(){return this._name}get cameras(){return this._cameras}constructor(e,t){this._engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}getClassName(){return"PostProcessRenderPipeline"}get isSupported(){for(const e in this._renderEffects)if(Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&!this._renderEffects[e].isSupported)return!1;return!0}addEffect(e){this._renderEffects[e._name]=e}_rebuild(){}_enableEffect(e,t){const i=this._renderEffects[e];i&&i._enable(k.MakeArray(t||this._cameras))}_disableEffect(e,t){const i=this._renderEffects[e];i&&i._disable(k.MakeArray(t||this._cameras))}_attachCameras(e,t){const i=k.MakeArray(e||this._cameras);if(!i)return;const s=[];let r;for(r=0;r<i.length;r++){const n=i[r];n&&(this._cameras.indexOf(n)===-1?this._cameras.push(n):t&&s.push(r))}for(r=0;r<s.length;r++)i.splice(s[r],1);for(const n in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,n)&&this._renderEffects[n]._attachCameras(i)}_detachCameras(e){const t=k.MakeArray(e||this._cameras);if(t){for(const i in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,i)&&this._renderEffects[i]._detachCameras(t);for(let i=0;i<t.length;i++)this._cameras.splice(this._cameras.indexOf(t[i]),1)}}_update(){for(const e in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&this._renderEffects[e]._update();for(let e=0;e<this._cameras.length;e++){if(!this._cameras[e])continue;const t=this._cameras[e].name;this._renderEffectsForIsolatedPass[t]&&this._renderEffectsForIsolatedPass[t]._update()}}_reset(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array}_enableMSAAOnFirstPostProcess(e){if(!this._engine._features.supportMSAA)return!1;const t=Object.keys(this._renderEffects);if(t.length>0){const i=this._renderEffects[t[0]].getPostProcesses();i&&(i[0].samples=e)}return!0}setPrePassRenderer(e){return!1}dispose(){}}g([v()],lr.prototype,"_name",void 0);class Le{constructor(e,t,i,s){this._name=t,this._singleInstance=s||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}get isSupported(){for(const e in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,e)){const t=this._postProcesses[e];for(let i=0;i<t.length;i++)if(!t[i].isSupported)return!1}return!0}_update(){}_attachCameras(e){let t;const i=k.MakeArray(e||this._cameras);if(i)for(let s=0;s<i.length;s++){const r=i[s];if(!r)continue;const n=r.name;if(this._singleInstance?t=0:t=n,!this._postProcesses[t]){const a=this._getPostProcesses();a&&(this._postProcesses[t]=Array.isArray(a)?a:[a])}this._indicesForCamera[n]||(this._indicesForCamera[n]=[]),this._postProcesses[t].forEach(a=>{const o=r.attachPostProcess(a);this._indicesForCamera[n].push(o)}),this._cameras[n]||(this._cameras[n]=r)}}_detachCameras(e){const t=k.MakeArray(e||this._cameras);if(t)for(let i=0;i<t.length;i++){const s=t[i],r=s.name,n=this._postProcesses[this._singleInstance?0:r];n&&n.forEach(a=>{s.detachPostProcess(a)}),this._cameras[r]&&(this._cameras[r]=null)}}_enable(e){const t=k.MakeArray(e||this._cameras);if(t)for(let i=0;i<t.length;i++){const s=t[i],r=s.name;for(let n=0;n<this._indicesForCamera[r].length;n++)(s._postProcesses[this._indicesForCamera[r][n]]===void 0||s._postProcesses[this._indicesForCamera[r][n]]===null)&&this._postProcesses[this._singleInstance?0:r].forEach(a=>{t[i].attachPostProcess(a,this._indicesForCamera[r][n])})}}_disable(e){const t=k.MakeArray(e||this._cameras);if(t)for(let i=0;i<t.length;i++){const s=t[i],r=s.name;this._postProcesses[this._singleInstance?0:r].forEach(n=>{s.detachPostProcess(n)})}}getPostProcesses(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null}}const Eg="circleOfConfusionPixelShader",Tg=`uniform sampler2D depthSampler;
7932
+ }`;U.ShadersStore[gg]=Eg;class or extends ue{getClassName(){return"FxaaPostProcess"}constructor(e,t,i=null,s,r,n,a=0){super(e,"fxaa",["texelSize"],null,t,i,s||O.BILINEAR_SAMPLINGMODE,r,n,null,a,"fxaa",void 0,!0);const o=this._getDefines();this.updateEffect(o),this.onApplyObservable.add(h=>{const c=this.texelSize;h.setFloat2("texelSize",c.x,c.y)})}_getDefines(){const e=this.getEngine();if(!e)return null;const t=e.getGlInfo();return t&&t.renderer&&t.renderer.toLowerCase().indexOf("mali")>-1?`#define MALI 1
7933
+ `:null}static _Parse(e,t,i,s){return J.Parse(()=>new or(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable),e,i,s)}}Re("BABYLON.FxaaPostProcess",or);class lr{get name(){return this._name}get cameras(){return this._cameras}constructor(e,t){this._engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}getClassName(){return"PostProcessRenderPipeline"}get isSupported(){for(const e in this._renderEffects)if(Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&!this._renderEffects[e].isSupported)return!1;return!0}addEffect(e){this._renderEffects[e._name]=e}_rebuild(){}_enableEffect(e,t){const i=this._renderEffects[e];i&&i._enable(k.MakeArray(t||this._cameras))}_disableEffect(e,t){const i=this._renderEffects[e];i&&i._disable(k.MakeArray(t||this._cameras))}_attachCameras(e,t){const i=k.MakeArray(e||this._cameras);if(!i)return;const s=[];let r;for(r=0;r<i.length;r++){const n=i[r];n&&(this._cameras.indexOf(n)===-1?this._cameras.push(n):t&&s.push(r))}for(r=0;r<s.length;r++)i.splice(s[r],1);for(const n in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,n)&&this._renderEffects[n]._attachCameras(i)}_detachCameras(e){const t=k.MakeArray(e||this._cameras);if(t){for(const i in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,i)&&this._renderEffects[i]._detachCameras(t);for(let i=0;i<t.length;i++)this._cameras.splice(this._cameras.indexOf(t[i]),1)}}_update(){for(const e in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&this._renderEffects[e]._update();for(let e=0;e<this._cameras.length;e++){if(!this._cameras[e])continue;const t=this._cameras[e].name;this._renderEffectsForIsolatedPass[t]&&this._renderEffectsForIsolatedPass[t]._update()}}_reset(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array}_enableMSAAOnFirstPostProcess(e){if(!this._engine._features.supportMSAA)return!1;const t=Object.keys(this._renderEffects);if(t.length>0){const i=this._renderEffects[t[0]].getPostProcesses();i&&(i[0].samples=e)}return!0}setPrePassRenderer(e){return!1}dispose(){}}g([v()],lr.prototype,"_name",void 0);class Le{constructor(e,t,i,s){this._name=t,this._singleInstance=s||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}get isSupported(){for(const e in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,e)){const t=this._postProcesses[e];for(let i=0;i<t.length;i++)if(!t[i].isSupported)return!1}return!0}_update(){}_attachCameras(e){let t;const i=k.MakeArray(e||this._cameras);if(i)for(let s=0;s<i.length;s++){const r=i[s];if(!r)continue;const n=r.name;if(this._singleInstance?t=0:t=n,!this._postProcesses[t]){const a=this._getPostProcesses();a&&(this._postProcesses[t]=Array.isArray(a)?a:[a])}this._indicesForCamera[n]||(this._indicesForCamera[n]=[]),this._postProcesses[t].forEach(a=>{const o=r.attachPostProcess(a);this._indicesForCamera[n].push(o)}),this._cameras[n]||(this._cameras[n]=r)}}_detachCameras(e){const t=k.MakeArray(e||this._cameras);if(t)for(let i=0;i<t.length;i++){const s=t[i],r=s.name,n=this._postProcesses[this._singleInstance?0:r];n&&n.forEach(a=>{s.detachPostProcess(a)}),this._cameras[r]&&(this._cameras[r]=null)}}_enable(e){const t=k.MakeArray(e||this._cameras);if(t)for(let i=0;i<t.length;i++){const s=t[i],r=s.name;for(let n=0;n<this._indicesForCamera[r].length;n++)(s._postProcesses[this._indicesForCamera[r][n]]===void 0||s._postProcesses[this._indicesForCamera[r][n]]===null)&&this._postProcesses[this._singleInstance?0:r].forEach(a=>{t[i].attachPostProcess(a,this._indicesForCamera[r][n])})}}_disable(e){const t=k.MakeArray(e||this._cameras);if(t)for(let i=0;i<t.length;i++){const s=t[i],r=s.name;this._postProcesses[this._singleInstance?0:r].forEach(n=>{s.detachPostProcess(n)})}}getPostProcesses(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null}}const Tg="circleOfConfusionPixelShader",Ag=`uniform sampler2D depthSampler;
7934
7934
  varying vec2 vUV;
7935
7935
  uniform vec2 cameraMinMaxZ;
7936
7936
  uniform float focusDistance;
@@ -7946,8 +7946,8 @@ float coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));
7946
7946
  coc=clamp(coc,0.0,1.0);
7947
7947
  gl_FragColor=vec4(coc,coc,coc,1.0);
7948
7948
  }
7949
- `;U.ShadersStore[Eg]=Tg;class hr extends ue{getClassName(){return"CircleOfConfusionPostProcess"}constructor(e,t,i,s,r,n,a,o=0,h=!1){super(e,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],i,s,r,n,a,null,o,void 0,null,h),this.lensSize=50,this.fStop=1.4,this.focusDistance=2e3,this.focalLength=50,this._depthTexture=null,this._depthTexture=t,this.onApplyObservable.add(c=>{if(!this._depthTexture){F.Warn("No depth texture set on CircleOfConfusionPostProcess");return}c.setTexture("depthSampler",this._depthTexture);const f=this.lensSize/this.fStop*this.focalLength/(this.focusDistance-this.focalLength);c.setFloat("focusDistance",this.focusDistance),c.setFloat("cocPrecalculation",f);const d=this._depthTexture.activeCamera;c.setFloat2("cameraMinMaxZ",d.minZ,d.maxZ-d.minZ)})}set depthTexture(e){this._depthTexture=e}}g([v()],hr.prototype,"lensSize",void 0),g([v()],hr.prototype,"fStop",void 0),g([v()],hr.prototype,"focusDistance",void 0),g([v()],hr.prototype,"focalLength",void 0),Re("BABYLON.CircleOfConfusionPostProcess",hr);class Tn extends gt{getClassName(){return"DepthOfFieldBlurPostProcess"}constructor(e,t,i,s,r,n,a,o=null,h=O.BILINEAR_SAMPLINGMODE,c,u,f=0,d=!1,_=5){super(e,i,s,r,n,h=2,c,u,f,`#define DOF 1\r
7950
- `,d,_),this.direction=i,this.externalTextureSamplerBinding=!!o,this.onApplyObservable.add(p=>{o!=null&&p.setTextureFromPostProcess("textureSampler",o),p.setTextureFromPostProcessOutput("circleOfConfusionSampler",a)})}}g([v()],Tn.prototype,"direction",void 0),Re("BABYLON.DepthOfFieldBlurPostProcess",Tn);const Ag="depthOfFieldMergePixelShader",vg=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
7949
+ `;U.ShadersStore[Tg]=Ag;class hr extends ue{getClassName(){return"CircleOfConfusionPostProcess"}constructor(e,t,i,s,r,n,a,o=0,h=!1){super(e,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],i,s,r,n,a,null,o,void 0,null,h),this.lensSize=50,this.fStop=1.4,this.focusDistance=2e3,this.focalLength=50,this._depthTexture=null,this._depthTexture=t,this.onApplyObservable.add(c=>{if(!this._depthTexture){F.Warn("No depth texture set on CircleOfConfusionPostProcess");return}c.setTexture("depthSampler",this._depthTexture);const f=this.lensSize/this.fStop*this.focalLength/(this.focusDistance-this.focalLength);c.setFloat("focusDistance",this.focusDistance),c.setFloat("cocPrecalculation",f);const d=this._depthTexture.activeCamera;c.setFloat2("cameraMinMaxZ",d.minZ,d.maxZ-d.minZ)})}set depthTexture(e){this._depthTexture=e}}g([v()],hr.prototype,"lensSize",void 0),g([v()],hr.prototype,"fStop",void 0),g([v()],hr.prototype,"focusDistance",void 0),g([v()],hr.prototype,"focalLength",void 0),Re("BABYLON.CircleOfConfusionPostProcess",hr);class Tn extends gt{getClassName(){return"DepthOfFieldBlurPostProcess"}constructor(e,t,i,s,r,n,a,o=null,h=O.BILINEAR_SAMPLINGMODE,c,u,f=0,d=!1,_=5){super(e,i,s,r,n,h=2,c,u,f,`#define DOF 1\r
7950
+ `,d,_),this.direction=i,this.externalTextureSamplerBinding=!!o,this.onApplyObservable.add(p=>{o!=null&&p.setTextureFromPostProcess("textureSampler",o),p.setTextureFromPostProcessOutput("circleOfConfusionSampler",a)})}}g([v()],Tn.prototype,"direction",void 0),Re("BABYLON.DepthOfFieldBlurPostProcess",Tn);const vg="depthOfFieldMergePixelShader",Sg=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
7951
7951
  #define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
7952
7952
  #else
7953
7953
  #define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
@@ -7998,8 +7998,8 @@ gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);
7998
7998
  }
7999
7999
  #endif
8000
8000
  }
8001
- `;U.ShadersStore[Ag]=vg;class Sg extends ue{getClassName(){return"DepthOfFieldMergePostProcess"}constructor(e,t,i,s,r,n,a,o,h,c=0,u=!1){super(e,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],r,n,a,o,h,null,c,void 0,null,!0),this._blurSteps=s,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add(f=>{f.setTextureFromPostProcess("textureSampler",t),f.setTextureFromPostProcessOutput("circleOfConfusionSampler",i),s.forEach((d,_)=>{f.setTextureFromPostProcessOutput("blurStep"+(s.length-_-1),d)})}),u||this.updateEffect()}updateEffect(e=null,t=null,i=null,s,r,n){e||(e="",e+="#define BLUR_LEVEL "+(this._blurSteps.length-1)+`
8002
- `),super.updateEffect(e,t,i,s,r,n)}}var Ki;(function(l){l[l.Low=0]="Low",l[l.Medium=1]="Medium",l[l.High=2]="High"})(Ki||(Ki={}));class yl extends Le{set focalLength(e){this._circleOfConfusion.focalLength=e}get focalLength(){return this._circleOfConfusion.focalLength}set fStop(e){this._circleOfConfusion.fStop=e}get fStop(){return this._circleOfConfusion.fStop}set focusDistance(e){this._circleOfConfusion.focusDistance=e}get focusDistance(){return this._circleOfConfusion.focusDistance}set lensSize(e){this._circleOfConfusion.lensSize=e}get lensSize(){return this._circleOfConfusion.lensSize}constructor(e,t,i=Ki.Low,s=0,r=!1){super(e.getEngine(),"depth of field",()=>this._effects,!0),this._effects=[];const n=e.getEngine(),a=n.isWebGPU||n.webGLVersion>1?6:5;this._circleOfConfusion=new hr("circleOfConfusion",t,1,null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r),this._depthOfFieldBlurY=[],this._depthOfFieldBlurX=[];let o=1,h=15;switch(i){case Ki.High:{o=3,h=51;break}case Ki.Medium:{o=2,h=31;break}default:{h=15,o=1;break}}const c=h/Math.pow(2,o-1);let u=1;for(let f=0;f<o;f++){const d=new Tn("vertical blur",e,new ae(0,1),c,u,null,this._circleOfConfusion,f==0?this._circleOfConfusion:null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r,f==0?a:5);d.autoClear=!1,u=.75/Math.pow(2,f);const _=new Tn("horizontal blur",e,new ae(1,0),c,u,null,this._circleOfConfusion,null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r);_.autoClear=!1,this._depthOfFieldBlurY.push(d),this._depthOfFieldBlurX.push(_)}this._effects=[this._circleOfConfusion];for(let f=0;f<this._depthOfFieldBlurX.length;f++)this._effects.push(this._depthOfFieldBlurY[f]),this._effects.push(this._depthOfFieldBlurX[f]);this._dofMerge=new Sg("dofMerge",this._circleOfConfusion,this._circleOfConfusion,this._depthOfFieldBlurX,u,null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r),this._dofMerge.autoClear=!1,this._effects.push(this._dofMerge)}getClassName(){return"DepthOfFieldEffect"}set depthTexture(e){this._circleOfConfusion.depthTexture=e}disposeEffects(e){for(let t=0;t<this._effects.length;t++)this._effects[t].dispose(e)}_updateEffects(){for(let e=0;e<this._effects.length;e++)this._effects[e].updateEffect()}_isReady(){for(let e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0}}const Rg="extractHighlightsPixelShader",xg=`#include<helperFunctions>
8001
+ `;U.ShadersStore[vg]=Sg;class Rg extends ue{getClassName(){return"DepthOfFieldMergePostProcess"}constructor(e,t,i,s,r,n,a,o,h,c=0,u=!1){super(e,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],r,n,a,o,h,null,c,void 0,null,!0),this._blurSteps=s,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add(f=>{f.setTextureFromPostProcess("textureSampler",t),f.setTextureFromPostProcessOutput("circleOfConfusionSampler",i),s.forEach((d,_)=>{f.setTextureFromPostProcessOutput("blurStep"+(s.length-_-1),d)})}),u||this.updateEffect()}updateEffect(e=null,t=null,i=null,s,r,n){e||(e="",e+="#define BLUR_LEVEL "+(this._blurSteps.length-1)+`
8002
+ `),super.updateEffect(e,t,i,s,r,n)}}var Ki;(function(l){l[l.Low=0]="Low",l[l.Medium=1]="Medium",l[l.High=2]="High"})(Ki||(Ki={}));class yl extends Le{set focalLength(e){this._circleOfConfusion.focalLength=e}get focalLength(){return this._circleOfConfusion.focalLength}set fStop(e){this._circleOfConfusion.fStop=e}get fStop(){return this._circleOfConfusion.fStop}set focusDistance(e){this._circleOfConfusion.focusDistance=e}get focusDistance(){return this._circleOfConfusion.focusDistance}set lensSize(e){this._circleOfConfusion.lensSize=e}get lensSize(){return this._circleOfConfusion.lensSize}constructor(e,t,i=Ki.Low,s=0,r=!1){super(e.getEngine(),"depth of field",()=>this._effects,!0),this._effects=[];const n=e.getEngine(),a=n.isWebGPU||n.webGLVersion>1?6:5;this._circleOfConfusion=new hr("circleOfConfusion",t,1,null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r),this._depthOfFieldBlurY=[],this._depthOfFieldBlurX=[];let o=1,h=15;switch(i){case Ki.High:{o=3,h=51;break}case Ki.Medium:{o=2,h=31;break}default:{h=15,o=1;break}}const c=h/Math.pow(2,o-1);let u=1;for(let f=0;f<o;f++){const d=new Tn("vertical blur",e,new ae(0,1),c,u,null,this._circleOfConfusion,f==0?this._circleOfConfusion:null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r,f==0?a:5);d.autoClear=!1,u=.75/Math.pow(2,f);const _=new Tn("horizontal blur",e,new ae(1,0),c,u,null,this._circleOfConfusion,null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r);_.autoClear=!1,this._depthOfFieldBlurY.push(d),this._depthOfFieldBlurX.push(_)}this._effects=[this._circleOfConfusion];for(let f=0;f<this._depthOfFieldBlurX.length;f++)this._effects.push(this._depthOfFieldBlurY[f]),this._effects.push(this._depthOfFieldBlurX[f]);this._dofMerge=new Rg("dofMerge",this._circleOfConfusion,this._circleOfConfusion,this._depthOfFieldBlurX,u,null,O.BILINEAR_SAMPLINGMODE,n,!1,s,r),this._dofMerge.autoClear=!1,this._effects.push(this._dofMerge)}getClassName(){return"DepthOfFieldEffect"}set depthTexture(e){this._circleOfConfusion.depthTexture=e}disposeEffects(e){for(let t=0;t<this._effects.length;t++)this._effects[t].dispose(e)}_updateEffects(){for(let e=0;e<this._effects.length;e++)this._effects[e].updateEffect()}_isReady(){for(let e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0}}const xg="extractHighlightsPixelShader",Cg=`#include<helperFunctions>
8003
8003
  varying vec2 vUV;
8004
8004
  uniform sampler2D textureSampler;
8005
8005
  uniform float threshold;
@@ -8010,7 +8010,7 @@ void main(void)
8010
8010
  gl_FragColor=texture2D(textureSampler,vUV);
8011
8011
  float luma=dot(LuminanceEncodeApprox,gl_FragColor.rgb*exposure);
8012
8012
  gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;
8013
- }`;U.ShadersStore[Rg]=xg;class Na extends ue{getClassName(){return"ExtractHighlightsPostProcess"}constructor(e,t,i,s,r,n,a=0,o=!1){super(e,"extractHighlights",["threshold","exposure"],null,t,i,s,r,n,null,a,void 0,null,o),this.threshold=.9,this._exposure=1,this._inputPostProcess=null,this.onApplyObservable.add(h=>{this.externalTextureSamplerBinding=!!this._inputPostProcess,this._inputPostProcess&&h.setTextureFromPostProcess("textureSampler",this._inputPostProcess),h.setFloat("threshold",Math.pow(this.threshold,fr)),h.setFloat("exposure",this._exposure)})}}g([v()],Na.prototype,"threshold",void 0),Re("BABYLON.ExtractHighlightsPostProcess",Na);const Cg="bloomMergePixelShader",bg=`uniform sampler2D textureSampler;
8013
+ }`;U.ShadersStore[xg]=Cg;class Na extends ue{getClassName(){return"ExtractHighlightsPostProcess"}constructor(e,t,i,s,r,n,a=0,o=!1){super(e,"extractHighlights",["threshold","exposure"],null,t,i,s,r,n,null,a,void 0,null,o),this.threshold=.9,this._exposure=1,this._inputPostProcess=null,this.onApplyObservable.add(h=>{this.externalTextureSamplerBinding=!!this._inputPostProcess,this._inputPostProcess&&h.setTextureFromPostProcess("textureSampler",this._inputPostProcess),h.setFloat("threshold",Math.pow(this.threshold,fr)),h.setFloat("exposure",this._exposure)})}}g([v()],Na.prototype,"threshold",void 0),Re("BABYLON.ExtractHighlightsPostProcess",Na);const bg="bloomMergePixelShader",Ig=`uniform sampler2D textureSampler;
8014
8014
  uniform sampler2D bloomBlur;
8015
8015
  varying vec2 vUV;
8016
8016
  uniform float bloomWeight;
@@ -8021,7 +8021,7 @@ gl_FragColor=texture2D(textureSampler,vUV);
8021
8021
  vec3 blurred=texture2D(bloomBlur,vUV).rgb;
8022
8022
  gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);
8023
8023
  }
8024
- `;U.ShadersStore[Cg]=bg;class Fa extends ue{getClassName(){return"BloomMergePostProcess"}constructor(e,t,i,s,r,n,a,o,h,c=0,u=!1){super(e,"bloomMerge",["bloomWeight"],["bloomBlur"],r,n,a,o,h,null,c,void 0,null,!0),this.weight=1,this.weight=s,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add(f=>{f.setTextureFromPostProcess("textureSampler",t),f.setTextureFromPostProcessOutput("bloomBlur",i),f.setFloat("bloomWeight",this.weight)}),u||this.updateEffect()}}g([v()],Fa.prototype,"weight",void 0),Re("BABYLON.BloomMergePostProcess",Fa);class Ml extends Le{get threshold(){return this._downscale.threshold}set threshold(e){this._downscale.threshold=e}get weight(){return this._merge.weight}set weight(e){this._merge.weight=e}get kernel(){return this._blurX.kernel/this._bloomScale}set kernel(e){this._blurX.kernel=e*this._bloomScale,this._blurY.kernel=e*this._bloomScale}constructor(e,t,i,s,r=0,n=!1){super(e.getEngine(),"bloom",()=>this._effects,!0),this._bloomScale=t,this._effects=[],this._downscale=new Na("highlights",1,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n),this._blurX=new gt("horizontal blur",new ae(1,0),10,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,void 0,n),this._blurX.alwaysForcePOT=!0,this._blurX.autoClear=!1,this._blurY=new gt("vertical blur",new ae(0,1),10,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,void 0,n),this._blurY.alwaysForcePOT=!0,this._blurY.autoClear=!1,this.kernel=s,this._effects=[this._downscale,this._blurX,this._blurY],this._merge=new Fa("bloomMerge",this._downscale,this._blurY,i,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n),this._merge.autoClear=!1,this._effects.push(this._merge)}disposeEffects(e){for(let t=0;t<this._effects.length;t++)this._effects[t].dispose(e)}_updateEffects(){for(let e=0;e<this._effects.length;e++)this._effects[e].updateEffect()}_isReady(){for(let e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0}}class Ig{constructor(){this._renderPipelines={}}get supportedPipelines(){const e=[];for(const t in this._renderPipelines)if(Object.prototype.hasOwnProperty.call(this._renderPipelines,t)){const i=this._renderPipelines[t];i.isSupported&&e.push(i)}return e}addPipeline(e){this._renderPipelines[e._name]=e}removePipeline(e){delete this._renderPipelines[e]}attachCamerasToRenderPipeline(e,t,i=!1){const s=this._renderPipelines[e];s&&s._attachCameras(t,i)}detachCamerasFromRenderPipeline(e,t){const i=this._renderPipelines[e];i&&i._detachCameras(t)}enableEffectInPipeline(e,t,i){const s=this._renderPipelines[e];s&&s._enableEffect(t,i)}disableEffectInPipeline(e,t,i){const s=this._renderPipelines[e];s&&s._disableEffect(t,i)}update(){for(const e in this._renderPipelines)if(Object.prototype.hasOwnProperty.call(this._renderPipelines,e)){const t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}}_rebuild(){for(const e in this._renderPipelines)Object.prototype.hasOwnProperty.call(this._renderPipelines,e)&&this._renderPipelines[e]._rebuild()}dispose(){for(const e in this._renderPipelines)Object.prototype.hasOwnProperty.call(this._renderPipelines,e)&&this._renderPipelines[e].dispose()}}Object.defineProperty(Ie.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){let l=this._getComponent(ee.NAME_POSTPROCESSRENDERPIPELINEMANAGER);l||(l=new yg(this),this._addComponent(l)),this._postProcessRenderPipelineManager=new Ig}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});class yg{constructor(e){this.name=ee.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(ee.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)}rebuild(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()}dispose(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()}_gatherRenderTargets(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()}}class Et extends lr{get automaticBuild(){return this._buildAllowed}set automaticBuild(e){this._buildAllowed=e}get scene(){return this._scene}set sharpenEnabled(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())}get sharpenEnabled(){return this._sharpenEnabled}get bloomKernel(){return this._bloomKernel}set bloomKernel(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel}set bloomWeight(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)}get bloomWeight(){return this._bloomWeight}set bloomThreshold(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)}get bloomThreshold(){return this._bloomThreshold}set bloomScale(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())}get bloomScale(){return this._bloomScale}set bloomEnabled(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())}get bloomEnabled(){return this._bloomEnabled}_rebuildBloom(){const e=this.bloom;this.bloom=new Ml(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(let t=0;t<this._cameras.length;t++)e.disposeEffects(this._cameras[t])}get depthOfFieldEnabled(){return this._depthOfFieldEnabled}set depthOfFieldEnabled(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())}get depthOfFieldBlurLevel(){return this._depthOfFieldBlurLevel}set depthOfFieldBlurLevel(e){if(this._depthOfFieldBlurLevel===e)return;this._depthOfFieldBlurLevel=e;const t=this.depthOfField;this.depthOfField=new yl(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=t.focalLength,this.depthOfField.focusDistance=t.focusDistance,this.depthOfField.fStop=t.fStop,this.depthOfField.lensSize=t.lensSize;for(let i=0;i<this._cameras.length;i++)t.disposeEffects(this._cameras[i]);this._buildPipeline()}set fxaaEnabled(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())}get fxaaEnabled(){return this._fxaaEnabled}set samples(e){this._samples!==e&&(this._samples=e,this._buildPipeline())}get samples(){return this._samples}set imageProcessingEnabled(e){this._imageProcessingEnabled!==e&&(this._scene.imageProcessingConfiguration.isEnabled=e)}get imageProcessingEnabled(){return this._imageProcessingEnabled}set glowLayerEnabled(e){e&&!this._glowLayer?this._glowLayer=new ei("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)}get glowLayerEnabled(){return this._glowLayer!=null}get glowLayer(){return this._glowLayer}set chromaticAberrationEnabled(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())}get chromaticAberrationEnabled(){return this._chromaticAberrationEnabled}set grainEnabled(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())}get grainEnabled(){return this._grainEnabled}constructor(e="",t=!0,i=Ee.LastCreatedScene,s,r=!0){super(i.getEngine(),e),this._camerasToBeAttached=[],this.SharpenPostProcessId="SharpenPostProcessEffect",this.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",this.FxaaPostProcessId="FxaaPostProcessEffect",this.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",this.GrainPostProcessId="GrainPostProcessEffect",this._glowLayer=null,this.animations=[],this._imageProcessingConfigurationObserver=null,this._sharpenEnabled=!1,this._bloomEnabled=!1,this._depthOfFieldEnabled=!1,this._depthOfFieldBlurLevel=Ki.Low,this._fxaaEnabled=!1,this._imageProcessingEnabled=!0,this._bloomScale=.5,this._chromaticAberrationEnabled=!1,this._grainEnabled=!1,this._buildAllowed=!0,this.onBuildObservable=new B,this._resizeObserver=null,this._hardwareScaleLevel=1,this._bloomKernel=64,this._bloomWeight=.15,this._bloomThreshold=.9,this._samples=1,this._hasCleared=!1,this._prevPostProcess=null,this._prevPrevPostProcess=null,this._depthOfFieldSceneObserver=null,this._activeCameraChangedObserver=null,this._activeCamerasChangedObserver=null,this._cameras=s||i.cameras,this._cameras=this._cameras.slice(),this._camerasToBeAttached=this._cameras.slice(),this._buildAllowed=r,this._scene=i;const n=this._scene.getEngine().getCaps();this._hdr=t&&(n.textureHalfFloatRender||n.textureFloatRender),this._hdr?n.textureHalfFloatRender?this._defaultPipelineTextureType=2:n.textureFloatRender&&(this._defaultPipelineTextureType=1):this._defaultPipelineTextureType=0,i.postProcessRenderPipelineManager.addPipeline(this);const a=this._scene.getEngine();this.sharpen=new nr("sharpen",1,null,O.BILINEAR_SAMPLINGMODE,a,!1,this._defaultPipelineTextureType,!0),this._sharpenEffect=new Le(a,this.SharpenPostProcessId,()=>this.sharpen,!0),this.depthOfField=new yl(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!0),this._hardwareScaleLevel=a.getHardwareScalingLevel(),this._resizeObserver=a.onResizeObservable.add(()=>{this._hardwareScaleLevel=a.getHardwareScalingLevel(),this.bloomKernel=this._bloomKernel}),this.bloom=new Ml(this._scene,this._bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!0),this.chromaticAberration=new Pi("ChromaticAberration",a.getRenderWidth(),a.getRenderHeight(),1,null,O.BILINEAR_SAMPLINGMODE,a,!1,this._defaultPipelineTextureType,!0),this._chromaticAberrationEffect=new Le(a,this.ChromaticAberrationPostProcessId,()=>this.chromaticAberration,!0),this.grain=new ar("Grain",1,null,O.BILINEAR_SAMPLINGMODE,a,!1,this._defaultPipelineTextureType,!0),this._grainEffect=new Le(a,this.GrainPostProcessId,()=>this.grain,!0),this._imageProcessingConfigurationObserver=this._scene.imageProcessingConfiguration.onUpdateParameters.add(()=>{this.bloom._downscale._exposure=this._scene.imageProcessingConfiguration.exposure,this.imageProcessingEnabled!==this._scene.imageProcessingConfiguration.isEnabled&&(this._imageProcessingEnabled=this._scene.imageProcessingConfiguration.isEnabled,k.SetImmediate(()=>{this._buildPipeline()}))}),this._buildPipeline()}getClassName(){return"DefaultRenderingPipeline"}prepare(){const e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e}_setAutoClearAndTextureSharing(e,t=!1){this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)}_buildPipeline(){if(!this._buildAllowed)return;this._scene.autoClear=!0;const e=this._scene.getEngine();if(this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(const t of this._cameras){const i=this._scene.enableDepthRenderer(t);i.useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add(t=>{this._cameras.indexOf(t.activeCamera)>-1&&(this.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())})}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);const t=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=t.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new Il("imageProcessing",1,null,O.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new Le(e,this.ImageProcessingPostProcessId,()=>this.imageProcessing,!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,(!this._cameras||this._cameras.length===0)&&(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new or("fxaa",1,null,O.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType),this.addEffect(new Le(e,this.FxaaPostProcessId,()=>this.fxaa,!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),(this._scene.activeCameras&&this._scene.activeCameras.length>1||this._scene.activeCamera&&this._cameras.indexOf(this._scene.activeCamera)===-1)&&(this._scene.autoClear=!0),this._activeCameraChangedObserver||(this._activeCameraChangedObserver=this._scene.onActiveCameraChanged.add(()=>{this._scene.activeCamera&&this._cameras.indexOf(this._scene.activeCamera)===-1&&(this._scene.autoClear=!0)})),this._activeCamerasChangedObserver||(this._activeCamerasChangedObserver=this._scene.onActiveCamerasChanged.add(()=>{this._scene.activeCameras&&this._scene.activeCameras.length>1&&(this._scene.autoClear=!0)})),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&F.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}_disposePostProcesses(e=!1){for(let t=0;t<this._cameras.length;t++){const i=this._cameras[t];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)}addCamera(e){this._camerasToBeAttached.push(e),this._buildPipeline()}removeCamera(e){const t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()}dispose(){this._buildAllowed=!1,this.onBuildObservable.clear(),this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene._postProcessRenderPipelineManager.removePipeline(this.name),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.onActiveCameraChanged.remove(this._activeCameraChangedObserver),this._scene.onActiveCamerasChanged.remove(this._activeCamerasChangedObserver),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),super.dispose()}serialize(){const e=J.Serialize(this);return e.customType="DefaultRenderingPipeline",e}static Parse(e,t,i){return J.Parse(()=>new Et(e._name,e._name._hdr,t),e,t,i)}}g([v()],Et.prototype,"sharpenEnabled",null),g([v()],Et.prototype,"bloomKernel",null),g([v()],Et.prototype,"_bloomWeight",void 0),g([v()],Et.prototype,"_bloomThreshold",void 0),g([v()],Et.prototype,"_hdr",void 0),g([v()],Et.prototype,"bloomWeight",null),g([v()],Et.prototype,"bloomThreshold",null),g([v()],Et.prototype,"bloomScale",null),g([v()],Et.prototype,"bloomEnabled",null),g([v()],Et.prototype,"depthOfFieldEnabled",null),g([v()],Et.prototype,"depthOfFieldBlurLevel",null),g([v()],Et.prototype,"fxaaEnabled",null),g([v()],Et.prototype,"samples",null),g([v()],Et.prototype,"imageProcessingEnabled",null),g([v()],Et.prototype,"glowLayerEnabled",null),g([v()],Et.prototype,"chromaticAberrationEnabled",null),g([v()],Et.prototype,"grainEnabled",null),Re("BABYLON.DefaultRenderingPipeline",Et);const Mg="lensHighlightsPixelShader",Pg=`uniform sampler2D textureSampler;
8024
+ `;U.ShadersStore[bg]=Ig;class Fa extends ue{getClassName(){return"BloomMergePostProcess"}constructor(e,t,i,s,r,n,a,o,h,c=0,u=!1){super(e,"bloomMerge",["bloomWeight"],["bloomBlur"],r,n,a,o,h,null,c,void 0,null,!0),this.weight=1,this.weight=s,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add(f=>{f.setTextureFromPostProcess("textureSampler",t),f.setTextureFromPostProcessOutput("bloomBlur",i),f.setFloat("bloomWeight",this.weight)}),u||this.updateEffect()}}g([v()],Fa.prototype,"weight",void 0),Re("BABYLON.BloomMergePostProcess",Fa);class Ml extends Le{get threshold(){return this._downscale.threshold}set threshold(e){this._downscale.threshold=e}get weight(){return this._merge.weight}set weight(e){this._merge.weight=e}get kernel(){return this._blurX.kernel/this._bloomScale}set kernel(e){this._blurX.kernel=e*this._bloomScale,this._blurY.kernel=e*this._bloomScale}constructor(e,t,i,s,r=0,n=!1){super(e.getEngine(),"bloom",()=>this._effects,!0),this._bloomScale=t,this._effects=[],this._downscale=new Na("highlights",1,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n),this._blurX=new gt("horizontal blur",new ae(1,0),10,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,void 0,n),this._blurX.alwaysForcePOT=!0,this._blurX.autoClear=!1,this._blurY=new gt("vertical blur",new ae(0,1),10,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,void 0,n),this._blurY.alwaysForcePOT=!0,this._blurY.autoClear=!1,this.kernel=s,this._effects=[this._downscale,this._blurX,this._blurY],this._merge=new Fa("bloomMerge",this._downscale,this._blurY,i,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n),this._merge.autoClear=!1,this._effects.push(this._merge)}disposeEffects(e){for(let t=0;t<this._effects.length;t++)this._effects[t].dispose(e)}_updateEffects(){for(let e=0;e<this._effects.length;e++)this._effects[e].updateEffect()}_isReady(){for(let e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0}}class yg{constructor(){this._renderPipelines={}}get supportedPipelines(){const e=[];for(const t in this._renderPipelines)if(Object.prototype.hasOwnProperty.call(this._renderPipelines,t)){const i=this._renderPipelines[t];i.isSupported&&e.push(i)}return e}addPipeline(e){this._renderPipelines[e._name]=e}removePipeline(e){delete this._renderPipelines[e]}attachCamerasToRenderPipeline(e,t,i=!1){const s=this._renderPipelines[e];s&&s._attachCameras(t,i)}detachCamerasFromRenderPipeline(e,t){const i=this._renderPipelines[e];i&&i._detachCameras(t)}enableEffectInPipeline(e,t,i){const s=this._renderPipelines[e];s&&s._enableEffect(t,i)}disableEffectInPipeline(e,t,i){const s=this._renderPipelines[e];s&&s._disableEffect(t,i)}update(){for(const e in this._renderPipelines)if(Object.prototype.hasOwnProperty.call(this._renderPipelines,e)){const t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}}_rebuild(){for(const e in this._renderPipelines)Object.prototype.hasOwnProperty.call(this._renderPipelines,e)&&this._renderPipelines[e]._rebuild()}dispose(){for(const e in this._renderPipelines)Object.prototype.hasOwnProperty.call(this._renderPipelines,e)&&this._renderPipelines[e].dispose()}}Object.defineProperty(Ie.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){let l=this._getComponent(ee.NAME_POSTPROCESSRENDERPIPELINEMANAGER);l||(l=new Mg(this),this._addComponent(l)),this._postProcessRenderPipelineManager=new yg}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});class Mg{constructor(e){this.name=ee.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(ee.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)}rebuild(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()}dispose(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()}_gatherRenderTargets(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()}}class Et extends lr{get automaticBuild(){return this._buildAllowed}set automaticBuild(e){this._buildAllowed=e}get scene(){return this._scene}set sharpenEnabled(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())}get sharpenEnabled(){return this._sharpenEnabled}get bloomKernel(){return this._bloomKernel}set bloomKernel(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel}set bloomWeight(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)}get bloomWeight(){return this._bloomWeight}set bloomThreshold(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)}get bloomThreshold(){return this._bloomThreshold}set bloomScale(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())}get bloomScale(){return this._bloomScale}set bloomEnabled(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())}get bloomEnabled(){return this._bloomEnabled}_rebuildBloom(){const e=this.bloom;this.bloom=new Ml(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(let t=0;t<this._cameras.length;t++)e.disposeEffects(this._cameras[t])}get depthOfFieldEnabled(){return this._depthOfFieldEnabled}set depthOfFieldEnabled(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())}get depthOfFieldBlurLevel(){return this._depthOfFieldBlurLevel}set depthOfFieldBlurLevel(e){if(this._depthOfFieldBlurLevel===e)return;this._depthOfFieldBlurLevel=e;const t=this.depthOfField;this.depthOfField=new yl(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=t.focalLength,this.depthOfField.focusDistance=t.focusDistance,this.depthOfField.fStop=t.fStop,this.depthOfField.lensSize=t.lensSize;for(let i=0;i<this._cameras.length;i++)t.disposeEffects(this._cameras[i]);this._buildPipeline()}set fxaaEnabled(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())}get fxaaEnabled(){return this._fxaaEnabled}set samples(e){this._samples!==e&&(this._samples=e,this._buildPipeline())}get samples(){return this._samples}set imageProcessingEnabled(e){this._imageProcessingEnabled!==e&&(this._scene.imageProcessingConfiguration.isEnabled=e)}get imageProcessingEnabled(){return this._imageProcessingEnabled}set glowLayerEnabled(e){e&&!this._glowLayer?this._glowLayer=new ei("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)}get glowLayerEnabled(){return this._glowLayer!=null}get glowLayer(){return this._glowLayer}set chromaticAberrationEnabled(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())}get chromaticAberrationEnabled(){return this._chromaticAberrationEnabled}set grainEnabled(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())}get grainEnabled(){return this._grainEnabled}constructor(e="",t=!0,i=Ee.LastCreatedScene,s,r=!0){super(i.getEngine(),e),this._camerasToBeAttached=[],this.SharpenPostProcessId="SharpenPostProcessEffect",this.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",this.FxaaPostProcessId="FxaaPostProcessEffect",this.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",this.GrainPostProcessId="GrainPostProcessEffect",this._glowLayer=null,this.animations=[],this._imageProcessingConfigurationObserver=null,this._sharpenEnabled=!1,this._bloomEnabled=!1,this._depthOfFieldEnabled=!1,this._depthOfFieldBlurLevel=Ki.Low,this._fxaaEnabled=!1,this._imageProcessingEnabled=!0,this._bloomScale=.5,this._chromaticAberrationEnabled=!1,this._grainEnabled=!1,this._buildAllowed=!0,this.onBuildObservable=new B,this._resizeObserver=null,this._hardwareScaleLevel=1,this._bloomKernel=64,this._bloomWeight=.15,this._bloomThreshold=.9,this._samples=1,this._hasCleared=!1,this._prevPostProcess=null,this._prevPrevPostProcess=null,this._depthOfFieldSceneObserver=null,this._activeCameraChangedObserver=null,this._activeCamerasChangedObserver=null,this._cameras=s||i.cameras,this._cameras=this._cameras.slice(),this._camerasToBeAttached=this._cameras.slice(),this._buildAllowed=r,this._scene=i;const n=this._scene.getEngine().getCaps();this._hdr=t&&(n.textureHalfFloatRender||n.textureFloatRender),this._hdr?n.textureHalfFloatRender?this._defaultPipelineTextureType=2:n.textureFloatRender&&(this._defaultPipelineTextureType=1):this._defaultPipelineTextureType=0,i.postProcessRenderPipelineManager.addPipeline(this);const a=this._scene.getEngine();this.sharpen=new nr("sharpen",1,null,O.BILINEAR_SAMPLINGMODE,a,!1,this._defaultPipelineTextureType,!0),this._sharpenEffect=new Le(a,this.SharpenPostProcessId,()=>this.sharpen,!0),this.depthOfField=new yl(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!0),this._hardwareScaleLevel=a.getHardwareScalingLevel(),this._resizeObserver=a.onResizeObservable.add(()=>{this._hardwareScaleLevel=a.getHardwareScalingLevel(),this.bloomKernel=this._bloomKernel}),this.bloom=new Ml(this._scene,this._bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!0),this.chromaticAberration=new Pi("ChromaticAberration",a.getRenderWidth(),a.getRenderHeight(),1,null,O.BILINEAR_SAMPLINGMODE,a,!1,this._defaultPipelineTextureType,!0),this._chromaticAberrationEffect=new Le(a,this.ChromaticAberrationPostProcessId,()=>this.chromaticAberration,!0),this.grain=new ar("Grain",1,null,O.BILINEAR_SAMPLINGMODE,a,!1,this._defaultPipelineTextureType,!0),this._grainEffect=new Le(a,this.GrainPostProcessId,()=>this.grain,!0),this._imageProcessingConfigurationObserver=this._scene.imageProcessingConfiguration.onUpdateParameters.add(()=>{this.bloom._downscale._exposure=this._scene.imageProcessingConfiguration.exposure,this.imageProcessingEnabled!==this._scene.imageProcessingConfiguration.isEnabled&&(this._imageProcessingEnabled=this._scene.imageProcessingConfiguration.isEnabled,k.SetImmediate(()=>{this._buildPipeline()}))}),this._buildPipeline()}getClassName(){return"DefaultRenderingPipeline"}prepare(){const e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e}_setAutoClearAndTextureSharing(e,t=!1){this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)}_buildPipeline(){if(!this._buildAllowed)return;this._scene.autoClear=!0;const e=this._scene.getEngine();if(this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(const t of this._cameras){const i=this._scene.enableDepthRenderer(t);i.useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add(t=>{this._cameras.indexOf(t.activeCamera)>-1&&(this.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())})}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);const t=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=t.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new Il("imageProcessing",1,null,O.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new Le(e,this.ImageProcessingPostProcessId,()=>this.imageProcessing,!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,(!this._cameras||this._cameras.length===0)&&(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new or("fxaa",1,null,O.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType),this.addEffect(new Le(e,this.FxaaPostProcessId,()=>this.fxaa,!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),(this._scene.activeCameras&&this._scene.activeCameras.length>1||this._scene.activeCamera&&this._cameras.indexOf(this._scene.activeCamera)===-1)&&(this._scene.autoClear=!0),this._activeCameraChangedObserver||(this._activeCameraChangedObserver=this._scene.onActiveCameraChanged.add(()=>{this._scene.activeCamera&&this._cameras.indexOf(this._scene.activeCamera)===-1&&(this._scene.autoClear=!0)})),this._activeCamerasChangedObserver||(this._activeCamerasChangedObserver=this._scene.onActiveCamerasChanged.add(()=>{this._scene.activeCameras&&this._scene.activeCameras.length>1&&(this._scene.autoClear=!0)})),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&F.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}_disposePostProcesses(e=!1){for(let t=0;t<this._cameras.length;t++){const i=this._cameras[t];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)}addCamera(e){this._camerasToBeAttached.push(e),this._buildPipeline()}removeCamera(e){const t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()}dispose(){this._buildAllowed=!1,this.onBuildObservable.clear(),this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene._postProcessRenderPipelineManager.removePipeline(this.name),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.onActiveCameraChanged.remove(this._activeCameraChangedObserver),this._scene.onActiveCamerasChanged.remove(this._activeCamerasChangedObserver),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),super.dispose()}serialize(){const e=J.Serialize(this);return e.customType="DefaultRenderingPipeline",e}static Parse(e,t,i){return J.Parse(()=>new Et(e._name,e._name._hdr,t),e,t,i)}}g([v()],Et.prototype,"sharpenEnabled",null),g([v()],Et.prototype,"bloomKernel",null),g([v()],Et.prototype,"_bloomWeight",void 0),g([v()],Et.prototype,"_bloomThreshold",void 0),g([v()],Et.prototype,"_hdr",void 0),g([v()],Et.prototype,"bloomWeight",null),g([v()],Et.prototype,"bloomThreshold",null),g([v()],Et.prototype,"bloomScale",null),g([v()],Et.prototype,"bloomEnabled",null),g([v()],Et.prototype,"depthOfFieldEnabled",null),g([v()],Et.prototype,"depthOfFieldBlurLevel",null),g([v()],Et.prototype,"fxaaEnabled",null),g([v()],Et.prototype,"samples",null),g([v()],Et.prototype,"imageProcessingEnabled",null),g([v()],Et.prototype,"glowLayerEnabled",null),g([v()],Et.prototype,"chromaticAberrationEnabled",null),g([v()],Et.prototype,"grainEnabled",null),Re("BABYLON.DefaultRenderingPipeline",Et);const Pg="lensHighlightsPixelShader",Og=`uniform sampler2D textureSampler;
8025
8025
  uniform float gain;
8026
8026
  uniform float threshold;
8027
8027
  uniform float screen_width;
@@ -8133,7 +8133,7 @@ blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));
8133
8133
  #endif
8134
8134
  blurred/=39.0;
8135
8135
  gl_FragColor=blurred;
8136
- }`;U.ShadersStore[Mg]=Pg;const Og="depthOfFieldPixelShader",Dg=`uniform sampler2D textureSampler;
8136
+ }`;U.ShadersStore[Pg]=Og;const Dg="depthOfFieldPixelShader",Lg=`uniform sampler2D textureSampler;
8137
8137
  uniform sampler2D highlightsSampler;
8138
8138
  uniform sampler2D depthSampler;
8139
8139
  uniform sampler2D grainSampler;
@@ -8267,7 +8267,7 @@ vec4 grain_color=texture2D(grainSampler,texels_coords*0.003);
8267
8267
  gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;
8268
8268
  }
8269
8269
  }
8270
- `;U.ShadersStore[Og]=Dg;class Lg{constructor(){this.enabled=!1,this.name="ssao2",this.texturesRequired=[6,5]}}const Ng="ssao2PixelShader",Fg=`precision highp float;
8270
+ `;U.ShadersStore[Dg]=Lg;class Ng{constructor(){this.enabled=!1,this.name="ssao2",this.texturesRequired=[6,5]}}const Fg="ssao2PixelShader",wg=`precision highp float;
8271
8271
  uniform sampler2D textureSampler;
8272
8272
  varying vec2 vUV;
8273
8273
  #ifdef SSAO
@@ -8429,7 +8429,7 @@ gl_FragColor.rgb=vec3(result);
8429
8429
  gl_FragColor.a=1.0;
8430
8430
  }
8431
8431
  #endif
8432
- `;U.ShadersStore[Ng]=Fg;const wg="ssaoCombinePixelShader",Bg=`uniform sampler2D textureSampler;
8432
+ `;U.ShadersStore[Fg]=wg;const Bg="ssaoCombinePixelShader",Ug=`uniform sampler2D textureSampler;
8433
8433
  uniform sampler2D originalColor;
8434
8434
  uniform vec4 viewport;
8435
8435
  varying vec2 vUV;
@@ -8441,13 +8441,13 @@ vec4 sceneColor=texture2D(originalColor,vUV);
8441
8441
  gl_FragColor=sceneColor*ssaoColor;
8442
8442
  #define CUSTOM_FRAGMENT_MAIN_END
8443
8443
  }
8444
- `;U.ShadersStore[wg]=Bg;class ut extends lr{set epsilon(e){this._epsilon=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO())}get epsilon(){return this._epsilon}set samples(e){this._samples=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),this._sampleSphere=this._generateHemisphere()}get samples(){return this._samples}set textureSamples(e){this._textureSamples=e,this._prePassRenderer?this._prePassRenderer.samples=e:this._originalColorPostProcess.samples=e}get textureSamples(){return this._textureSamples}get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}set bypassBlur(e){const t=this._getDefinesForBlur(this.expensiveBlur,e),i=this._getSamplersForBlur(e);this._blurHPostProcess.updateEffect(t.h,null,i),this._blurVPostProcess.updateEffect(t.v,null,i),this._bypassBlur=e}get bypassBlur(){return this._bypassBlur}set expensiveBlur(e){const t=this._getDefinesForBlur(e,this._bypassBlur);this._blurHPostProcess.updateEffect(t.h),this._blurVPostProcess.updateEffect(t.v),this._expensiveBlur=e}get expensiveBlur(){return this._expensiveBlur}static get IsSupported(){const e=Ee.LastCreatedEngine;return e?e._features.supportSSAO2:!1}get scene(){return this._scene}constructor(e,t,i,s,r=!1,n=0){if(super(t.getEngine(),e),this.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",this.SSAORenderEffect="SSAORenderEffect",this.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",this.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",this.SSAOCombineRenderEffect="SSAOCombineRenderEffect",this.totalStrength=1,this.maxZ=100,this.minZAspect=.2,this._epsilon=.02,this._samples=8,this._textureSamples=1,this._forceGeometryBuffer=!1,this.radius=2,this.base=0,this._bypassBlur=!1,this._expensiveBlur=!0,this.bilateralSamples=16,this.bilateralSoften=0,this.bilateralTolerance=0,this._bits=new Uint32Array(1),this._scene=t,this._ratio=i,this._textureType=n,this._forceGeometryBuffer=r,!this.isSupported){F.Error("The current engine does not support SSAO 2.");return}const a=this._ratio.ssaoRatio||i,o=this._ratio.blurRatio||i;this._forceGeometryBuffer?t.enableGeometryBufferRenderer():t.enablePrePassRenderer(),this._createRandomTexture(),this._originalColorPostProcess=new xs("SSAOOriginalSceneColor",1,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),void 0,this._textureType),this._originalColorPostProcess.samples=this.textureSamples,this._createSSAOPostProcess(1,n),this._createBlurPostProcess(a,o,this._textureType),this._createSSAOCombinePostProcess(o,this._textureType),this.addEffect(new Le(t.getEngine(),this.SSAOOriginalSceneColorEffect,()=>this._originalColorPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAORenderEffect,()=>this._ssaoPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurHRenderEffect,()=>this._blurHPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurVRenderEffect,()=>this._blurVPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOCombineRenderEffect,()=>this._ssaoCombinePostProcess,!0)),t.postProcessRenderPipelineManager.addPipeline(this),s&&t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,s)}getClassName(){return"SSAO2RenderingPipeline"}dispose(e=!1){for(let t=0;t<this._scene.cameras.length;t++){const i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),super.dispose()}_rebuild(){super._rebuild()}_getSamplersForBlur(e){return e?["textureSampler"]:["textureSampler","depthSampler"]}_getDefinesForBlur(e,t){let i=`#define BLUR
8444
+ `;U.ShadersStore[Bg]=Ug;class ut extends lr{set epsilon(e){this._epsilon=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO())}get epsilon(){return this._epsilon}set samples(e){this._samples=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),this._sampleSphere=this._generateHemisphere()}get samples(){return this._samples}set textureSamples(e){this._textureSamples=e,this._prePassRenderer?this._prePassRenderer.samples=e:this._originalColorPostProcess.samples=e}get textureSamples(){return this._textureSamples}get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}set bypassBlur(e){const t=this._getDefinesForBlur(this.expensiveBlur,e),i=this._getSamplersForBlur(e);this._blurHPostProcess.updateEffect(t.h,null,i),this._blurVPostProcess.updateEffect(t.v,null,i),this._bypassBlur=e}get bypassBlur(){return this._bypassBlur}set expensiveBlur(e){const t=this._getDefinesForBlur(e,this._bypassBlur);this._blurHPostProcess.updateEffect(t.h),this._blurVPostProcess.updateEffect(t.v),this._expensiveBlur=e}get expensiveBlur(){return this._expensiveBlur}static get IsSupported(){const e=Ee.LastCreatedEngine;return e?e._features.supportSSAO2:!1}get scene(){return this._scene}constructor(e,t,i,s,r=!1,n=0){if(super(t.getEngine(),e),this.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",this.SSAORenderEffect="SSAORenderEffect",this.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",this.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",this.SSAOCombineRenderEffect="SSAOCombineRenderEffect",this.totalStrength=1,this.maxZ=100,this.minZAspect=.2,this._epsilon=.02,this._samples=8,this._textureSamples=1,this._forceGeometryBuffer=!1,this.radius=2,this.base=0,this._bypassBlur=!1,this._expensiveBlur=!0,this.bilateralSamples=16,this.bilateralSoften=0,this.bilateralTolerance=0,this._bits=new Uint32Array(1),this._scene=t,this._ratio=i,this._textureType=n,this._forceGeometryBuffer=r,!this.isSupported){F.Error("The current engine does not support SSAO 2.");return}const a=this._ratio.ssaoRatio||i,o=this._ratio.blurRatio||i;this._forceGeometryBuffer?t.enableGeometryBufferRenderer():t.enablePrePassRenderer(),this._createRandomTexture(),this._originalColorPostProcess=new xs("SSAOOriginalSceneColor",1,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),void 0,this._textureType),this._originalColorPostProcess.samples=this.textureSamples,this._createSSAOPostProcess(1,n),this._createBlurPostProcess(a,o,this._textureType),this._createSSAOCombinePostProcess(o,this._textureType),this.addEffect(new Le(t.getEngine(),this.SSAOOriginalSceneColorEffect,()=>this._originalColorPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAORenderEffect,()=>this._ssaoPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurHRenderEffect,()=>this._blurHPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurVRenderEffect,()=>this._blurVPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOCombineRenderEffect,()=>this._ssaoCombinePostProcess,!0)),t.postProcessRenderPipelineManager.addPipeline(this),s&&t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,s)}getClassName(){return"SSAO2RenderingPipeline"}dispose(e=!1){for(let t=0;t<this._scene.cameras.length;t++){const i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),super.dispose()}_rebuild(){super._rebuild()}_getSamplersForBlur(e){return e?["textureSampler"]:["textureSampler","depthSampler"]}_getDefinesForBlur(e,t){let i=`#define BLUR
8445
8445
  `;return t&&(i+=`#define BLUR_BYPASS
8446
8446
  `),e||(i+=`#define BLUR_LEGACY
8447
8447
  `),{h:i+`#define BLUR_H
8448
8448
  `,v:i}}_createBlurPostProcess(e,t,i){const s=this._getDefinesForBlur(this.expensiveBlur,this.bypassBlur),r=this._getSamplersForBlur(this.bypassBlur);this._blurHPostProcess=this._createBlurFilter("BlurH",r,e,s.h,i,!0),this._blurVPostProcess=this._createBlurFilter("BlurV",r,t,s.v,i,!1)}_createBlurFilter(e,t,i,s,r,n){const a=new ue(e,"ssao2",["outSize","samples","soften","tolerance"],t,i,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s,r);return a.onApply=o=>{if(!this._scene.activeCamera)return;const h=n?this._ssaoCombinePostProcess.width:this._ssaoCombinePostProcess.height,c=n?this._originalColorPostProcess.width:this._originalColorPostProcess.height;o.setFloat("outSize",h>0?h:c),o.setInt("samples",this.bilateralSamples),o.setFloat("soften",this.bilateralSoften),o.setFloat("tolerance",this.bilateralTolerance),this._geometryBufferRenderer?o.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[0]):this._prePassRenderer&&o.setTexture("depthSampler",this._prePassRenderer.getRenderTarget().textures[this._prePassRenderer.getIndex(5)])},a.samples=this.textureSamples,a}_radicalInverse_VdC(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(this._bits[0]&1431655765)<<1|(this._bits[0]&2863311530)>>>1>>>0,this._bits[0]=(this._bits[0]&858993459)<<2|(this._bits[0]&3435973836)>>>2>>>0,this._bits[0]=(this._bits[0]&252645135)<<4|(this._bits[0]&4042322160)>>>4>>>0,this._bits[0]=(this._bits[0]&16711935)<<8|(this._bits[0]&4278255360)>>>8>>>0,this._bits[0]*23283064365386963e-26}_hammersley(e,t){return[e/t,this._radicalInverse_VdC(e)]}_hemisphereSample_uniform(e,t){const i=t*2*Math.PI,s=1-e*.85,r=Math.sqrt(1-s*s);return new E(Math.cos(i)*r,Math.sin(i)*r,s)}_generateHemisphere(){const e=this.samples,t=[];let i,s=0;for(;s<e;){if(e<16)i=this._hemisphereSample_uniform(Math.random(),Math.random());else{const r=this._hammersley(s,e);i=this._hemisphereSample_uniform(r[0],r[1])}t.push(i.x,i.y,i.z),s++}return t}_getDefinesForSSAO(){return`#define SSAO
8449
8449
  #define SAMPLES ${this.samples}
8450
- #define EPSILON ${this.epsilon.toFixed(4)}`}_createSSAOPostProcess(e,t){this._sampleSphere=this._generateHemisphere();const i=this._getDefinesForSSAO(),s=["randomSampler","depthSampler","normalSampler"];this._ssaoPostProcess=new ue("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","texelSize","xViewport","yViewport","maxZ","minZAspect","depthProjection"],s,e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i,t),this._ssaoPostProcess.onApply=r=>{var n,a,o,h;if(this._scene.activeCamera){if(r.setArray3("sampleSphere",this._sampleSphere),r.setFloat("randTextureTiles",32),r.setFloat("samplesFactor",1/this.samples),r.setFloat("totalStrength",this.totalStrength),r.setFloat2("texelSize",1/this._ssaoPostProcess.width,1/this._ssaoPostProcess.height),r.setFloat("radius",this.radius),r.setFloat("maxZ",this.maxZ),r.setFloat("minZAspect",this.minZAspect),r.setFloat("base",this.base),r.setFloat("near",this._scene.activeCamera.minZ),this._scene.activeCamera.mode===ie.PERSPECTIVE_CAMERA)r.setMatrix3x3("depthProjection",ut.PERSPECTIVE_DEPTH_PROJECTION),r.setFloat("xViewport",Math.tan(this._scene.activeCamera.fov/2)*this._scene.getEngine().getAspectRatio(this._scene.activeCamera,!0)),r.setFloat("yViewport",Math.tan(this._scene.activeCamera.fov/2));else{const c=this._scene.getEngine().getRenderWidth()/2,u=this._scene.getEngine().getRenderHeight()/2,f=(n=this._scene.activeCamera.orthoLeft)!==null&&n!==void 0?n:-c,d=(a=this._scene.activeCamera.orthoRight)!==null&&a!==void 0?a:c,_=(o=this._scene.activeCamera.orthoBottom)!==null&&o!==void 0?o:-u,p=(h=this._scene.activeCamera.orthoTop)!==null&&h!==void 0?h:u;r.setMatrix3x3("depthProjection",ut.ORTHO_DEPTH_PROJECTION),r.setFloat("xViewport",(d-f)*.5),r.setFloat("yViewport",(p-_)*.5)}r.setMatrix("projection",this._scene.getProjectionMatrix()),this._geometryBufferRenderer?(r.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[0]),r.setTexture("normalSampler",this._geometryBufferRenderer.getGBuffer().textures[1])):this._prePassRenderer&&(r.setTexture("depthSampler",this._prePassRenderer.getRenderTarget().textures[this._prePassRenderer.getIndex(5)]),r.setTexture("normalSampler",this._prePassRenderer.getRenderTarget().textures[this._prePassRenderer.getIndex(6)])),r.setTexture("randomSampler",this._randomTexture)}},this._ssaoPostProcess.samples=this.textureSamples,this._forceGeometryBuffer||(this._ssaoPostProcess._prePassEffectConfiguration=new Lg)}_createSSAOCombinePostProcess(e,t){this._ssaoCombinePostProcess=new ue("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,void 0,t),this._ssaoCombinePostProcess.onApply=i=>{const s=this._scene.activeCamera.viewport;i.setVector4("viewport",D.Vector4[0].copyFromFloats(s.x,s.y,s.width,s.height)),i.setTextureFromPostProcessOutput("originalColor",this._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples}_createRandomTexture(){this._randomTexture=new rr("SSAORandomTexture",128,this._scene,!1,O.BILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=O.WRAP_ADDRESSMODE,this._randomTexture.wrapV=O.WRAP_ADDRESSMODE;const t=this._randomTexture.getContext(),i=(r,n)=>Math.random()*(n-r)+r,s=E.Zero();for(let r=0;r<128;r++)for(let n=0;n<128;n++)s.x=i(0,1),s.y=i(0,1),s.z=0,s.normalize(),s.scaleInPlace(255),s.x=Math.floor(s.x),s.y=Math.floor(s.y),t.fillStyle="rgb("+s.x+", "+s.y+", "+s.z+")",t.fillRect(r,n,1,1);this._randomTexture.update(!1)}serialize(){const e=J.Serialize(this);return e.customType="SSAO2RenderingPipeline",e}static Parse(e,t,i){return J.Parse(()=>new ut(e._name,t,e._ratio,void 0,e._forceGeometryBuffer,e._textureType),e,t,i)}}ut.ORTHO_DEPTH_PROJECTION=[1,0,0,0,1,0,0,0,1],ut.PERSPECTIVE_DEPTH_PROJECTION=[0,0,0,0,0,0,1,1,1],g([v()],ut.prototype,"totalStrength",void 0),g([v()],ut.prototype,"maxZ",void 0),g([v()],ut.prototype,"minZAspect",void 0),g([v("epsilon")],ut.prototype,"_epsilon",void 0),g([v("samples")],ut.prototype,"_samples",void 0),g([v("textureSamples")],ut.prototype,"_textureSamples",void 0),g([v()],ut.prototype,"_forceGeometryBuffer",void 0),g([v()],ut.prototype,"_ratio",void 0),g([v()],ut.prototype,"_textureType",void 0),g([v()],ut.prototype,"radius",void 0),g([v()],ut.prototype,"base",void 0),g([v("bypassBlur")],ut.prototype,"_bypassBlur",void 0),g([v("expensiveBlur")],ut.prototype,"_expensiveBlur",void 0),g([v()],ut.prototype,"bilateralSamples",void 0),g([v()],ut.prototype,"bilateralSoften",void 0),g([v()],ut.prototype,"bilateralTolerance",void 0),Re("BABYLON.SSAO2RenderingPipeline",ut);const Ug="ssaoPixelShader",Vg=`uniform sampler2D textureSampler;
8450
+ #define EPSILON ${this.epsilon.toFixed(4)}`}_createSSAOPostProcess(e,t){this._sampleSphere=this._generateHemisphere();const i=this._getDefinesForSSAO(),s=["randomSampler","depthSampler","normalSampler"];this._ssaoPostProcess=new ue("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","texelSize","xViewport","yViewport","maxZ","minZAspect","depthProjection"],s,e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i,t),this._ssaoPostProcess.onApply=r=>{var n,a,o,h;if(this._scene.activeCamera){if(r.setArray3("sampleSphere",this._sampleSphere),r.setFloat("randTextureTiles",32),r.setFloat("samplesFactor",1/this.samples),r.setFloat("totalStrength",this.totalStrength),r.setFloat2("texelSize",1/this._ssaoPostProcess.width,1/this._ssaoPostProcess.height),r.setFloat("radius",this.radius),r.setFloat("maxZ",this.maxZ),r.setFloat("minZAspect",this.minZAspect),r.setFloat("base",this.base),r.setFloat("near",this._scene.activeCamera.minZ),this._scene.activeCamera.mode===ie.PERSPECTIVE_CAMERA)r.setMatrix3x3("depthProjection",ut.PERSPECTIVE_DEPTH_PROJECTION),r.setFloat("xViewport",Math.tan(this._scene.activeCamera.fov/2)*this._scene.getEngine().getAspectRatio(this._scene.activeCamera,!0)),r.setFloat("yViewport",Math.tan(this._scene.activeCamera.fov/2));else{const c=this._scene.getEngine().getRenderWidth()/2,u=this._scene.getEngine().getRenderHeight()/2,f=(n=this._scene.activeCamera.orthoLeft)!==null&&n!==void 0?n:-c,d=(a=this._scene.activeCamera.orthoRight)!==null&&a!==void 0?a:c,_=(o=this._scene.activeCamera.orthoBottom)!==null&&o!==void 0?o:-u,p=(h=this._scene.activeCamera.orthoTop)!==null&&h!==void 0?h:u;r.setMatrix3x3("depthProjection",ut.ORTHO_DEPTH_PROJECTION),r.setFloat("xViewport",(d-f)*.5),r.setFloat("yViewport",(p-_)*.5)}r.setMatrix("projection",this._scene.getProjectionMatrix()),this._geometryBufferRenderer?(r.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[0]),r.setTexture("normalSampler",this._geometryBufferRenderer.getGBuffer().textures[1])):this._prePassRenderer&&(r.setTexture("depthSampler",this._prePassRenderer.getRenderTarget().textures[this._prePassRenderer.getIndex(5)]),r.setTexture("normalSampler",this._prePassRenderer.getRenderTarget().textures[this._prePassRenderer.getIndex(6)])),r.setTexture("randomSampler",this._randomTexture)}},this._ssaoPostProcess.samples=this.textureSamples,this._forceGeometryBuffer||(this._ssaoPostProcess._prePassEffectConfiguration=new Ng)}_createSSAOCombinePostProcess(e,t){this._ssaoCombinePostProcess=new ue("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,void 0,t),this._ssaoCombinePostProcess.onApply=i=>{const s=this._scene.activeCamera.viewport;i.setVector4("viewport",D.Vector4[0].copyFromFloats(s.x,s.y,s.width,s.height)),i.setTextureFromPostProcessOutput("originalColor",this._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples}_createRandomTexture(){this._randomTexture=new rr("SSAORandomTexture",128,this._scene,!1,O.BILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=O.WRAP_ADDRESSMODE,this._randomTexture.wrapV=O.WRAP_ADDRESSMODE;const t=this._randomTexture.getContext(),i=(r,n)=>Math.random()*(n-r)+r,s=E.Zero();for(let r=0;r<128;r++)for(let n=0;n<128;n++)s.x=i(0,1),s.y=i(0,1),s.z=0,s.normalize(),s.scaleInPlace(255),s.x=Math.floor(s.x),s.y=Math.floor(s.y),t.fillStyle="rgb("+s.x+", "+s.y+", "+s.z+")",t.fillRect(r,n,1,1);this._randomTexture.update(!1)}serialize(){const e=J.Serialize(this);return e.customType="SSAO2RenderingPipeline",e}static Parse(e,t,i){return J.Parse(()=>new ut(e._name,t,e._ratio,void 0,e._forceGeometryBuffer,e._textureType),e,t,i)}}ut.ORTHO_DEPTH_PROJECTION=[1,0,0,0,1,0,0,0,1],ut.PERSPECTIVE_DEPTH_PROJECTION=[0,0,0,0,0,0,1,1,1],g([v()],ut.prototype,"totalStrength",void 0),g([v()],ut.prototype,"maxZ",void 0),g([v()],ut.prototype,"minZAspect",void 0),g([v("epsilon")],ut.prototype,"_epsilon",void 0),g([v("samples")],ut.prototype,"_samples",void 0),g([v("textureSamples")],ut.prototype,"_textureSamples",void 0),g([v()],ut.prototype,"_forceGeometryBuffer",void 0),g([v()],ut.prototype,"_ratio",void 0),g([v()],ut.prototype,"_textureType",void 0),g([v()],ut.prototype,"radius",void 0),g([v()],ut.prototype,"base",void 0),g([v("bypassBlur")],ut.prototype,"_bypassBlur",void 0),g([v("expensiveBlur")],ut.prototype,"_expensiveBlur",void 0),g([v()],ut.prototype,"bilateralSamples",void 0),g([v()],ut.prototype,"bilateralSoften",void 0),g([v()],ut.prototype,"bilateralTolerance",void 0),Re("BABYLON.SSAO2RenderingPipeline",ut);const Vg="ssaoPixelShader",kg=`uniform sampler2D textureSampler;
8451
8451
  varying vec2 vUV;
8452
8452
  #ifdef SSAO
8453
8453
  uniform sampler2D randomSampler;
@@ -8499,11 +8499,11 @@ gl_FragColor.b=result;
8499
8499
  gl_FragColor.a=1.0;
8500
8500
  }
8501
8501
  #endif
8502
- `;U.ShadersStore[Ug]=Vg;class Wr extends lr{get scene(){return this._scene}constructor(e,t,i,s){super(t.getEngine(),e),this.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",this.SSAORenderEffect="SSAORenderEffect",this.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",this.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",this.SSAOCombineRenderEffect="SSAOCombineRenderEffect",this.totalStrength=1,this.radius=1e-4,this.area=.0075,this.fallOff=1e-6,this.base=.5,this._firstUpdate=!0,this._scene=t,this._createRandomTexture();const r=i.ssaoRatio||i,n=i.combineRatio||i;this._originalColorPostProcess=new xs("SSAOOriginalSceneColor",n,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),this._createSSAOPostProcess(r),this._createBlurPostProcess(r),this._createSSAOCombinePostProcess(n),this.addEffect(new Le(t.getEngine(),this.SSAOOriginalSceneColorEffect,()=>this._originalColorPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAORenderEffect,()=>this._ssaoPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurHRenderEffect,()=>this._blurHPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurVRenderEffect,()=>this._blurVPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOCombineRenderEffect,()=>this._ssaoCombinePostProcess,!0)),t.postProcessRenderPipelineManager.addPipeline(this),s&&t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,s)}_attachCameras(e,t){super._attachCameras(e,t);for(const i of this._cameras)this._scene.enableDepthRenderer(i).getDepthMap()}getClassName(){return"SSAORenderingPipeline"}dispose(e=!1){for(let t=0;t<this._scene.cameras.length;t++){const i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),super.dispose()}_createBlurPostProcess(e){this._blurHPostProcess=new gt("BlurH",new ae(1,0),16,e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,0),this._blurVPostProcess=new gt("BlurV",new ae(0,1),16,e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,0),this._blurHPostProcess.onActivateObservable.add(()=>{const i=this._blurHPostProcess.width/this._scene.getEngine().getRenderWidth();this._blurHPostProcess.kernel=16*i}),this._blurVPostProcess.onActivateObservable.add(()=>{const i=this._blurVPostProcess.height/this._scene.getEngine().getRenderHeight();this._blurVPostProcess.kernel=16*i})}_rebuild(){this._firstUpdate=!0,super._rebuild()}_createSSAOPostProcess(e){const i=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271],s=1/16;this._ssaoPostProcess=new ue("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,`#define SAMPLES 16
8503
- #define SSAO`),this._ssaoPostProcess.externalTextureSamplerBinding=!0,this._ssaoPostProcess.onApply=r=>{this._firstUpdate&&(r.setArray3("sampleSphere",i),r.setFloat("samplesFactor",s),r.setFloat("randTextureTiles",4)),r.setFloat("totalStrength",this.totalStrength),r.setFloat("radius",this.radius),r.setFloat("area",this.area),r.setFloat("fallOff",this.fallOff),r.setFloat("base",this.base),r.setTexture("textureSampler",this._scene.enableDepthRenderer(this._scene.activeCamera).getDepthMap()),r.setTexture("randomSampler",this._randomTexture)}}_createSSAOCombinePostProcess(e){this._ssaoCombinePostProcess=new ue("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=t=>{t.setVector4("viewport",D.Vector4[0].copyFromFloats(0,0,1,1)),t.setTextureFromPostProcess("originalColor",this._originalColorPostProcess)}}_createRandomTexture(){this._randomTexture=new rr("SSAORandomTexture",512,this._scene,!1,O.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=O.WRAP_ADDRESSMODE,this._randomTexture.wrapV=O.WRAP_ADDRESSMODE;const t=this._randomTexture.getContext(),i=(r,n)=>Math.random()*(n-r)+r,s=E.Zero();for(let r=0;r<512;r++)for(let n=0;n<512;n++)s.x=Math.floor(Math.max(0,i(-1,1))*255),s.y=Math.floor(Math.max(0,i(-1,1))*255),s.z=Math.floor(Math.max(0,i(-1,1))*255),t.fillStyle="rgb("+s.x+", "+s.y+", "+s.z+")",t.fillRect(r,n,1,1);this._randomTexture.update(!1)}}g([v()],Wr.prototype,"totalStrength",void 0),g([v()],Wr.prototype,"radius",void 0),g([v()],Wr.prototype,"area",void 0),g([v()],Wr.prototype,"fallOff",void 0),g([v()],Wr.prototype,"base",void 0),re.prototype.restoreSingleAttachment=function(){const l=this._gl;this.bindAttachments([l.BACK])},re.prototype.restoreSingleAttachmentForRenderTarget=function(){const l=this._gl;this.bindAttachments([l.COLOR_ATTACHMENT0])},re.prototype.buildTextureLayout=function(l){const e=this._gl,t=[];for(let i=0;i<l.length;i++)l[i]?t.push(e["COLOR_ATTACHMENT"+i]):t.push(e.NONE);return t},re.prototype.bindAttachments=function(l){this._gl.drawBuffers(l)},re.prototype.unBindMultiColorAttachmentFramebuffer=function(l,e=!1,t){this._currentRenderTarget=null;const i=this._gl,s=l._attachments,r=s.length;if(l._MSAAFramebuffer){i.bindFramebuffer(i.READ_FRAMEBUFFER,l._MSAAFramebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,l._framebuffer);for(let n=0;n<r;n++){const a=l.textures[n];for(let o=0;o<r;o++)s[o]=i.NONE;s[n]=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+n:"COLOR_ATTACHMENT"+n+"_WEBGL"],i.readBuffer(s[n]),i.drawBuffers(s),i.blitFramebuffer(0,0,a.width,a.height,0,0,a.width,a.height,i.COLOR_BUFFER_BIT,i.NEAREST)}for(let n=0;n<r;n++)s[n]=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+n:"COLOR_ATTACHMENT"+n+"_WEBGL"];i.drawBuffers(s)}for(let n=0;n<r;n++){const a=l.textures[n];a!=null&&a.generateMipMaps&&!e&&!a.isCube&&(this._bindTextureDirectly(i.TEXTURE_2D,a,!0),i.generateMipmap(i.TEXTURE_2D),this._bindTextureDirectly(i.TEXTURE_2D,null))}t&&(l._MSAAFramebuffer&&this._bindUnboundFramebuffer(l._framebuffer),t()),this._bindUnboundFramebuffer(null)},re.prototype.createMultipleRenderTarget=function(l,e,t=!0){var i;let s=!1,r=!0,n=!1,a=!1,o=15,h=1;const c=0,u=3,f=!1,d=5,_=3553;let p=new Array,m=new Array,T=new Array,S=new Array,x=new Array,b=new Array,I=new Array,R=new Array;const C=this._createHardwareRenderTargetWrapper(!0,!1,l);e!==void 0&&(s=e.generateMipMaps===void 0?!1:e.generateMipMaps,r=e.generateDepthBuffer===void 0?!0:e.generateDepthBuffer,n=e.generateStencilBuffer===void 0?!1:e.generateStencilBuffer,a=e.generateDepthTexture===void 0?!1:e.generateDepthTexture,h=e.textureCount||1,e.types&&(p=e.types),e.samplingModes&&(m=e.samplingModes),e.useSRGBBuffers&&(T=e.useSRGBBuffers),e.formats&&(S=e.formats),e.targetTypes&&(x=e.targetTypes),e.faceIndex&&(b=e.faceIndex),e.layerIndex&&(I=e.layerIndex),e.layerCounts&&(R=e.layerCounts),this.webGLVersion>1&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===16||e.depthTextureFormat===14||e.depthTextureFormat===18)&&(o=e.depthTextureFormat));const y=this._gl,w=y.createFramebuffer();this._bindUnboundFramebuffer(w);const G=l.width||l,te=l.height||l,Q=[],Te=[],he=this.webGLVersion>1&&a&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===18),ve=this._setupFramebufferDepthAttachments(!he&&n,!a&&r,G,te);C._framebuffer=w,C._depthStencilBuffer=ve,C._generateDepthBuffer=!a&&r,C._generateStencilBuffer=!he&&n,C._attachments=Te;for(let le=0;le<h;le++){let be=m[le]||u,ye=p[le]||c,Ye=T[le]||f;const et=S[le]||d,Ne=x[le]||_,pt=(i=R[le])!==null&&i!==void 0?i:1;(ye===1&&!this._caps.textureFloatLinearFiltering||ye===2&&!this._caps.textureHalfFloatLinearFiltering)&&(be=1);const Si=this._getSamplingParameters(be,s);ye===1&&!this._caps.textureFloat&&(ye=0,F.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),Ye=Ye&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU);const Os=this.webGLVersion>1,ur=y[Os?"COLOR_ATTACHMENT"+le:"COLOR_ATTACHMENT"+le+"_WEBGL"];if(Te.push(ur),Ne===-1)continue;const ot=new ht(this,Fe.MultiRenderTarget);Q[le]=ot,y.activeTexture(y["TEXTURE"+le]),y.bindTexture(Ne,ot._hardwareTexture.underlyingResource),y.texParameteri(Ne,y.TEXTURE_MAG_FILTER,Si.mag),y.texParameteri(Ne,y.TEXTURE_MIN_FILTER,Si.min),y.texParameteri(Ne,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(Ne,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE);const Ds=this._getRGBABufferInternalSizedFormat(ye,et,Ye),Ls=this._getInternalFormat(et),Ns=this._getWebGLTextureType(ye);if(Os&&(Ne===35866||Ne===32879))Ne===35866?ot.is2DArray=!0:ot.is3D=!0,ot.baseDepth=ot.depth=pt,y.texImage3D(Ne,0,Ds,G,te,pt,0,Ls,Ns,null);else if(Ne===34067){for(let Fs=0;Fs<6;Fs++)y.texImage2D(y.TEXTURE_CUBE_MAP_POSITIVE_X+Fs,0,Ds,G,te,0,Ls,Ns,null);ot.isCube=!0}else y.texImage2D(y.TEXTURE_2D,0,Ds,G,te,0,Ls,Ns,null);s&&y.generateMipmap(Ne),this._bindTextureDirectly(Ne,null),ot.baseWidth=G,ot.baseHeight=te,ot.width=G,ot.height=te,ot.isReady=!0,ot.samples=1,ot.generateMipMaps=s,ot.samplingMode=be,ot.type=ye,ot._useSRGBBuffer=Ye,ot.format=et,this._internalTexturesCache.push(ot)}if(a&&this._caps.depthTextureExtension){const le=new ht(this,Fe.Depth);let be=5,ye=y.DEPTH_COMPONENT16,Ye=y.DEPTH_COMPONENT,et=y.UNSIGNED_SHORT,Ne=y.DEPTH_ATTACHMENT;this.webGLVersion<2?ye=y.DEPTH_COMPONENT:o===14?(be=1,et=y.FLOAT,ye=y.DEPTH_COMPONENT32F):o===18?(be=0,et=y.FLOAT_32_UNSIGNED_INT_24_8_REV,ye=y.DEPTH32F_STENCIL8,Ye=y.DEPTH_STENCIL,Ne=y.DEPTH_STENCIL_ATTACHMENT):o===16?(be=0,et=y.UNSIGNED_INT,ye=y.DEPTH_COMPONENT24,Ne=y.DEPTH_ATTACHMENT):(o===13||o===17)&&(be=12,et=y.UNSIGNED_INT_24_8,ye=y.DEPTH24_STENCIL8,Ye=y.DEPTH_STENCIL,Ne=y.DEPTH_STENCIL_ATTACHMENT),y.activeTexture(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,le._hardwareTexture.underlyingResource),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texImage2D(y.TEXTURE_2D,0,ye,G,te,0,Ye,et,null),y.framebufferTexture2D(y.FRAMEBUFFER,Ne,y.TEXTURE_2D,le._hardwareTexture.underlyingResource,0),le.baseWidth=G,le.baseHeight=te,le.width=G,le.height=te,le.isReady=!0,le.samples=1,le.generateMipMaps=s,le.samplingMode=1,le.format=o,le.type=be,Q[h]=le,this._internalTexturesCache.push(le)}return C.setTextures(Q),t&&y.drawBuffers(Te),this._bindUnboundFramebuffer(null),C.setLayerAndFaceIndices(I,b),this.resetTextureCache(),C},re.prototype.updateMultipleRenderTargetTextureSampleCount=function(l,e,t=!0){if(this.webGLVersion<2||!l||!l.texture)return 1;if(l.samples===e)return e;const i=l._attachments.length;if(i===0)return 1;const s=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples);const r=!!l._depthStencilBuffer;if(r&&(s.deleteRenderbuffer(l._depthStencilBuffer),l._depthStencilBuffer=null),l._MSAAFramebuffer&&(s.deleteFramebuffer(l._MSAAFramebuffer),l._MSAAFramebuffer=null),e>1&&typeof s.renderbufferStorageMultisample=="function"){const n=s.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");l._MSAAFramebuffer=n,this._bindUnboundFramebuffer(n);const a=[];for(let o=0;o<i;o++)l.textures[o]._hardwareTexture.releaseMSAARenderBuffers();for(let o=0;o<i;o++){const h=l.textures[o],c=h._hardwareTexture,u=s[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],f=this._createRenderBuffer(h.width,h.height,e,-1,this._getRGBAMultiSampleBufferFormat(h.type,h.format),u);if(!f)throw new Error("Unable to create multi sampled framebuffer");c.addMSAARenderBuffer(f),h.samples=e,a.push(u)}t&&s.drawBuffers(a)}else this._bindUnboundFramebuffer(l._framebuffer);return r&&(l._depthStencilBuffer=this._setupFramebufferDepthAttachments(l._generateStencilBuffer,l._generateDepthBuffer,l.texture.width,l.texture.height,e)),this._bindUnboundFramebuffer(null),e};class kg extends Dt{get isSupported(){var e,t;return(t=(e=this._engine)===null||e===void 0?void 0:e.getCaps().drawBuffersExtension)!==null&&t!==void 0?t:!1}get textures(){return this._textures}get count(){return this._count}get depthTexture(){return this._textures[this._textures.length-1]}set wrapU(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapU=e}set wrapV(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapV=e}constructor(e,t,i,s,r,n){const a=r&&r.generateMipMaps?r.generateMipMaps:!1,o=r&&r.generateDepthTexture?r.generateDepthTexture:!1,h=r&&r.depthTextureFormat?r.depthTextureFormat:15,c=!r||r.doNotChangeAspectRatio===void 0?!0:r.doNotChangeAspectRatio,u=r&&r.drawOnlyOnFirstAttachmentByDefault?r.drawOnlyOnFirstAttachmentByDefault:!1;if(super(e,t,s,a,c,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0),!this.isSupported){this.dispose();return}this._textureNames=n;const f=[],d=[],_=[],p=[],m=[],T=[],S=[],x=[];this._initTypes(i,f,d,_,p,m,T,S,x,r);const b=!r||r.generateDepthBuffer===void 0?!0:r.generateDepthBuffer,I=!r||r.generateStencilBuffer===void 0?!1:r.generateStencilBuffer;this._multiRenderTargetOptions={samplingModes:d,generateMipMaps:a,generateDepthBuffer:b,generateStencilBuffer:I,generateDepthTexture:o,depthTextureFormat:h,types:f,textureCount:i,useSRGBBuffers:_,formats:p,targetTypes:m,faceIndex:T,layerIndex:S,layerCounts:x},this._count=i,this._drawOnlyOnFirstAttachmentByDefault=u,i>0&&(this._createInternalTextures(),this._createTextures(n))}_initTypes(e,t,i,s,r,n,a,o,h,c){for(let u=0;u<e;u++)c&&c.types&&c.types[u]!==void 0?t.push(c.types[u]):t.push(c&&c.defaultType?c.defaultType:0),c&&c.samplingModes&&c.samplingModes[u]!==void 0?i.push(c.samplingModes[u]):i.push(O.BILINEAR_SAMPLINGMODE),c&&c.useSRGBBuffers&&c.useSRGBBuffers[u]!==void 0?s.push(c.useSRGBBuffers[u]):s.push(!1),c&&c.formats&&c.formats[u]!==void 0?r.push(c.formats[u]):r.push(5),c&&c.targetTypes&&c.targetTypes[u]!==void 0?n.push(c.targetTypes[u]):n.push(3553),c&&c.faceIndex&&c.faceIndex[u]!==void 0?a.push(c.faceIndex[u]):a.push(0),c&&c.layerIndex&&c.layerIndex[u]!==void 0?o.push(c.layerIndex[u]):o.push(0),c&&c.layerCounts&&c.layerCounts[u]!==void 0?h.push(c.layerCounts[u]):h.push(1)}_createInternaTextureIndexMapping(){const e={},t=[];if(!this._renderTarget)return t;const i=this._renderTarget.textures;for(let s=0;s<i.length;s++){const r=i[s];if(!r)continue;const n=e[r.uniqueId];n!==void 0?t[s]=n:e[r.uniqueId]=s}return t}_rebuild(e=!1,t){if(this._count<1)return;const i=this._createInternaTextureIndexMapping();this.releaseInternalTextures(),this._createInternalTextures(),e&&(this._releaseTextures(),this._createTextures(t));const s=this._renderTarget.textures;for(let r=0;r<s.length;r++){const n=this._textures[r];i[r]!==void 0&&this._renderTarget.setTexture(s[i[r]],r),n._texture=s[r],n._texture&&(n._noMipmap=!n._texture.useMipMaps,n._useSRGBBuffer=n._texture._useSRGBBuffer)}this.samples!==1&&this._renderTarget.setSamples(this.samples,!this._drawOnlyOnFirstAttachmentByDefault,!0)}_createInternalTextures(){this._renderTarget=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions,!this._drawOnlyOnFirstAttachmentByDefault),this._texture=this._renderTarget.texture}_releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;e++)this._textures[e]._texture=null,this._textures[e].dispose()}_createTextures(e){const t=this._renderTarget.textures;this._textures=[];for(let i=0;i<t.length;i++){const s=new O(null,this.getScene());e!=null&&e[i]&&(s.name=e[i]),s._texture=t[i],s._texture&&(s._noMipmap=!s._texture.useMipMaps,s._useSRGBBuffer=s._texture._useSRGBBuffer),this._textures.push(s)}}setInternalTexture(e,t,i=!0){var s,r;if(this.renderTarget&&(t===0&&(this._texture=e),this.renderTarget.setTexture(e,t,i),this.textures[t]||(this.textures[t]=new O(null,this.getScene()),this.textures[t].name=(r=(s=this._textureNames)===null||s===void 0?void 0:s[t])!==null&&r!==void 0?r:this.textures[t].name),this.textures[t]._texture=e,this.textures[t]._noMipmap=!e.useMipMaps,this.textures[t]._useSRGBBuffer=e._useSRGBBuffer,this._count=this.renderTarget.textures?this.renderTarget.textures.length:0,this._multiRenderTargetOptions.types&&(this._multiRenderTargetOptions.types[t]=e.type),this._multiRenderTargetOptions.samplingModes&&(this._multiRenderTargetOptions.samplingModes[t]=e.samplingMode),this._multiRenderTargetOptions.useSRGBBuffers&&(this._multiRenderTargetOptions.useSRGBBuffers[t]=e._useSRGBBuffer),this._multiRenderTargetOptions.targetTypes&&this._multiRenderTargetOptions.targetTypes[t]!==-1)){let n=0;e.is2DArray?n=35866:e.isCube?n=34067:e.is3D?n=32879:n=3553,this._multiRenderTargetOptions.targetTypes[t]=n}}setLayerAndFaceIndex(e,t=-1,i=-1){!this.textures[e]||!this.renderTarget||(this._multiRenderTargetOptions.layerIndex&&(this._multiRenderTargetOptions.layerIndex[e]=t),this._multiRenderTargetOptions.faceIndex&&(this._multiRenderTargetOptions.faceIndex[e]=i),this.renderTarget.setLayerAndFaceIndex(e,t,i))}setLayerAndFaceIndices(e,t){this.renderTarget&&(this._multiRenderTargetOptions.layerIndex=e,this._multiRenderTargetOptions.faceIndex=t,this.renderTarget.setLayerAndFaceIndices(e,t))}get samples(){return this._samples}set samples(e){this._renderTarget?this._samples=this._renderTarget.setSamples(e):this._samples=e}resize(e){this._processSizeParameter(e,!1),this._rebuild(void 0,this._textureNames)}updateCount(e,t,i){this._multiRenderTargetOptions.textureCount=e,this._count=e;const s=[],r=[],n=[],a=[],o=[],h=[],c=[],u=[];this._textureNames=i,this._initTypes(e,s,r,n,a,o,h,c,u,t),this._multiRenderTargetOptions.types=s,this._multiRenderTargetOptions.samplingModes=r,this._multiRenderTargetOptions.useSRGBBuffers=n,this._multiRenderTargetOptions.formats=a,this._multiRenderTargetOptions.targetTypes=o,this._multiRenderTargetOptions.faceIndex=h,this._multiRenderTargetOptions.layerIndex=c,this._multiRenderTargetOptions.layerCounts=u,this._rebuild(!0,i)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindMultiColorAttachmentFramebuffer(this._renderTarget,this.isCube,()=>{this.onAfterRenderObservable.notifyObservers(t)})}dispose(e=!1){this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),super.dispose()}releaseInternalTextures(){var e,t;const i=(e=this._renderTarget)===null||e===void 0?void 0:e.textures;if(i){for(let s=i.length-1;s>=0;s--)this._textures[s]._texture=null;(t=this._renderTarget)===null||t===void 0||t.dispose(),this._renderTarget=null}}}const Gg="mrtFragmentDeclaration",Hg=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
8502
+ `;U.ShadersStore[Vg]=kg;class Wr extends lr{get scene(){return this._scene}constructor(e,t,i,s){super(t.getEngine(),e),this.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",this.SSAORenderEffect="SSAORenderEffect",this.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",this.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",this.SSAOCombineRenderEffect="SSAOCombineRenderEffect",this.totalStrength=1,this.radius=1e-4,this.area=.0075,this.fallOff=1e-6,this.base=.5,this._firstUpdate=!0,this._scene=t,this._createRandomTexture();const r=i.ssaoRatio||i,n=i.combineRatio||i;this._originalColorPostProcess=new xs("SSAOOriginalSceneColor",n,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),this._createSSAOPostProcess(r),this._createBlurPostProcess(r),this._createSSAOCombinePostProcess(n),this.addEffect(new Le(t.getEngine(),this.SSAOOriginalSceneColorEffect,()=>this._originalColorPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAORenderEffect,()=>this._ssaoPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurHRenderEffect,()=>this._blurHPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOBlurVRenderEffect,()=>this._blurVPostProcess,!0)),this.addEffect(new Le(t.getEngine(),this.SSAOCombineRenderEffect,()=>this._ssaoCombinePostProcess,!0)),t.postProcessRenderPipelineManager.addPipeline(this),s&&t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,s)}_attachCameras(e,t){super._attachCameras(e,t);for(const i of this._cameras)this._scene.enableDepthRenderer(i).getDepthMap()}getClassName(){return"SSAORenderingPipeline"}dispose(e=!1){for(let t=0;t<this._scene.cameras.length;t++){const i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),super.dispose()}_createBlurPostProcess(e){this._blurHPostProcess=new gt("BlurH",new ae(1,0),16,e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,0),this._blurVPostProcess=new gt("BlurV",new ae(0,1),16,e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,0),this._blurHPostProcess.onActivateObservable.add(()=>{const i=this._blurHPostProcess.width/this._scene.getEngine().getRenderWidth();this._blurHPostProcess.kernel=16*i}),this._blurVPostProcess.onActivateObservable.add(()=>{const i=this._blurVPostProcess.height/this._scene.getEngine().getRenderHeight();this._blurVPostProcess.kernel=16*i})}_rebuild(){this._firstUpdate=!0,super._rebuild()}_createSSAOPostProcess(e){const i=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271],s=1/16;this._ssaoPostProcess=new ue("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,`#define SAMPLES 16
8503
+ #define SSAO`),this._ssaoPostProcess.externalTextureSamplerBinding=!0,this._ssaoPostProcess.onApply=r=>{this._firstUpdate&&(r.setArray3("sampleSphere",i),r.setFloat("samplesFactor",s),r.setFloat("randTextureTiles",4)),r.setFloat("totalStrength",this.totalStrength),r.setFloat("radius",this.radius),r.setFloat("area",this.area),r.setFloat("fallOff",this.fallOff),r.setFloat("base",this.base),r.setTexture("textureSampler",this._scene.enableDepthRenderer(this._scene.activeCamera).getDepthMap()),r.setTexture("randomSampler",this._randomTexture)}}_createSSAOCombinePostProcess(e){this._ssaoCombinePostProcess=new ue("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,O.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=t=>{t.setVector4("viewport",D.Vector4[0].copyFromFloats(0,0,1,1)),t.setTextureFromPostProcess("originalColor",this._originalColorPostProcess)}}_createRandomTexture(){this._randomTexture=new rr("SSAORandomTexture",512,this._scene,!1,O.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=O.WRAP_ADDRESSMODE,this._randomTexture.wrapV=O.WRAP_ADDRESSMODE;const t=this._randomTexture.getContext(),i=(r,n)=>Math.random()*(n-r)+r,s=E.Zero();for(let r=0;r<512;r++)for(let n=0;n<512;n++)s.x=Math.floor(Math.max(0,i(-1,1))*255),s.y=Math.floor(Math.max(0,i(-1,1))*255),s.z=Math.floor(Math.max(0,i(-1,1))*255),t.fillStyle="rgb("+s.x+", "+s.y+", "+s.z+")",t.fillRect(r,n,1,1);this._randomTexture.update(!1)}}g([v()],Wr.prototype,"totalStrength",void 0),g([v()],Wr.prototype,"radius",void 0),g([v()],Wr.prototype,"area",void 0),g([v()],Wr.prototype,"fallOff",void 0),g([v()],Wr.prototype,"base",void 0),re.prototype.restoreSingleAttachment=function(){const l=this._gl;this.bindAttachments([l.BACK])},re.prototype.restoreSingleAttachmentForRenderTarget=function(){const l=this._gl;this.bindAttachments([l.COLOR_ATTACHMENT0])},re.prototype.buildTextureLayout=function(l){const e=this._gl,t=[];for(let i=0;i<l.length;i++)l[i]?t.push(e["COLOR_ATTACHMENT"+i]):t.push(e.NONE);return t},re.prototype.bindAttachments=function(l){this._gl.drawBuffers(l)},re.prototype.unBindMultiColorAttachmentFramebuffer=function(l,e=!1,t){this._currentRenderTarget=null;const i=this._gl,s=l._attachments,r=s.length;if(l._MSAAFramebuffer){i.bindFramebuffer(i.READ_FRAMEBUFFER,l._MSAAFramebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,l._framebuffer);for(let n=0;n<r;n++){const a=l.textures[n];for(let o=0;o<r;o++)s[o]=i.NONE;s[n]=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+n:"COLOR_ATTACHMENT"+n+"_WEBGL"],i.readBuffer(s[n]),i.drawBuffers(s),i.blitFramebuffer(0,0,a.width,a.height,0,0,a.width,a.height,i.COLOR_BUFFER_BIT,i.NEAREST)}for(let n=0;n<r;n++)s[n]=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+n:"COLOR_ATTACHMENT"+n+"_WEBGL"];i.drawBuffers(s)}for(let n=0;n<r;n++){const a=l.textures[n];a!=null&&a.generateMipMaps&&!e&&!a.isCube&&(this._bindTextureDirectly(i.TEXTURE_2D,a,!0),i.generateMipmap(i.TEXTURE_2D),this._bindTextureDirectly(i.TEXTURE_2D,null))}t&&(l._MSAAFramebuffer&&this._bindUnboundFramebuffer(l._framebuffer),t()),this._bindUnboundFramebuffer(null)},re.prototype.createMultipleRenderTarget=function(l,e,t=!0){var i;let s=!1,r=!0,n=!1,a=!1,o=15,h=1;const c=0,u=3,f=!1,d=5,_=3553;let p=new Array,m=new Array,T=new Array,S=new Array,x=new Array,b=new Array,I=new Array,R=new Array;const C=this._createHardwareRenderTargetWrapper(!0,!1,l);e!==void 0&&(s=e.generateMipMaps===void 0?!1:e.generateMipMaps,r=e.generateDepthBuffer===void 0?!0:e.generateDepthBuffer,n=e.generateStencilBuffer===void 0?!1:e.generateStencilBuffer,a=e.generateDepthTexture===void 0?!1:e.generateDepthTexture,h=e.textureCount||1,e.types&&(p=e.types),e.samplingModes&&(m=e.samplingModes),e.useSRGBBuffers&&(T=e.useSRGBBuffers),e.formats&&(S=e.formats),e.targetTypes&&(x=e.targetTypes),e.faceIndex&&(b=e.faceIndex),e.layerIndex&&(I=e.layerIndex),e.layerCounts&&(R=e.layerCounts),this.webGLVersion>1&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===16||e.depthTextureFormat===14||e.depthTextureFormat===18)&&(o=e.depthTextureFormat));const y=this._gl,w=y.createFramebuffer();this._bindUnboundFramebuffer(w);const G=l.width||l,te=l.height||l,Q=[],Te=[],he=this.webGLVersion>1&&a&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===18),ve=this._setupFramebufferDepthAttachments(!he&&n,!a&&r,G,te);C._framebuffer=w,C._depthStencilBuffer=ve,C._generateDepthBuffer=!a&&r,C._generateStencilBuffer=!he&&n,C._attachments=Te;for(let le=0;le<h;le++){let be=m[le]||u,ye=p[le]||c,Ye=T[le]||f;const et=S[le]||d,Ne=x[le]||_,pt=(i=R[le])!==null&&i!==void 0?i:1;(ye===1&&!this._caps.textureFloatLinearFiltering||ye===2&&!this._caps.textureHalfFloatLinearFiltering)&&(be=1);const Si=this._getSamplingParameters(be,s);ye===1&&!this._caps.textureFloat&&(ye=0,F.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),Ye=Ye&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU);const Os=this.webGLVersion>1,ur=y[Os?"COLOR_ATTACHMENT"+le:"COLOR_ATTACHMENT"+le+"_WEBGL"];if(Te.push(ur),Ne===-1)continue;const ot=new ht(this,Fe.MultiRenderTarget);Q[le]=ot,y.activeTexture(y["TEXTURE"+le]),y.bindTexture(Ne,ot._hardwareTexture.underlyingResource),y.texParameteri(Ne,y.TEXTURE_MAG_FILTER,Si.mag),y.texParameteri(Ne,y.TEXTURE_MIN_FILTER,Si.min),y.texParameteri(Ne,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(Ne,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE);const Ds=this._getRGBABufferInternalSizedFormat(ye,et,Ye),Ls=this._getInternalFormat(et),Ns=this._getWebGLTextureType(ye);if(Os&&(Ne===35866||Ne===32879))Ne===35866?ot.is2DArray=!0:ot.is3D=!0,ot.baseDepth=ot.depth=pt,y.texImage3D(Ne,0,Ds,G,te,pt,0,Ls,Ns,null);else if(Ne===34067){for(let Fs=0;Fs<6;Fs++)y.texImage2D(y.TEXTURE_CUBE_MAP_POSITIVE_X+Fs,0,Ds,G,te,0,Ls,Ns,null);ot.isCube=!0}else y.texImage2D(y.TEXTURE_2D,0,Ds,G,te,0,Ls,Ns,null);s&&y.generateMipmap(Ne),this._bindTextureDirectly(Ne,null),ot.baseWidth=G,ot.baseHeight=te,ot.width=G,ot.height=te,ot.isReady=!0,ot.samples=1,ot.generateMipMaps=s,ot.samplingMode=be,ot.type=ye,ot._useSRGBBuffer=Ye,ot.format=et,this._internalTexturesCache.push(ot)}if(a&&this._caps.depthTextureExtension){const le=new ht(this,Fe.Depth);let be=5,ye=y.DEPTH_COMPONENT16,Ye=y.DEPTH_COMPONENT,et=y.UNSIGNED_SHORT,Ne=y.DEPTH_ATTACHMENT;this.webGLVersion<2?ye=y.DEPTH_COMPONENT:o===14?(be=1,et=y.FLOAT,ye=y.DEPTH_COMPONENT32F):o===18?(be=0,et=y.FLOAT_32_UNSIGNED_INT_24_8_REV,ye=y.DEPTH32F_STENCIL8,Ye=y.DEPTH_STENCIL,Ne=y.DEPTH_STENCIL_ATTACHMENT):o===16?(be=0,et=y.UNSIGNED_INT,ye=y.DEPTH_COMPONENT24,Ne=y.DEPTH_ATTACHMENT):(o===13||o===17)&&(be=12,et=y.UNSIGNED_INT_24_8,ye=y.DEPTH24_STENCIL8,Ye=y.DEPTH_STENCIL,Ne=y.DEPTH_STENCIL_ATTACHMENT),y.activeTexture(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,le._hardwareTexture.underlyingResource),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texImage2D(y.TEXTURE_2D,0,ye,G,te,0,Ye,et,null),y.framebufferTexture2D(y.FRAMEBUFFER,Ne,y.TEXTURE_2D,le._hardwareTexture.underlyingResource,0),le.baseWidth=G,le.baseHeight=te,le.width=G,le.height=te,le.isReady=!0,le.samples=1,le.generateMipMaps=s,le.samplingMode=1,le.format=o,le.type=be,Q[h]=le,this._internalTexturesCache.push(le)}return C.setTextures(Q),t&&y.drawBuffers(Te),this._bindUnboundFramebuffer(null),C.setLayerAndFaceIndices(I,b),this.resetTextureCache(),C},re.prototype.updateMultipleRenderTargetTextureSampleCount=function(l,e,t=!0){if(this.webGLVersion<2||!l||!l.texture)return 1;if(l.samples===e)return e;const i=l._attachments.length;if(i===0)return 1;const s=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples);const r=!!l._depthStencilBuffer;if(r&&(s.deleteRenderbuffer(l._depthStencilBuffer),l._depthStencilBuffer=null),l._MSAAFramebuffer&&(s.deleteFramebuffer(l._MSAAFramebuffer),l._MSAAFramebuffer=null),e>1&&typeof s.renderbufferStorageMultisample=="function"){const n=s.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");l._MSAAFramebuffer=n,this._bindUnboundFramebuffer(n);const a=[];for(let o=0;o<i;o++)l.textures[o]._hardwareTexture.releaseMSAARenderBuffers();for(let o=0;o<i;o++){const h=l.textures[o],c=h._hardwareTexture,u=s[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],f=this._createRenderBuffer(h.width,h.height,e,-1,this._getRGBAMultiSampleBufferFormat(h.type,h.format),u);if(!f)throw new Error("Unable to create multi sampled framebuffer");c.addMSAARenderBuffer(f),h.samples=e,a.push(u)}t&&s.drawBuffers(a)}else this._bindUnboundFramebuffer(l._framebuffer);return r&&(l._depthStencilBuffer=this._setupFramebufferDepthAttachments(l._generateStencilBuffer,l._generateDepthBuffer,l.texture.width,l.texture.height,e)),this._bindUnboundFramebuffer(null),e};class Gg extends Dt{get isSupported(){var e,t;return(t=(e=this._engine)===null||e===void 0?void 0:e.getCaps().drawBuffersExtension)!==null&&t!==void 0?t:!1}get textures(){return this._textures}get count(){return this._count}get depthTexture(){return this._textures[this._textures.length-1]}set wrapU(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapU=e}set wrapV(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapV=e}constructor(e,t,i,s,r,n){const a=r&&r.generateMipMaps?r.generateMipMaps:!1,o=r&&r.generateDepthTexture?r.generateDepthTexture:!1,h=r&&r.depthTextureFormat?r.depthTextureFormat:15,c=!r||r.doNotChangeAspectRatio===void 0?!0:r.doNotChangeAspectRatio,u=r&&r.drawOnlyOnFirstAttachmentByDefault?r.drawOnlyOnFirstAttachmentByDefault:!1;if(super(e,t,s,a,c,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0),!this.isSupported){this.dispose();return}this._textureNames=n;const f=[],d=[],_=[],p=[],m=[],T=[],S=[],x=[];this._initTypes(i,f,d,_,p,m,T,S,x,r);const b=!r||r.generateDepthBuffer===void 0?!0:r.generateDepthBuffer,I=!r||r.generateStencilBuffer===void 0?!1:r.generateStencilBuffer;this._multiRenderTargetOptions={samplingModes:d,generateMipMaps:a,generateDepthBuffer:b,generateStencilBuffer:I,generateDepthTexture:o,depthTextureFormat:h,types:f,textureCount:i,useSRGBBuffers:_,formats:p,targetTypes:m,faceIndex:T,layerIndex:S,layerCounts:x},this._count=i,this._drawOnlyOnFirstAttachmentByDefault=u,i>0&&(this._createInternalTextures(),this._createTextures(n))}_initTypes(e,t,i,s,r,n,a,o,h,c){for(let u=0;u<e;u++)c&&c.types&&c.types[u]!==void 0?t.push(c.types[u]):t.push(c&&c.defaultType?c.defaultType:0),c&&c.samplingModes&&c.samplingModes[u]!==void 0?i.push(c.samplingModes[u]):i.push(O.BILINEAR_SAMPLINGMODE),c&&c.useSRGBBuffers&&c.useSRGBBuffers[u]!==void 0?s.push(c.useSRGBBuffers[u]):s.push(!1),c&&c.formats&&c.formats[u]!==void 0?r.push(c.formats[u]):r.push(5),c&&c.targetTypes&&c.targetTypes[u]!==void 0?n.push(c.targetTypes[u]):n.push(3553),c&&c.faceIndex&&c.faceIndex[u]!==void 0?a.push(c.faceIndex[u]):a.push(0),c&&c.layerIndex&&c.layerIndex[u]!==void 0?o.push(c.layerIndex[u]):o.push(0),c&&c.layerCounts&&c.layerCounts[u]!==void 0?h.push(c.layerCounts[u]):h.push(1)}_createInternaTextureIndexMapping(){const e={},t=[];if(!this._renderTarget)return t;const i=this._renderTarget.textures;for(let s=0;s<i.length;s++){const r=i[s];if(!r)continue;const n=e[r.uniqueId];n!==void 0?t[s]=n:e[r.uniqueId]=s}return t}_rebuild(e=!1,t){if(this._count<1)return;const i=this._createInternaTextureIndexMapping();this.releaseInternalTextures(),this._createInternalTextures(),e&&(this._releaseTextures(),this._createTextures(t));const s=this._renderTarget.textures;for(let r=0;r<s.length;r++){const n=this._textures[r];i[r]!==void 0&&this._renderTarget.setTexture(s[i[r]],r),n._texture=s[r],n._texture&&(n._noMipmap=!n._texture.useMipMaps,n._useSRGBBuffer=n._texture._useSRGBBuffer)}this.samples!==1&&this._renderTarget.setSamples(this.samples,!this._drawOnlyOnFirstAttachmentByDefault,!0)}_createInternalTextures(){this._renderTarget=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions,!this._drawOnlyOnFirstAttachmentByDefault),this._texture=this._renderTarget.texture}_releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;e++)this._textures[e]._texture=null,this._textures[e].dispose()}_createTextures(e){const t=this._renderTarget.textures;this._textures=[];for(let i=0;i<t.length;i++){const s=new O(null,this.getScene());e!=null&&e[i]&&(s.name=e[i]),s._texture=t[i],s._texture&&(s._noMipmap=!s._texture.useMipMaps,s._useSRGBBuffer=s._texture._useSRGBBuffer),this._textures.push(s)}}setInternalTexture(e,t,i=!0){var s,r;if(this.renderTarget&&(t===0&&(this._texture=e),this.renderTarget.setTexture(e,t,i),this.textures[t]||(this.textures[t]=new O(null,this.getScene()),this.textures[t].name=(r=(s=this._textureNames)===null||s===void 0?void 0:s[t])!==null&&r!==void 0?r:this.textures[t].name),this.textures[t]._texture=e,this.textures[t]._noMipmap=!e.useMipMaps,this.textures[t]._useSRGBBuffer=e._useSRGBBuffer,this._count=this.renderTarget.textures?this.renderTarget.textures.length:0,this._multiRenderTargetOptions.types&&(this._multiRenderTargetOptions.types[t]=e.type),this._multiRenderTargetOptions.samplingModes&&(this._multiRenderTargetOptions.samplingModes[t]=e.samplingMode),this._multiRenderTargetOptions.useSRGBBuffers&&(this._multiRenderTargetOptions.useSRGBBuffers[t]=e._useSRGBBuffer),this._multiRenderTargetOptions.targetTypes&&this._multiRenderTargetOptions.targetTypes[t]!==-1)){let n=0;e.is2DArray?n=35866:e.isCube?n=34067:e.is3D?n=32879:n=3553,this._multiRenderTargetOptions.targetTypes[t]=n}}setLayerAndFaceIndex(e,t=-1,i=-1){!this.textures[e]||!this.renderTarget||(this._multiRenderTargetOptions.layerIndex&&(this._multiRenderTargetOptions.layerIndex[e]=t),this._multiRenderTargetOptions.faceIndex&&(this._multiRenderTargetOptions.faceIndex[e]=i),this.renderTarget.setLayerAndFaceIndex(e,t,i))}setLayerAndFaceIndices(e,t){this.renderTarget&&(this._multiRenderTargetOptions.layerIndex=e,this._multiRenderTargetOptions.faceIndex=t,this.renderTarget.setLayerAndFaceIndices(e,t))}get samples(){return this._samples}set samples(e){this._renderTarget?this._samples=this._renderTarget.setSamples(e):this._samples=e}resize(e){this._processSizeParameter(e,!1),this._rebuild(void 0,this._textureNames)}updateCount(e,t,i){this._multiRenderTargetOptions.textureCount=e,this._count=e;const s=[],r=[],n=[],a=[],o=[],h=[],c=[],u=[];this._textureNames=i,this._initTypes(e,s,r,n,a,o,h,c,u,t),this._multiRenderTargetOptions.types=s,this._multiRenderTargetOptions.samplingModes=r,this._multiRenderTargetOptions.useSRGBBuffers=n,this._multiRenderTargetOptions.formats=a,this._multiRenderTargetOptions.targetTypes=o,this._multiRenderTargetOptions.faceIndex=h,this._multiRenderTargetOptions.layerIndex=c,this._multiRenderTargetOptions.layerCounts=u,this._rebuild(!0,i)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindMultiColorAttachmentFramebuffer(this._renderTarget,this.isCube,()=>{this.onAfterRenderObservable.notifyObservers(t)})}dispose(e=!1){this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),super.dispose()}releaseInternalTextures(){var e,t;const i=(e=this._renderTarget)===null||e===void 0?void 0:e.textures;if(i){for(let s=i.length-1;s>=0;s--)this._textures[s]._texture=null;(t=this._renderTarget)===null||t===void 0||t.dispose(),this._renderTarget=null}}}const Hg="mrtFragmentDeclaration",Wg=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
8504
8504
  layout(location=0) out vec4 glFragData[{X}];
8505
8505
  #endif
8506
- `;U.IncludesShadersStore[Gg]=Hg;const Wg="geometryPixelShader",zg=`#extension GL_EXT_draw_buffers : require
8506
+ `;U.IncludesShadersStore[Hg]=Wg;const zg="geometryPixelShader",Xg=`#extension GL_EXT_draw_buffers : require
8507
8507
  #if defined(BUMP) || !defined(NORMAL)
8508
8508
  #extension GL_OES_standard_derivatives : enable
8509
8509
  #endif
@@ -8640,9 +8640,9 @@ reflectivity.a*=glossiness;
8640
8640
  gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
8641
8641
  #endif
8642
8642
  }
8643
- `;U.ShadersStore[Wg]=zg;const Xg="geometryVertexDeclaration",Yg=`uniform mat4 viewProjection;
8644
- uniform mat4 view;`;U.IncludesShadersStore[Xg]=Yg;const Kg="geometryUboDeclaration",jg=`#include<sceneUboDeclaration>
8645
- `;U.IncludesShadersStore[Kg]=jg;const qg="geometryVertexShader",Zg=`precision highp float;
8643
+ `;U.ShadersStore[zg]=Xg;const Yg="geometryVertexDeclaration",Kg=`uniform mat4 viewProjection;
8644
+ uniform mat4 view;`;U.IncludesShadersStore[Yg]=Kg;const jg="geometryUboDeclaration",qg=`#include<sceneUboDeclaration>
8645
+ `;U.IncludesShadersStore[jg]=qg;const Zg="geometryVertexShader",Qg=`precision highp float;
8646
8646
  #include<bonesDeclaration>
8647
8647
  #include<bakedVertexAnimationDeclaration>
8648
8648
  #include<morphTargetsVertexGlobalDeclaration>
@@ -8788,8 +8788,8 @@ vAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));
8788
8788
  #endif
8789
8789
  #include<bumpVertex>
8790
8790
  }
8791
- `;U.ShadersStore[qg]=Zg;const Pl=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"];zs(Pl);class at{_linkPrePassRenderer(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add(()=>{}))}_unlinkPrePassRenderer(){this._linkedWithPrePass=!1,this._createRenderTargets()}_resetLayout(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachmentsFromPrePass=[]}_forceTextureType(e,t){e===at.POSITION_TEXTURE_TYPE?(this._positionIndex=t,this._enablePosition=!0):e===at.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=t,this._enableVelocity=!0):e===at.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=t,this._enableReflectivity=!0):e===at.DEPTH_TEXTURE_TYPE?this._depthIndex=t:e===at.NORMAL_TEXTURE_TYPE&&(this._normalIndex=t)}_setAttachments(e){this._attachmentsFromPrePass=e}_linkInternalTexture(e){this._multiRenderTarget.setInternalTexture(e,0,!1)}get renderList(){return this._multiRenderTarget.renderList}set renderList(e){this._multiRenderTarget.renderList=e}get isSupported(){return this._multiRenderTarget.isSupported}getTextureIndex(e){switch(e){case at.POSITION_TEXTURE_TYPE:return this._positionIndex;case at.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case at.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;default:return-1}}get enablePosition(){return this._enablePosition}set enablePosition(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableVelocity(){return this._enableVelocity}set enableVelocity(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=e}get enableReflectivity(){return this._enableReflectivity}set enableReflectivity(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get scene(){return this._scene}get ratio(){return this._ratio}constructor(e,t=1,i=15){this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._clearColor=new ge(0,0,0,0),this._clearDepthColor=new ge(1e8,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._linkedWithPrePass=!1,this.useSpecificClearForDepthTexture=!1,this._scene=e,this._ratio=t,this._useUbo=e.getEngine().supportsUniformBuffers,this._depthFormat=i,at._SceneComponentInitialization(this._scene),this._createRenderTargets()}isReady(e,t){const i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;const s=[],r=[A.PositionKind,A.NormalKind],n=e.getMesh();if(i){let d=!1;if(i.needAlphaTesting()&&i.getAlphaTestTexture()&&(s.push("#define ALPHATEST"),s.push(`#define ALPHATEST_UV${i.getAlphaTestTexture().coordinatesIndex+1}`),d=!0),i.bumpTexture&&H.BumpTextureEnabled&&(s.push("#define BUMP"),s.push(`#define BUMP_UV${i.bumpTexture.coordinatesIndex+1}`),d=!0),this._enableReflectivity){let _=!1;i.getClassName()==="PBRMetallicRoughnessMaterial"?(i.metallicRoughnessTexture!==null&&(s.push("#define ORMTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.metallicRoughnessTexture.coordinatesIndex+1}`),s.push("#define METALLICWORKFLOW"),d=!0,_=!0),i.metallic!==null&&(s.push("#define METALLIC"),s.push("#define METALLICWORKFLOW"),_=!0),i.roughness!==null&&(s.push("#define ROUGHNESS"),s.push("#define METALLICWORKFLOW"),_=!0),_&&(i.baseTexture!==null&&(s.push("#define ALBEDOTEXTURE"),s.push(`#define ALBEDO_UV${i.baseTexture.coordinatesIndex+1}`),i.baseTexture.gammaSpace&&s.push("#define GAMMAALBEDO"),d=!0),i.baseColor!==null&&s.push("#define ALBEDOCOLOR"))):i.getClassName()==="PBRSpecularGlossinessMaterial"?(i.specularGlossinessTexture!==null?(s.push("#define SPECULARGLOSSINESSTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.specularGlossinessTexture.coordinatesIndex+1}`),d=!0,i.specularGlossinessTexture.gammaSpace&&s.push("#define GAMMAREFLECTIVITYTEXTURE")):i.specularColor!==null&&s.push("#define REFLECTIVITYCOLOR"),i.glossiness!==null&&s.push("#define GLOSSINESS")):i.getClassName()==="PBRMaterial"?(i.metallicTexture!==null&&(s.push("#define ORMTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.metallicTexture.coordinatesIndex+1}`),s.push("#define METALLICWORKFLOW"),d=!0,_=!0),i.metallic!==null&&(s.push("#define METALLIC"),s.push("#define METALLICWORKFLOW"),_=!0),i.roughness!==null&&(s.push("#define ROUGHNESS"),s.push("#define METALLICWORKFLOW"),_=!0),_?(i.albedoTexture!==null&&(s.push("#define ALBEDOTEXTURE"),s.push(`#define ALBEDO_UV${i.albedoTexture.coordinatesIndex+1}`),i.albedoTexture.gammaSpace&&s.push("#define GAMMAALBEDO"),d=!0),i.albedoColor!==null&&s.push("#define ALBEDOCOLOR")):(i.reflectivityTexture!==null?(s.push("#define SPECULARGLOSSINESSTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.reflectivityTexture.coordinatesIndex+1}`),i.reflectivityTexture.gammaSpace&&s.push("#define GAMMAREFLECTIVITYTEXTURE"),d=!0):i.reflectivityColor!==null&&s.push("#define REFLECTIVITYCOLOR"),i.microSurface!==null&&s.push("#define GLOSSINESS"))):i.getClassName()==="StandardMaterial"&&(i.specularTexture!==null&&(s.push("#define REFLECTIVITYTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.specularTexture.coordinatesIndex+1}`),i.specularTexture.gammaSpace&&s.push("#define GAMMAREFLECTIVITYTEXTURE"),d=!0),i.specularColor!==null&&s.push("#define REFLECTIVITYCOLOR"))}d&&(s.push("#define NEED_UV"),n.isVerticesDataPresent(A.UVKind)&&(r.push(A.UVKind),s.push("#define UV1")),n.isVerticesDataPresent(A.UV2Kind)&&(r.push(A.UV2Kind),s.push("#define UV2")))}this._linkedWithPrePass&&(s.push("#define PREPASS"),this._depthIndex!==-1&&(s.push("#define DEPTH_INDEX "+this._depthIndex),s.push("#define PREPASS_DEPTH")),this._normalIndex!==-1&&(s.push("#define NORMAL_INDEX "+this._normalIndex),s.push("#define PREPASS_NORMAL"))),this._enablePosition&&(s.push("#define POSITION"),s.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(s.push("#define VELOCITY"),s.push("#define VELOCITY_INDEX "+this._velocityIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(n)===-1&&s.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(s.push("#define REFLECTIVITY"),s.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),n.useBones&&n.computeBonesUsingShaders?(r.push(A.MatricesIndicesKind),r.push(A.MatricesWeightsKind),n.numBoneInfluencers>4&&(r.push(A.MatricesIndicesExtraKind),r.push(A.MatricesWeightsExtraKind)),s.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),s.push("#define BonesPerMesh "+(n.skeleton?n.skeleton.bones.length+1:0))):s.push("#define NUM_BONE_INFLUENCERS 0");const a=n.morphTargetManager;let o=0;a&&a.numInfluencers>0&&(o=a.numInfluencers,s.push("#define MORPHTARGETS"),s.push("#define NUM_MORPH_INFLUENCERS "+o),a.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),X.PrepareAttributesForMorphTargetsInfluencers(r,n,o)),t&&(s.push("#define INSTANCES"),X.PushAttributesForInstances(r,this._enableVelocity),e.getRenderingMesh().hasThinInstances&&s.push("#define THIN_INSTANCES")),this._linkedWithPrePass?s.push("#define RENDER_TARGET_COUNT "+this._attachmentsFromPrePass.length):s.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length),nn(i,this._scene,s);const h=this._scene.getEngine(),c=e._getDrawWrapper(void 0,!0),u=c.defines,f=s.join(`
8792
- `);return u!==f&&c.setEffect(h.createEffect("geometry",{attributes:r,uniformsNames:Pl,samplers:["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets"],defines:f,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:o}},h),f),c.effect.isReady()}getGBuffer(){return this._multiRenderTarget}get samples(){return this._multiRenderTarget.samples}set samples(e){this._multiRenderTarget.samples=e}dispose(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.getGBuffer().dispose()}_assignRenderTargetIndices(){const e=[];let t=2;return e.push("gBuffer_Depth","gBuffer_Normal"),this._enablePosition&&(this._positionIndex=t,t++,e.push("gBuffer_Position")),this._enableVelocity&&(this._velocityIndex=t,t++,e.push("gBuffer_Velocity")),this._enableReflectivity&&(this._reflectivityIndex=t,t++,e.push("gBuffer_Reflectivity")),[t,e]}_createRenderTargets(){const e=this._scene.getEngine(),[t,i]=this._assignRenderTargetIndices();let s=0;if(e._caps.textureFloat&&e._caps.textureFloatLinearFiltering?s=1:e._caps.textureHalfFloat&&e._caps.textureHalfFloatLinearFiltering&&(s=2),this._multiRenderTarget=new kg("gBuffer",{width:e.getRenderWidth()*this._ratio,height:e.getRenderHeight()*this._ratio},t,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:s,depthTextureFormat:this._depthFormat},i.concat("gBuffer_DepthBuffer")),!this.isSupported)return;this._multiRenderTarget.wrapU=O.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=O.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;const r=[!0],n=[!1],a=[!0];for(let f=1;f<t;++f)r.push(!0),a.push(!1),n.push(!0);const o=e.buildTextureLayout(r),h=e.buildTextureLayout(n),c=e.buildTextureLayout(a);this._multiRenderTarget.onClearObservable.add(f=>{f.bindAttachments(this.useSpecificClearForDepthTexture?h:o),f.clear(this._clearColor,!0,!0,!0),this.useSpecificClearForDepthTexture&&(f.bindAttachments(c),f.clear(this._clearDepthColor,!0,!0,!0)),f.bindAttachments(o)}),this._resizeObserver=e.onResizeObservable.add(()=>{this._multiRenderTarget&&this._multiRenderTarget.resize({width:e.getRenderWidth()*this._ratio,height:e.getRenderHeight()*this._ratio})});const u=f=>{const d=f.getRenderingMesh(),_=f.getEffectiveMesh(),p=this._scene,m=p.getEngine(),T=f.getMaterial();if(!T)return;if(_._internalAbstractMeshDataInfo._isActiveIntermediate=!1,this._enableVelocity&&!this._previousTransformationMatrices[_.uniqueId]&&(this._previousTransformationMatrices[_.uniqueId]={world:M.Identity(),viewProjection:p.getTransformMatrix()},d.skeleton)){const I=d.skeleton.getTransformMatrices(d);this._previousBonesTransformationMatrices[d.uniqueId]=this._copyBonesTransformationMatrices(I,new Float32Array(I.length))}const S=d._getInstancesRenderList(f._id,!!f.getReplacementMesh());if(S.mustReturn)return;const x=m.getCaps().instancedArrays&&(S.visibleInstances[f._id]!==null||d.hasThinInstances),b=_.getWorldMatrix();if(this.isReady(f,x)){const I=f._getDrawWrapper();if(!I)return;const R=I.effect;m.enableEffect(I),x||d._bind(f,R,T.fillMode),this._useUbo?(X.BindSceneUniformBuffer(R,this._scene.getSceneUniformBuffer()),this._scene.finalizeSceneUbo()):(R.setMatrix("viewProjection",p.getTransformMatrix()),R.setMatrix("view",p.getViewMatrix()));let C;const y=d._instanceDataStorage;if(!y.isFrozen&&(T.backFaceCulling||d.overrideMaterialSideOrientation!==null)){const w=_._getWorldMatrixDeterminant();C=d.overrideMaterialSideOrientation,C===null&&(C=T.sideOrientation),w<0&&(C=C===V.ClockWiseSideOrientation?V.CounterClockWiseSideOrientation:V.ClockWiseSideOrientation)}else C=y.sideOrientation;if(T._preBind(I,C),T.needAlphaTesting()){const w=T.getAlphaTestTexture();w&&(R.setTexture("diffuseSampler",w),R.setMatrix("diffuseMatrix",w.getTextureMatrix()))}T.bumpTexture&&p.getEngine().getCaps().standardDerivatives&&H.BumpTextureEnabled&&(R.setFloat3("vBumpInfos",T.bumpTexture.coordinatesIndex,1/T.bumpTexture.level,T.parallaxScaleBias),R.setMatrix("bumpMatrix",T.bumpTexture.getTextureMatrix()),R.setTexture("bumpSampler",T.bumpTexture),R.setFloat2("vTangentSpaceParams",T.invertNormalMapX?-1:1,T.invertNormalMapY?-1:1)),this._enableReflectivity&&(T.getClassName()==="PBRMetallicRoughnessMaterial"?(T.metallicRoughnessTexture!==null&&(R.setTexture("reflectivitySampler",T.metallicRoughnessTexture),R.setMatrix("reflectivityMatrix",T.metallicRoughnessTexture.getTextureMatrix())),T.metallic!==null&&R.setFloat("metallic",T.metallic),T.roughness!==null&&R.setFloat("glossiness",1-T.roughness),T.baseTexture!==null&&(R.setTexture("albedoSampler",T.baseTexture),R.setMatrix("albedoMatrix",T.baseTexture.getTextureMatrix())),T.baseColor!==null&&R.setColor3("albedoColor",T.baseColor)):T.getClassName()==="PBRSpecularGlossinessMaterial"?(T.specularGlossinessTexture!==null?(R.setTexture("reflectivitySampler",T.specularGlossinessTexture),R.setMatrix("reflectivityMatrix",T.specularGlossinessTexture.getTextureMatrix())):T.specularColor!==null&&R.setColor3("reflectivityColor",T.specularColor),T.glossiness!==null&&R.setFloat("glossiness",T.glossiness)):T.getClassName()==="PBRMaterial"?(T.metallicTexture!==null&&(R.setTexture("reflectivitySampler",T.metallicTexture),R.setMatrix("reflectivityMatrix",T.metallicTexture.getTextureMatrix())),T.metallic!==null&&R.setFloat("metallic",T.metallic),T.roughness!==null&&R.setFloat("glossiness",1-T.roughness),T.roughness!==null||T.metallic!==null||T.metallicTexture!==null?(T.albedoTexture!==null&&(R.setTexture("albedoSampler",T.albedoTexture),R.setMatrix("albedoMatrix",T.albedoTexture.getTextureMatrix())),T.albedoColor!==null&&R.setColor3("albedoColor",T.albedoColor)):(T.reflectivityTexture!==null?(R.setTexture("reflectivitySampler",T.reflectivityTexture),R.setMatrix("reflectivityMatrix",T.reflectivityTexture.getTextureMatrix())):T.reflectivityColor!==null&&R.setColor3("reflectivityColor",T.reflectivityColor),T.microSurface!==null&&R.setFloat("glossiness",T.microSurface))):T.getClassName()==="StandardMaterial"&&(T.specularTexture!==null&&(R.setTexture("reflectivitySampler",T.specularTexture),R.setMatrix("reflectivityMatrix",T.specularTexture.getTextureMatrix())),T.specularColor!==null&&R.setColor3("reflectivityColor",T.specularColor))),Xs(R,T,this._scene),d.useBones&&d.computeBonesUsingShaders&&d.skeleton&&(R.setMatrices("mBones",d.skeleton.getTransformMatrices(d)),this._enableVelocity&&R.setMatrices("mPreviousBones",this._previousBonesTransformationMatrices[d.uniqueId])),X.BindMorphTargetParameters(d,R),d.morphTargetManager&&d.morphTargetManager.isUsingTextureForTargets&&d.morphTargetManager._bind(R),this._enableVelocity&&(R.setMatrix("previousWorld",this._previousTransformationMatrices[_.uniqueId].world),R.setMatrix("previousViewProjection",this._previousTransformationMatrices[_.uniqueId].viewProjection)),x&&d.hasThinInstances&&R.setMatrix("world",b),d._processRendering(_,f,R,T.fillMode,S,x,(w,G)=>{w||R.setMatrix("world",G)})}this._enableVelocity&&(this._previousTransformationMatrices[_.uniqueId].world=b.clone(),this._previousTransformationMatrices[_.uniqueId].viewProjection=this._scene.getTransformMatrix().clone(),d.skeleton&&this._copyBonesTransformationMatrices(d.skeleton.getTransformMatrices(d),this._previousBonesTransformationMatrices[_.uniqueId]))};this._multiRenderTarget.customIsReadyFunction=(f,d,_)=>{if((_||d===0)&&f.subMeshes)for(let p=0;p<f.subMeshes.length;++p){const m=f.subMeshes[p],T=m.getMaterial(),S=m.getRenderingMesh();if(!T)continue;const x=S._getInstancesRenderList(m._id,!!m.getReplacementMesh()),b=e.getCaps().instancedArrays&&(x.visibleInstances[m._id]!==null||S.hasThinInstances);if(!this.isReady(m,b))return!1}return!0},this._multiRenderTarget.customRenderFunction=(f,d,_,p)=>{let m;if(this._linkedWithPrePass){if(!this._prePassRenderer.enabled)return;this._scene.getEngine().bindAttachments(this._attachmentsFromPrePass)}if(p.length){for(e.setColorWrite(!1),m=0;m<p.length;m++)u(p.data[m]);e.setColorWrite(!0)}for(m=0;m<f.length;m++)u(f.data[m]);for(e.setDepthWrite(!1),m=0;m<d.length;m++)u(d.data[m]);if(this.renderTransparentMeshes)for(m=0;m<_.length;m++)u(_.data[m]);e.setDepthWrite(!0)}}_copyBonesTransformationMatrices(e,t){for(let i=0;i<e.length;i++)t[i]=e[i];return t}}at.DEPTH_TEXTURE_TYPE=0,at.NORMAL_TEXTURE_TYPE=1,at.POSITION_TEXTURE_TYPE=2,at.VELOCITY_TEXTURE_TYPE=3,at.REFLECTIVITY_TEXTURE_TYPE=4,at._SceneComponentInitialization=l=>{throw fe("GeometryBufferRendererSceneComponent")};class Qg{constructor(){this.enabled=!1,this.name="motionBlur",this.texturesRequired=[2]}}const $g=Object.freeze(new K(0,0,0,0)),Jg=Object.freeze(E.Zero()),eE=Object.freeze(ae.Zero()),tE=Object.freeze(ui.Zero()),iE=Object.freeze(z.Black());class sE{get currentFrame(){return this._currentFrame}get weight(){return this._weight}get currentValue(){return this._currentValue}get targetPath(){return this._targetPath}get target(){return this._currentActiveTarget}get isAdditive(){return this._host&&this._host.isAdditive}constructor(e,t,i,s){if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._absoluteFrameOffset=0,this._previousElapsedTime=0,this._previousAbsoluteFrame=0,this._targetIsArray=!1,this._animation=t,this._target=e,this._scene=i,this._host=s,this._activeTargets=[],t._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===N.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=M.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minValue=this._keys[0].value,this._maxValue=this._keys[this._keys.length-1].value,this._minFrame!==0){const n={frame:0,value:this._minValue};this._keys.splice(0,0,n)}if(this._target instanceof Array){let n=0;for(const a of this._target)this._preparePath(a,n),this._getOriginalValues(n),n++;this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];const r=t.getEvents();r&&r.length>0&&r.forEach(n=>{this._events.push(n._clone())}),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}_preparePath(e,t=0){const i=this._animation.targetPropertyPath;if(i.length>1){let s=e[i[0]];for(let r=1;r<i.length-1;r++)s=s[i[r]];this._targetPath=i[i.length-1],this._activeTargets[t]=s}else this._targetPath=i[0],this._activeTargets[t]=e}get animation(){return this._animation}reset(e=!1){if(e)if(this._target instanceof Array){let t=0;for(const i of this._target)this._originalValue[t]!==void 0&&this._setValue(i,this._activeTargets[t],this._originalValue[t],-1,t),t++}else this._originalValue[0]!==void 0&&this._setValue(this._target,this._directTarget,this._originalValue[0],-1,0);this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0;for(let t=0;t<this._events.length;t++)this._events[t].isDone=!1}isStopped(){return this._stopped}dispose(){const e=this._animation.runtimeAnimations.indexOf(this);e>-1&&this._animation.runtimeAnimations.splice(e,1)}setValue(e,t){if(this._targetIsArray){for(let i=0;i<this._target.length;i++){const s=this._target[i];this._setValue(s,this._activeTargets[i],e,t,i)}return}this._setValue(this._target,this._directTarget,e,t,0)}_getOriginalValues(e=0){let t;const i=this._activeTargets[e];i.getRestPose&&this._targetPath==="_matrix"?t=i.getRestPose():t=i[this._targetPath],t&&t.clone?this._originalValue[e]=t.clone():this._originalValue[e]=t}_setValue(e,t,i,s,r){if(this._currentActiveTarget=t,this._weight=s,this._enableBlending&&this._blendingFactor<=1){if(!this._originalBlendValue){const a=t[this._targetPath];a.clone?this._originalBlendValue=a.clone():this._originalBlendValue=a}this._originalBlendValue.m?N.AllowMatrixDecomposeForInterpolation?this._currentValue?M.DecomposeLerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=M.DecomposeLerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue?M.LerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=M.Lerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue=N._UniversalLerp(this._originalBlendValue,i,this._blendingFactor);const n=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=n}else this._currentValue?this._currentValue.copyFrom?this._currentValue.copyFrom(i):this._currentValue=i:i!=null&&i.clone?this._currentValue=i.clone():this._currentValue=i;s!==-1?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[r]):t[this._targetPath]=this._currentValue,e.markAsDirty&&e.markAsDirty(this._animation.targetProperty)}_getCorrectLoopMode(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode}goToFrame(e){const t=this._animation.getKeys();e<t[0].frame?e=t[0].frame:e>t[t.length-1].frame&&(e=t[t.length-1].frame);const i=this._events;if(i.length)for(let r=0;r<i.length;r++)i[r].onlyOnce||(i[r].isDone=i[r].frame<e);this._currentFrame=e;const s=this._animation._interpolate(e,this._animationState);this.setValue(s,-1)}_prepareForSpeedRatioChange(e){const t=this._previousElapsedTime*(this._animation.framePerSecond*e)/1e3;this._absoluteFrameOffset=this._previousAbsoluteFrame-t}animate(e,t,i,s,r,n=-1){const a=this._animation,o=a.targetPropertyPath;if(!o||o.length<1)return this._stopped=!0,!1;let h=!0;(t<this._minFrame||t>this._maxFrame)&&(t=this._minFrame),(i<this._minFrame||i>this._maxFrame)&&(i=this._maxFrame);const c=i-t;let u,f=e*(a.framePerSecond*r)/1e3+this._absoluteFrameOffset,d=0;if(s&&this._animationState.loopMode===N.ANIMATIONLOOPMODE_YOYO){const T=(f-t)/c;f=Math.abs(Math.sin(T*Math.PI))*c+t}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=f,!s&&i>=t&&f>=c)h=!1,d=a._getKeyValue(this._maxValue);else if(!s&&t>=i&&f<=c)h=!1,d=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==N.ANIMATIONLOOPMODE_CYCLE){const T=i.toString()+t.toString();if(!this._offsetsCache[T]){this._animationState.repeatCount=0,this._animationState.loopMode=N.ANIMATIONLOOPMODE_CYCLE;const S=a._interpolate(t,this._animationState),x=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case N.ANIMATIONTYPE_FLOAT:this._offsetsCache[T]=x-S;break;case N.ANIMATIONTYPE_QUATERNION:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_VECTOR3:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_VECTOR2:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_SIZE:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_COLOR3:this._offsetsCache[T]=x.subtract(S);break}this._highLimitsCache[T]=x}d=this._highLimitsCache[T],u=this._offsetsCache[T]}if(u===void 0)switch(a.dataType){case N.ANIMATIONTYPE_FLOAT:u=0;break;case N.ANIMATIONTYPE_QUATERNION:u=$g;break;case N.ANIMATIONTYPE_VECTOR3:u=Jg;break;case N.ANIMATIONTYPE_VECTOR2:u=eE;break;case N.ANIMATIONTYPE_SIZE:u=tE;break;case N.ANIMATIONTYPE_COLOR3:u=iE}let _;if(this._host&&this._host.syncRoot){const T=this._host.syncRoot,S=(T.masterFrame-T.fromFrame)/(T.toFrame-T.fromFrame);_=t+c*S}else f>0&&t>i||f<0&&t<i?_=h&&c!==0?i+f%c:t:_=h&&c!==0?t+f%c:i;const p=this._events;if(r>0&&this.currentFrame>_||r<0&&this.currentFrame<_){this._onLoop();for(let T=0;T<p.length;T++)p[T].onlyOnce||(p[T].isDone=!1);this._animationState.key=r>0?0:a.getKeys().length-1}this._currentFrame=_,this._animationState.repeatCount=c===0?0:f/c>>0,this._animationState.highLimitValue=d,this._animationState.offsetValue=u;const m=a._interpolate(_,this._animationState);if(this.setValue(m,n),p.length){for(let T=0;T<p.length;T++)if(c>0&&_>=p[T].frame&&p[T].frame>=t||c<0&&_<=p[T].frame&&p[T].frame<=t){const S=p[T];S.isDone||(S.onlyOnce&&(p.splice(T,1),T--),S.isDone=!0,S.action(_))}}return h||(this._stopped=!0),h}}class Ol{get syncRoot(){return this._syncRoot}get masterFrame(){return this._runtimeAnimations.length===0?0:this._runtimeAnimations[0].currentFrame}get weight(){return this._weight}set weight(e){if(e===-1){this._weight=-1;return}this._weight=Math.min(Math.max(e,0),1)}get speedRatio(){return this._speedRatio}set speedRatio(e){for(let t=0;t<this._runtimeAnimations.length;t++)this._runtimeAnimations[t]._prepareForSpeedRatioChange(e);this._speedRatio=e,this._goToFrame!==null&&this.goToFrame(this._goToFrame)}constructor(e,t,i=0,s=100,r=!1,n=1,a,o,h,c=!1,u=0){this.target=t,this.fromFrame=i,this.toFrame=s,this.loopAnimation=r,this.onAnimationEnd=a,this.onAnimationLoop=h,this.isAdditive=c,this.playOrder=u,this._localDelayOffset=null,this._pausedDelay=null,this._manualJumpDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this._syncRoot=null,this._frameToSyncFromJump=null,this._goToFrame=null,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new B,this.onAnimationLoopObservable=new B,this._scene=e,o&&this.appendAnimations(t,o),this._speedRatio=n,e._activeAnimatables.push(this)}syncWith(e){if(this._syncRoot=e,e){const t=this._scene._activeAnimatables.indexOf(this);t>-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this}getAnimations(){return this._runtimeAnimations}appendAnimations(e,t){for(let i=0;i<t.length;i++){const s=t[i],r=new sE(e,s,this._scene,this);r._onLoop=()=>{this.onAnimationLoopObservable.notifyObservers(this),this.onAnimationLoop&&this.onAnimationLoop()},this._runtimeAnimations.push(r)}}getAnimationByTargetProperty(e){const t=this._runtimeAnimations;for(let i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i].animation;return null}getRuntimeAnimationByTargetProperty(e){const t=this._runtimeAnimations;for(let i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i];return null}reset(){const e=this._runtimeAnimations;for(let t=0;t<e.length;t++)e[t].reset(!0);this._localDelayOffset=null,this._pausedDelay=null}enableBlending(e){const t=this._runtimeAnimations;for(let i=0;i<t.length;i++)t[i].animation.enableBlending=!0,t[i].animation.blendingSpeed=e}disableBlending(){const e=this._runtimeAnimations;for(let t=0;t<e.length;t++)e[t].animation.enableBlending=!1}goToFrame(e){var t;const i=this._runtimeAnimations;if(i[0]){const s=i[0].animation.framePerSecond;this._frameToSyncFromJump=(t=this._frameToSyncFromJump)!==null&&t!==void 0?t:i[0].currentFrame;const r=this.speedRatio===0?0:(e-this._frameToSyncFromJump)/s*1e3/this.speedRatio;this._manualJumpDelay=-r}for(let s=0;s<i.length;s++)i[s].goToFrame(e);this._goToFrame=e}pause(){this._paused||(this._paused=!0)}restart(){this._paused=!1}_raiseOnAnimationEnd(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)}stop(e,t,i=!1){if(e||t){const s=this._scene._activeAnimatables.indexOf(this);if(s>-1){const r=this._runtimeAnimations;for(let n=r.length-1;n>=0;n--){const a=r[n];e&&a.animation.name!=e||t&&!t(a.target)||(a.dispose(),r.splice(n,1))}r.length==0&&(i||this._scene._activeAnimatables.splice(s,1),this._raiseOnAnimationEnd())}}else{const s=this._scene._activeAnimatables.indexOf(this);if(s>-1){i||this._scene._activeAnimatables.splice(s,1);const r=this._runtimeAnimations;for(let n=0;n<r.length;n++)r[n].dispose();this._runtimeAnimations.length=0,this._raiseOnAnimationEnd()}}}waitAsync(){return new Promise(e=>{this.onAnimationEndObservable.add(()=>{e(this)},void 0,void 0,this,!0)})}_animate(e){if(this._paused)return this.animationStarted=!1,this._pausedDelay===null&&(this._pausedDelay=e),!0;if(this._localDelayOffset===null?(this._localDelayOffset=e,this._pausedDelay=null):this._pausedDelay!==null&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null),this._manualJumpDelay!==null&&(this._localDelayOffset+=this._manualJumpDelay,this._manualJumpDelay=null,this._frameToSyncFromJump=null),this._goToFrame=null,this._weight===0)return!0;let t=!1;const i=this._runtimeAnimations;let s;for(s=0;s<i.length;s++){const n=i[s].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);t=t||n}if(this.animationStarted=t,!t){if(this.disposeOnEnd)for(s=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(s,1),s=0;s<i.length;s++)i[s].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationLoop=null,this.onAnimationLoopObservable.clear(),this.onAnimationEndObservable.clear())}return t}}Ie.prototype._animate=function(){if(!this.animationsEnabled)return;const l=ii.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=l}this.deltaTime=this.useConstantAnimationDeltaTime?16:(l-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=l;const e=this._activeAnimatables;if(e.length===0)return;this._animationTime+=this.deltaTime;const t=this._animationTime;for(let i=0;i<e.length;i++){const s=e[i];!s._animate(t)&&s.disposeOnEnd&&i--}this._processLateAnimationBindings()},Ie.prototype.sortActiveAnimatables=function(){this._activeAnimatables.sort((l,e)=>l.playOrder-e.playOrder)},Ie.prototype.beginWeightedAnimation=function(l,e,t,i=1,s,r=1,n,a,o,h,c=!1){const u=this.beginAnimation(l,e,t,s,r,n,a,!1,o,h,c);return u.weight=i,u},Ie.prototype.beginAnimation=function(l,e,t,i,s=1,r,n,a=!0,o,h,c=!1){e>t&&s>0&&(s*=-1),a&&this.stopAnimation(l,void 0,o),n||(n=new Ol(this,l,e,t,i,s,r,void 0,h,c));const u=o?o(l):!0;if(l.animations&&u&&n.appendAnimations(l,l.animations),l.getAnimatables){const f=l.getAnimatables();for(let d=0;d<f.length;d++)this.beginAnimation(f[d],e,t,i,s,r,n,a,o,h)}return n.reset(),n},Ie.prototype.beginHierarchyAnimation=function(l,e,t,i,s,r=1,n,a,o=!0,h,c,u=!1){const f=l.getDescendants(e),d=[];d.push(this.beginAnimation(l,t,i,s,r,n,a,o,h,void 0,u));for(const _ of f)d.push(this.beginAnimation(_,t,i,s,r,n,a,o,h,void 0,u));return d},Ie.prototype.beginDirectAnimation=function(l,e,t,i,s,r,n,a,o=!1){if(r===void 0&&(r=1),t>i&&r>0)r*=-1;else if(i>t&&r<0){const c=i;i=t,t=c}return new Ol(this,l,t,i,s,r,n,e,a,o)},Ie.prototype.beginDirectHierarchyAnimation=function(l,e,t,i,s,r,n,a,o,h=!1){const c=l.getDescendants(e),u=[];u.push(this.beginDirectAnimation(l,t,i,s,r,n,a,o,h));for(const f of c)u.push(this.beginDirectAnimation(f,t,i,s,r,n,a,o,h));return u},Ie.prototype.getAnimatableByTarget=function(l){for(let e=0;e<this._activeAnimatables.length;e++)if(this._activeAnimatables[e].target===l)return this._activeAnimatables[e];return null},Ie.prototype.getAllAnimatablesByTarget=function(l){const e=[];for(let t=0;t<this._activeAnimatables.length;t++)this._activeAnimatables[t].target===l&&e.push(this._activeAnimatables[t]);return e},Ie.prototype.stopAnimation=function(l,e,t){const i=this.getAllAnimatablesByTarget(l);for(const s of i)s.stop(e,t)},Ie.prototype.stopAllAnimations=function(){if(this._activeAnimatables){for(let l=0;l<this._activeAnimatables.length;l++)this._activeAnimatables[l].stop(void 0,void 0,!0);this._activeAnimatables.length=0}for(const l of this.animationGroups)l.stop()},Ie.prototype._registerTargetForLateAnimationBinding=function(l,e){const t=l.target;this._registeredForLateAnimationBindings.pushNoDuplicate(t),t._lateAnimationHolders||(t._lateAnimationHolders={}),t._lateAnimationHolders[l.targetPath]||(t._lateAnimationHolders[l.targetPath]={totalWeight:0,totalAdditiveWeight:0,animations:[],additiveAnimations:[],originalValue:e}),l.isAdditive?(t._lateAnimationHolders[l.targetPath].additiveAnimations.push(l),t._lateAnimationHolders[l.targetPath].totalAdditiveWeight+=l.weight):(t._lateAnimationHolders[l.targetPath].animations.push(l),t._lateAnimationHolders[l.targetPath].totalWeight+=l.weight)},Ie.prototype._processLateAnimationBindingsForMatrices=function(l){if(l.totalWeight===0&&l.totalAdditiveWeight===0)return l.originalValue;let e=1;const t=D.Vector3[0],i=D.Vector3[1],s=D.Quaternion[0];let r=0;const n=l.animations[0],a=l.originalValue;let o=1,h=!1;if(l.totalWeight<1)o=1-l.totalWeight,a.decompose(i,s,t);else{if(r=1,e=l.totalWeight,o=n.weight/e,o==1)if(l.totalAdditiveWeight)h=!0;else return n.currentValue;n.currentValue.decompose(i,s,t)}if(!h){i.scaleInPlace(o),t.scaleInPlace(o),s.scaleInPlace(o);for(let u=r;u<l.animations.length;u++){const f=l.animations[u];if(f.weight===0)continue;o=f.weight/e;const d=D.Vector3[2],_=D.Vector3[3],p=D.Quaternion[1];f.currentValue.decompose(_,p,d),_.scaleAndAddToRef(o,i),p.scaleAndAddToRef(K.Dot(s,p)>0?o:-o,s),d.scaleAndAddToRef(o,t)}s.normalize()}for(let u=0;u<l.additiveAnimations.length;u++){const f=l.additiveAnimations[u];if(f.weight===0)continue;const d=D.Vector3[2],_=D.Vector3[3],p=D.Quaternion[1];f.currentValue.decompose(_,p,d),_.multiplyToRef(i,_),E.LerpToRef(i,_,f.weight,i),s.multiplyToRef(p,p),K.SlerpToRef(s,p,f.weight,s),d.scaleAndAddToRef(f.weight,t)}const c=n?n._animationState.workValue:D.Matrix[0].clone();return M.ComposeToRef(i,s,t,c),c},Ie.prototype._processLateAnimationBindingsForQuaternions=function(l,e){if(l.totalWeight===0&&l.totalAdditiveWeight===0)return e;const t=l.animations[0],i=l.originalValue;let s=e;if(l.totalWeight===0&&l.totalAdditiveWeight>0)s.copyFrom(i);else if(l.animations.length===1){if(K.SlerpToRef(i,t.currentValue,Math.min(1,l.totalWeight),s),l.totalAdditiveWeight===0)return s}else if(l.animations.length>1){let r=1,n,a;if(l.totalWeight<1){const h=1-l.totalWeight;n=[],a=[],n.push(i),a.push(h)}else{if(l.animations.length===2&&(K.SlerpToRef(l.animations[0].currentValue,l.animations[1].currentValue,l.animations[1].weight/l.totalWeight,e),l.totalAdditiveWeight===0))return e;n=[],a=[],r=l.totalWeight}for(let h=0;h<l.animations.length;h++){const c=l.animations[h];n.push(c.currentValue),a.push(c.weight/r)}let o=0;for(let h=0;h<n.length;){if(!h){K.SlerpToRef(n[h],n[h+1],a[h+1]/(a[h]+a[h+1]),e),s=e,o=a[h]+a[h+1],h+=2;continue}o+=a[h],K.SlerpToRef(s,n[h],a[h]/o,s),h++}}for(let r=0;r<l.additiveAnimations.length;r++){const n=l.additiveAnimations[r];n.weight!==0&&(s.multiplyToRef(n.currentValue,D.Quaternion[0]),K.SlerpToRef(s,D.Quaternion[0],n.weight,s))}return s},Ie.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(let l=0;l<this._registeredForLateAnimationBindings.length;l++){const e=this._registeredForLateAnimationBindings.data[l];for(const t in e._lateAnimationHolders){const i=e._lateAnimationHolders[t],s=i.animations[0],r=i.originalValue;if(r==null)continue;const n=N.AllowMatrixDecomposeForInterpolation&&r.m;let a=e[t];if(n)a=this._processLateAnimationBindingsForMatrices(i);else if(r.w!==void 0)a=this._processLateAnimationBindingsForQuaternions(i,a||K.Identity());else{let h=0,c=1;if(i.totalWeight<1)s&&r.scale?a=r.scale(1-i.totalWeight):s?a=r*(1-i.totalWeight):r.clone?a=r.clone():a=r;else if(s){c=i.totalWeight;const u=s.weight/c;u!==1?s.currentValue.scale?a=s.currentValue.scale(u):a=s.currentValue*u:a=s.currentValue,h=1}for(let u=h;u<i.animations.length;u++){const f=i.animations[u],d=f.weight/c;if(d)f.currentValue.scaleAndAddToRef?f.currentValue.scaleAndAddToRef(d,a):a+=f.currentValue*d;else continue}for(let u=0;u<i.additiveAnimations.length;u++){const f=i.additiveAnimations[u],d=f.weight;if(d)f.currentValue.scaleAndAddToRef?f.currentValue.scaleAndAddToRef(d,a):a+=f.currentValue*d;else continue}}e[t]=a}e._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},Ue.prototype.copyAnimationRange=function(l,e,t,i=!1,s=null){this.animations.length===0&&(this.animations.push(new N(this.name,"_matrix",l.animations[0].framePerSecond,N.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));const r=l.animations[0].getRange(e);if(!r)return!1;const n=r.from,a=r.to,o=l.animations[0].getKeys(),h=l.length,c=l.getParent(),u=this.getParent(),f=i&&c&&h&&this.length&&h!==this.length,d=f&&u&&c?u.length/c.length:1,_=i&&!u&&s&&(s.x!==1||s.y!==1||s.z!==1),p=this.animations[0].getKeys();let m,T,S;for(let x=0,b=o.length;x<b;x++)m=o[x],m.frame>=n&&m.frame<=a&&(i?(S=m.value.clone(),f?(T=S.getTranslation(),S.setTranslation(T.scaleInPlace(d))):_&&s?(T=S.getTranslation(),S.setTranslation(T.multiplyInPlace(s))):S=m.value):S=m.value,p.push({frame:m.frame+t,value:S}));return this.animations[0].createRange(e,n+t,a+t),!0},Object.defineProperty(Ie.prototype,"geometryBufferRenderer",{get:function(){return this._geometryBufferRenderer},set:function(l){l&&l.isSupported&&(this._geometryBufferRenderer=l)},enumerable:!0,configurable:!0}),Ie.prototype.enableGeometryBufferRenderer=function(l=1,e=15){return this._geometryBufferRenderer?this._geometryBufferRenderer:(this._geometryBufferRenderer=new at(this,l,e),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null),this._geometryBufferRenderer)},Ie.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};class rE{constructor(e){this.name=ee.NAME_GEOMETRYBUFFERRENDERER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(ee.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)}rebuild(){}dispose(){}_gatherRenderTargets(e){this.scene._geometryBufferRenderer&&e.push(this.scene._geometryBufferRenderer.getGBuffer())}}at._SceneComponentInitialization=l=>{let e=l._getComponent(ee.NAME_GEOMETRYBUFFERRENDERER);e||(e=new rE(l),l._addComponent(e))};const nE="motionBlurPixelShader",aE=`varying vec2 vUV;
8791
+ `;U.ShadersStore[Zg]=Qg;const Pl=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"];zs(Pl);class at{_linkPrePassRenderer(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add(()=>{}))}_unlinkPrePassRenderer(){this._linkedWithPrePass=!1,this._createRenderTargets()}_resetLayout(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachmentsFromPrePass=[]}_forceTextureType(e,t){e===at.POSITION_TEXTURE_TYPE?(this._positionIndex=t,this._enablePosition=!0):e===at.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=t,this._enableVelocity=!0):e===at.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=t,this._enableReflectivity=!0):e===at.DEPTH_TEXTURE_TYPE?this._depthIndex=t:e===at.NORMAL_TEXTURE_TYPE&&(this._normalIndex=t)}_setAttachments(e){this._attachmentsFromPrePass=e}_linkInternalTexture(e){this._multiRenderTarget.setInternalTexture(e,0,!1)}get renderList(){return this._multiRenderTarget.renderList}set renderList(e){this._multiRenderTarget.renderList=e}get isSupported(){return this._multiRenderTarget.isSupported}getTextureIndex(e){switch(e){case at.POSITION_TEXTURE_TYPE:return this._positionIndex;case at.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case at.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;default:return-1}}get enablePosition(){return this._enablePosition}set enablePosition(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableVelocity(){return this._enableVelocity}set enableVelocity(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=e}get enableReflectivity(){return this._enableReflectivity}set enableReflectivity(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get scene(){return this._scene}get ratio(){return this._ratio}constructor(e,t=1,i=15){this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._clearColor=new ge(0,0,0,0),this._clearDepthColor=new ge(1e8,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._linkedWithPrePass=!1,this.useSpecificClearForDepthTexture=!1,this._scene=e,this._ratio=t,this._useUbo=e.getEngine().supportsUniformBuffers,this._depthFormat=i,at._SceneComponentInitialization(this._scene),this._createRenderTargets()}isReady(e,t){const i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;const s=[],r=[A.PositionKind,A.NormalKind],n=e.getMesh();if(i){let d=!1;if(i.needAlphaTesting()&&i.getAlphaTestTexture()&&(s.push("#define ALPHATEST"),s.push(`#define ALPHATEST_UV${i.getAlphaTestTexture().coordinatesIndex+1}`),d=!0),i.bumpTexture&&H.BumpTextureEnabled&&(s.push("#define BUMP"),s.push(`#define BUMP_UV${i.bumpTexture.coordinatesIndex+1}`),d=!0),this._enableReflectivity){let _=!1;i.getClassName()==="PBRMetallicRoughnessMaterial"?(i.metallicRoughnessTexture!==null&&(s.push("#define ORMTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.metallicRoughnessTexture.coordinatesIndex+1}`),s.push("#define METALLICWORKFLOW"),d=!0,_=!0),i.metallic!==null&&(s.push("#define METALLIC"),s.push("#define METALLICWORKFLOW"),_=!0),i.roughness!==null&&(s.push("#define ROUGHNESS"),s.push("#define METALLICWORKFLOW"),_=!0),_&&(i.baseTexture!==null&&(s.push("#define ALBEDOTEXTURE"),s.push(`#define ALBEDO_UV${i.baseTexture.coordinatesIndex+1}`),i.baseTexture.gammaSpace&&s.push("#define GAMMAALBEDO"),d=!0),i.baseColor!==null&&s.push("#define ALBEDOCOLOR"))):i.getClassName()==="PBRSpecularGlossinessMaterial"?(i.specularGlossinessTexture!==null?(s.push("#define SPECULARGLOSSINESSTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.specularGlossinessTexture.coordinatesIndex+1}`),d=!0,i.specularGlossinessTexture.gammaSpace&&s.push("#define GAMMAREFLECTIVITYTEXTURE")):i.specularColor!==null&&s.push("#define REFLECTIVITYCOLOR"),i.glossiness!==null&&s.push("#define GLOSSINESS")):i.getClassName()==="PBRMaterial"?(i.metallicTexture!==null&&(s.push("#define ORMTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.metallicTexture.coordinatesIndex+1}`),s.push("#define METALLICWORKFLOW"),d=!0,_=!0),i.metallic!==null&&(s.push("#define METALLIC"),s.push("#define METALLICWORKFLOW"),_=!0),i.roughness!==null&&(s.push("#define ROUGHNESS"),s.push("#define METALLICWORKFLOW"),_=!0),_?(i.albedoTexture!==null&&(s.push("#define ALBEDOTEXTURE"),s.push(`#define ALBEDO_UV${i.albedoTexture.coordinatesIndex+1}`),i.albedoTexture.gammaSpace&&s.push("#define GAMMAALBEDO"),d=!0),i.albedoColor!==null&&s.push("#define ALBEDOCOLOR")):(i.reflectivityTexture!==null?(s.push("#define SPECULARGLOSSINESSTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.reflectivityTexture.coordinatesIndex+1}`),i.reflectivityTexture.gammaSpace&&s.push("#define GAMMAREFLECTIVITYTEXTURE"),d=!0):i.reflectivityColor!==null&&s.push("#define REFLECTIVITYCOLOR"),i.microSurface!==null&&s.push("#define GLOSSINESS"))):i.getClassName()==="StandardMaterial"&&(i.specularTexture!==null&&(s.push("#define REFLECTIVITYTEXTURE"),s.push(`#define REFLECTIVITY_UV${i.specularTexture.coordinatesIndex+1}`),i.specularTexture.gammaSpace&&s.push("#define GAMMAREFLECTIVITYTEXTURE"),d=!0),i.specularColor!==null&&s.push("#define REFLECTIVITYCOLOR"))}d&&(s.push("#define NEED_UV"),n.isVerticesDataPresent(A.UVKind)&&(r.push(A.UVKind),s.push("#define UV1")),n.isVerticesDataPresent(A.UV2Kind)&&(r.push(A.UV2Kind),s.push("#define UV2")))}this._linkedWithPrePass&&(s.push("#define PREPASS"),this._depthIndex!==-1&&(s.push("#define DEPTH_INDEX "+this._depthIndex),s.push("#define PREPASS_DEPTH")),this._normalIndex!==-1&&(s.push("#define NORMAL_INDEX "+this._normalIndex),s.push("#define PREPASS_NORMAL"))),this._enablePosition&&(s.push("#define POSITION"),s.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(s.push("#define VELOCITY"),s.push("#define VELOCITY_INDEX "+this._velocityIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(n)===-1&&s.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(s.push("#define REFLECTIVITY"),s.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),n.useBones&&n.computeBonesUsingShaders?(r.push(A.MatricesIndicesKind),r.push(A.MatricesWeightsKind),n.numBoneInfluencers>4&&(r.push(A.MatricesIndicesExtraKind),r.push(A.MatricesWeightsExtraKind)),s.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),s.push("#define BonesPerMesh "+(n.skeleton?n.skeleton.bones.length+1:0))):s.push("#define NUM_BONE_INFLUENCERS 0");const a=n.morphTargetManager;let o=0;a&&a.numInfluencers>0&&(o=a.numInfluencers,s.push("#define MORPHTARGETS"),s.push("#define NUM_MORPH_INFLUENCERS "+o),a.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),X.PrepareAttributesForMorphTargetsInfluencers(r,n,o)),t&&(s.push("#define INSTANCES"),X.PushAttributesForInstances(r,this._enableVelocity),e.getRenderingMesh().hasThinInstances&&s.push("#define THIN_INSTANCES")),this._linkedWithPrePass?s.push("#define RENDER_TARGET_COUNT "+this._attachmentsFromPrePass.length):s.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length),nn(i,this._scene,s);const h=this._scene.getEngine(),c=e._getDrawWrapper(void 0,!0),u=c.defines,f=s.join(`
8792
+ `);return u!==f&&c.setEffect(h.createEffect("geometry",{attributes:r,uniformsNames:Pl,samplers:["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets"],defines:f,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:o}},h),f),c.effect.isReady()}getGBuffer(){return this._multiRenderTarget}get samples(){return this._multiRenderTarget.samples}set samples(e){this._multiRenderTarget.samples=e}dispose(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.getGBuffer().dispose()}_assignRenderTargetIndices(){const e=[];let t=2;return e.push("gBuffer_Depth","gBuffer_Normal"),this._enablePosition&&(this._positionIndex=t,t++,e.push("gBuffer_Position")),this._enableVelocity&&(this._velocityIndex=t,t++,e.push("gBuffer_Velocity")),this._enableReflectivity&&(this._reflectivityIndex=t,t++,e.push("gBuffer_Reflectivity")),[t,e]}_createRenderTargets(){const e=this._scene.getEngine(),[t,i]=this._assignRenderTargetIndices();let s=0;if(e._caps.textureFloat&&e._caps.textureFloatLinearFiltering?s=1:e._caps.textureHalfFloat&&e._caps.textureHalfFloatLinearFiltering&&(s=2),this._multiRenderTarget=new Gg("gBuffer",{width:e.getRenderWidth()*this._ratio,height:e.getRenderHeight()*this._ratio},t,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:s,depthTextureFormat:this._depthFormat},i.concat("gBuffer_DepthBuffer")),!this.isSupported)return;this._multiRenderTarget.wrapU=O.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=O.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;const r=[!0],n=[!1],a=[!0];for(let f=1;f<t;++f)r.push(!0),a.push(!1),n.push(!0);const o=e.buildTextureLayout(r),h=e.buildTextureLayout(n),c=e.buildTextureLayout(a);this._multiRenderTarget.onClearObservable.add(f=>{f.bindAttachments(this.useSpecificClearForDepthTexture?h:o),f.clear(this._clearColor,!0,!0,!0),this.useSpecificClearForDepthTexture&&(f.bindAttachments(c),f.clear(this._clearDepthColor,!0,!0,!0)),f.bindAttachments(o)}),this._resizeObserver=e.onResizeObservable.add(()=>{this._multiRenderTarget&&this._multiRenderTarget.resize({width:e.getRenderWidth()*this._ratio,height:e.getRenderHeight()*this._ratio})});const u=f=>{const d=f.getRenderingMesh(),_=f.getEffectiveMesh(),p=this._scene,m=p.getEngine(),T=f.getMaterial();if(!T)return;if(_._internalAbstractMeshDataInfo._isActiveIntermediate=!1,this._enableVelocity&&!this._previousTransformationMatrices[_.uniqueId]&&(this._previousTransformationMatrices[_.uniqueId]={world:M.Identity(),viewProjection:p.getTransformMatrix()},d.skeleton)){const I=d.skeleton.getTransformMatrices(d);this._previousBonesTransformationMatrices[d.uniqueId]=this._copyBonesTransformationMatrices(I,new Float32Array(I.length))}const S=d._getInstancesRenderList(f._id,!!f.getReplacementMesh());if(S.mustReturn)return;const x=m.getCaps().instancedArrays&&(S.visibleInstances[f._id]!==null||d.hasThinInstances),b=_.getWorldMatrix();if(this.isReady(f,x)){const I=f._getDrawWrapper();if(!I)return;const R=I.effect;m.enableEffect(I),x||d._bind(f,R,T.fillMode),this._useUbo?(X.BindSceneUniformBuffer(R,this._scene.getSceneUniformBuffer()),this._scene.finalizeSceneUbo()):(R.setMatrix("viewProjection",p.getTransformMatrix()),R.setMatrix("view",p.getViewMatrix()));let C;const y=d._instanceDataStorage;if(!y.isFrozen&&(T.backFaceCulling||d.overrideMaterialSideOrientation!==null)){const w=_._getWorldMatrixDeterminant();C=d.overrideMaterialSideOrientation,C===null&&(C=T.sideOrientation),w<0&&(C=C===V.ClockWiseSideOrientation?V.CounterClockWiseSideOrientation:V.ClockWiseSideOrientation)}else C=y.sideOrientation;if(T._preBind(I,C),T.needAlphaTesting()){const w=T.getAlphaTestTexture();w&&(R.setTexture("diffuseSampler",w),R.setMatrix("diffuseMatrix",w.getTextureMatrix()))}T.bumpTexture&&p.getEngine().getCaps().standardDerivatives&&H.BumpTextureEnabled&&(R.setFloat3("vBumpInfos",T.bumpTexture.coordinatesIndex,1/T.bumpTexture.level,T.parallaxScaleBias),R.setMatrix("bumpMatrix",T.bumpTexture.getTextureMatrix()),R.setTexture("bumpSampler",T.bumpTexture),R.setFloat2("vTangentSpaceParams",T.invertNormalMapX?-1:1,T.invertNormalMapY?-1:1)),this._enableReflectivity&&(T.getClassName()==="PBRMetallicRoughnessMaterial"?(T.metallicRoughnessTexture!==null&&(R.setTexture("reflectivitySampler",T.metallicRoughnessTexture),R.setMatrix("reflectivityMatrix",T.metallicRoughnessTexture.getTextureMatrix())),T.metallic!==null&&R.setFloat("metallic",T.metallic),T.roughness!==null&&R.setFloat("glossiness",1-T.roughness),T.baseTexture!==null&&(R.setTexture("albedoSampler",T.baseTexture),R.setMatrix("albedoMatrix",T.baseTexture.getTextureMatrix())),T.baseColor!==null&&R.setColor3("albedoColor",T.baseColor)):T.getClassName()==="PBRSpecularGlossinessMaterial"?(T.specularGlossinessTexture!==null?(R.setTexture("reflectivitySampler",T.specularGlossinessTexture),R.setMatrix("reflectivityMatrix",T.specularGlossinessTexture.getTextureMatrix())):T.specularColor!==null&&R.setColor3("reflectivityColor",T.specularColor),T.glossiness!==null&&R.setFloat("glossiness",T.glossiness)):T.getClassName()==="PBRMaterial"?(T.metallicTexture!==null&&(R.setTexture("reflectivitySampler",T.metallicTexture),R.setMatrix("reflectivityMatrix",T.metallicTexture.getTextureMatrix())),T.metallic!==null&&R.setFloat("metallic",T.metallic),T.roughness!==null&&R.setFloat("glossiness",1-T.roughness),T.roughness!==null||T.metallic!==null||T.metallicTexture!==null?(T.albedoTexture!==null&&(R.setTexture("albedoSampler",T.albedoTexture),R.setMatrix("albedoMatrix",T.albedoTexture.getTextureMatrix())),T.albedoColor!==null&&R.setColor3("albedoColor",T.albedoColor)):(T.reflectivityTexture!==null?(R.setTexture("reflectivitySampler",T.reflectivityTexture),R.setMatrix("reflectivityMatrix",T.reflectivityTexture.getTextureMatrix())):T.reflectivityColor!==null&&R.setColor3("reflectivityColor",T.reflectivityColor),T.microSurface!==null&&R.setFloat("glossiness",T.microSurface))):T.getClassName()==="StandardMaterial"&&(T.specularTexture!==null&&(R.setTexture("reflectivitySampler",T.specularTexture),R.setMatrix("reflectivityMatrix",T.specularTexture.getTextureMatrix())),T.specularColor!==null&&R.setColor3("reflectivityColor",T.specularColor))),Xs(R,T,this._scene),d.useBones&&d.computeBonesUsingShaders&&d.skeleton&&(R.setMatrices("mBones",d.skeleton.getTransformMatrices(d)),this._enableVelocity&&R.setMatrices("mPreviousBones",this._previousBonesTransformationMatrices[d.uniqueId])),X.BindMorphTargetParameters(d,R),d.morphTargetManager&&d.morphTargetManager.isUsingTextureForTargets&&d.morphTargetManager._bind(R),this._enableVelocity&&(R.setMatrix("previousWorld",this._previousTransformationMatrices[_.uniqueId].world),R.setMatrix("previousViewProjection",this._previousTransformationMatrices[_.uniqueId].viewProjection)),x&&d.hasThinInstances&&R.setMatrix("world",b),d._processRendering(_,f,R,T.fillMode,S,x,(w,G)=>{w||R.setMatrix("world",G)})}this._enableVelocity&&(this._previousTransformationMatrices[_.uniqueId].world=b.clone(),this._previousTransformationMatrices[_.uniqueId].viewProjection=this._scene.getTransformMatrix().clone(),d.skeleton&&this._copyBonesTransformationMatrices(d.skeleton.getTransformMatrices(d),this._previousBonesTransformationMatrices[_.uniqueId]))};this._multiRenderTarget.customIsReadyFunction=(f,d,_)=>{if((_||d===0)&&f.subMeshes)for(let p=0;p<f.subMeshes.length;++p){const m=f.subMeshes[p],T=m.getMaterial(),S=m.getRenderingMesh();if(!T)continue;const x=S._getInstancesRenderList(m._id,!!m.getReplacementMesh()),b=e.getCaps().instancedArrays&&(x.visibleInstances[m._id]!==null||S.hasThinInstances);if(!this.isReady(m,b))return!1}return!0},this._multiRenderTarget.customRenderFunction=(f,d,_,p)=>{let m;if(this._linkedWithPrePass){if(!this._prePassRenderer.enabled)return;this._scene.getEngine().bindAttachments(this._attachmentsFromPrePass)}if(p.length){for(e.setColorWrite(!1),m=0;m<p.length;m++)u(p.data[m]);e.setColorWrite(!0)}for(m=0;m<f.length;m++)u(f.data[m]);for(e.setDepthWrite(!1),m=0;m<d.length;m++)u(d.data[m]);if(this.renderTransparentMeshes)for(m=0;m<_.length;m++)u(_.data[m]);e.setDepthWrite(!0)}}_copyBonesTransformationMatrices(e,t){for(let i=0;i<e.length;i++)t[i]=e[i];return t}}at.DEPTH_TEXTURE_TYPE=0,at.NORMAL_TEXTURE_TYPE=1,at.POSITION_TEXTURE_TYPE=2,at.VELOCITY_TEXTURE_TYPE=3,at.REFLECTIVITY_TEXTURE_TYPE=4,at._SceneComponentInitialization=l=>{throw fe("GeometryBufferRendererSceneComponent")};class $g{constructor(){this.enabled=!1,this.name="motionBlur",this.texturesRequired=[2]}}const Jg=Object.freeze(new K(0,0,0,0)),eE=Object.freeze(E.Zero()),tE=Object.freeze(ae.Zero()),iE=Object.freeze(ui.Zero()),sE=Object.freeze(z.Black());class rE{get currentFrame(){return this._currentFrame}get weight(){return this._weight}get currentValue(){return this._currentValue}get targetPath(){return this._targetPath}get target(){return this._currentActiveTarget}get isAdditive(){return this._host&&this._host.isAdditive}constructor(e,t,i,s){if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._absoluteFrameOffset=0,this._previousElapsedTime=0,this._previousAbsoluteFrame=0,this._targetIsArray=!1,this._animation=t,this._target=e,this._scene=i,this._host=s,this._activeTargets=[],t._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===N.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=M.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minValue=this._keys[0].value,this._maxValue=this._keys[this._keys.length-1].value,this._minFrame!==0){const n={frame:0,value:this._minValue};this._keys.splice(0,0,n)}if(this._target instanceof Array){let n=0;for(const a of this._target)this._preparePath(a,n),this._getOriginalValues(n),n++;this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];const r=t.getEvents();r&&r.length>0&&r.forEach(n=>{this._events.push(n._clone())}),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}_preparePath(e,t=0){const i=this._animation.targetPropertyPath;if(i.length>1){let s=e[i[0]];for(let r=1;r<i.length-1;r++)s=s[i[r]];this._targetPath=i[i.length-1],this._activeTargets[t]=s}else this._targetPath=i[0],this._activeTargets[t]=e}get animation(){return this._animation}reset(e=!1){if(e)if(this._target instanceof Array){let t=0;for(const i of this._target)this._originalValue[t]!==void 0&&this._setValue(i,this._activeTargets[t],this._originalValue[t],-1,t),t++}else this._originalValue[0]!==void 0&&this._setValue(this._target,this._directTarget,this._originalValue[0],-1,0);this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0;for(let t=0;t<this._events.length;t++)this._events[t].isDone=!1}isStopped(){return this._stopped}dispose(){const e=this._animation.runtimeAnimations.indexOf(this);e>-1&&this._animation.runtimeAnimations.splice(e,1)}setValue(e,t){if(this._targetIsArray){for(let i=0;i<this._target.length;i++){const s=this._target[i];this._setValue(s,this._activeTargets[i],e,t,i)}return}this._setValue(this._target,this._directTarget,e,t,0)}_getOriginalValues(e=0){let t;const i=this._activeTargets[e];i.getRestPose&&this._targetPath==="_matrix"?t=i.getRestPose():t=i[this._targetPath],t&&t.clone?this._originalValue[e]=t.clone():this._originalValue[e]=t}_setValue(e,t,i,s,r){if(this._currentActiveTarget=t,this._weight=s,this._enableBlending&&this._blendingFactor<=1){if(!this._originalBlendValue){const a=t[this._targetPath];a.clone?this._originalBlendValue=a.clone():this._originalBlendValue=a}this._originalBlendValue.m?N.AllowMatrixDecomposeForInterpolation?this._currentValue?M.DecomposeLerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=M.DecomposeLerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue?M.LerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=M.Lerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue=N._UniversalLerp(this._originalBlendValue,i,this._blendingFactor);const n=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=n}else this._currentValue?this._currentValue.copyFrom?this._currentValue.copyFrom(i):this._currentValue=i:i!=null&&i.clone?this._currentValue=i.clone():this._currentValue=i;s!==-1?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[r]):t[this._targetPath]=this._currentValue,e.markAsDirty&&e.markAsDirty(this._animation.targetProperty)}_getCorrectLoopMode(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode}goToFrame(e){const t=this._animation.getKeys();e<t[0].frame?e=t[0].frame:e>t[t.length-1].frame&&(e=t[t.length-1].frame);const i=this._events;if(i.length)for(let r=0;r<i.length;r++)i[r].onlyOnce||(i[r].isDone=i[r].frame<e);this._currentFrame=e;const s=this._animation._interpolate(e,this._animationState);this.setValue(s,-1)}_prepareForSpeedRatioChange(e){const t=this._previousElapsedTime*(this._animation.framePerSecond*e)/1e3;this._absoluteFrameOffset=this._previousAbsoluteFrame-t}animate(e,t,i,s,r,n=-1){const a=this._animation,o=a.targetPropertyPath;if(!o||o.length<1)return this._stopped=!0,!1;let h=!0;(t<this._minFrame||t>this._maxFrame)&&(t=this._minFrame),(i<this._minFrame||i>this._maxFrame)&&(i=this._maxFrame);const c=i-t;let u,f=e*(a.framePerSecond*r)/1e3+this._absoluteFrameOffset,d=0;if(s&&this._animationState.loopMode===N.ANIMATIONLOOPMODE_YOYO){const T=(f-t)/c;f=Math.abs(Math.sin(T*Math.PI))*c+t}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=f,!s&&i>=t&&f>=c)h=!1,d=a._getKeyValue(this._maxValue);else if(!s&&t>=i&&f<=c)h=!1,d=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==N.ANIMATIONLOOPMODE_CYCLE){const T=i.toString()+t.toString();if(!this._offsetsCache[T]){this._animationState.repeatCount=0,this._animationState.loopMode=N.ANIMATIONLOOPMODE_CYCLE;const S=a._interpolate(t,this._animationState),x=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case N.ANIMATIONTYPE_FLOAT:this._offsetsCache[T]=x-S;break;case N.ANIMATIONTYPE_QUATERNION:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_VECTOR3:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_VECTOR2:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_SIZE:this._offsetsCache[T]=x.subtract(S);break;case N.ANIMATIONTYPE_COLOR3:this._offsetsCache[T]=x.subtract(S);break}this._highLimitsCache[T]=x}d=this._highLimitsCache[T],u=this._offsetsCache[T]}if(u===void 0)switch(a.dataType){case N.ANIMATIONTYPE_FLOAT:u=0;break;case N.ANIMATIONTYPE_QUATERNION:u=Jg;break;case N.ANIMATIONTYPE_VECTOR3:u=eE;break;case N.ANIMATIONTYPE_VECTOR2:u=tE;break;case N.ANIMATIONTYPE_SIZE:u=iE;break;case N.ANIMATIONTYPE_COLOR3:u=sE}let _;if(this._host&&this._host.syncRoot){const T=this._host.syncRoot,S=(T.masterFrame-T.fromFrame)/(T.toFrame-T.fromFrame);_=t+c*S}else f>0&&t>i||f<0&&t<i?_=h&&c!==0?i+f%c:t:_=h&&c!==0?t+f%c:i;const p=this._events;if(r>0&&this.currentFrame>_||r<0&&this.currentFrame<_){this._onLoop();for(let T=0;T<p.length;T++)p[T].onlyOnce||(p[T].isDone=!1);this._animationState.key=r>0?0:a.getKeys().length-1}this._currentFrame=_,this._animationState.repeatCount=c===0?0:f/c>>0,this._animationState.highLimitValue=d,this._animationState.offsetValue=u;const m=a._interpolate(_,this._animationState);if(this.setValue(m,n),p.length){for(let T=0;T<p.length;T++)if(c>0&&_>=p[T].frame&&p[T].frame>=t||c<0&&_<=p[T].frame&&p[T].frame<=t){const S=p[T];S.isDone||(S.onlyOnce&&(p.splice(T,1),T--),S.isDone=!0,S.action(_))}}return h||(this._stopped=!0),h}}class Ol{get syncRoot(){return this._syncRoot}get masterFrame(){return this._runtimeAnimations.length===0?0:this._runtimeAnimations[0].currentFrame}get weight(){return this._weight}set weight(e){if(e===-1){this._weight=-1;return}this._weight=Math.min(Math.max(e,0),1)}get speedRatio(){return this._speedRatio}set speedRatio(e){for(let t=0;t<this._runtimeAnimations.length;t++)this._runtimeAnimations[t]._prepareForSpeedRatioChange(e);this._speedRatio=e,this._goToFrame!==null&&this.goToFrame(this._goToFrame)}constructor(e,t,i=0,s=100,r=!1,n=1,a,o,h,c=!1,u=0){this.target=t,this.fromFrame=i,this.toFrame=s,this.loopAnimation=r,this.onAnimationEnd=a,this.onAnimationLoop=h,this.isAdditive=c,this.playOrder=u,this._localDelayOffset=null,this._pausedDelay=null,this._manualJumpDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this._syncRoot=null,this._frameToSyncFromJump=null,this._goToFrame=null,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new B,this.onAnimationLoopObservable=new B,this._scene=e,o&&this.appendAnimations(t,o),this._speedRatio=n,e._activeAnimatables.push(this)}syncWith(e){if(this._syncRoot=e,e){const t=this._scene._activeAnimatables.indexOf(this);t>-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this}getAnimations(){return this._runtimeAnimations}appendAnimations(e,t){for(let i=0;i<t.length;i++){const s=t[i],r=new rE(e,s,this._scene,this);r._onLoop=()=>{this.onAnimationLoopObservable.notifyObservers(this),this.onAnimationLoop&&this.onAnimationLoop()},this._runtimeAnimations.push(r)}}getAnimationByTargetProperty(e){const t=this._runtimeAnimations;for(let i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i].animation;return null}getRuntimeAnimationByTargetProperty(e){const t=this._runtimeAnimations;for(let i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i];return null}reset(){const e=this._runtimeAnimations;for(let t=0;t<e.length;t++)e[t].reset(!0);this._localDelayOffset=null,this._pausedDelay=null}enableBlending(e){const t=this._runtimeAnimations;for(let i=0;i<t.length;i++)t[i].animation.enableBlending=!0,t[i].animation.blendingSpeed=e}disableBlending(){const e=this._runtimeAnimations;for(let t=0;t<e.length;t++)e[t].animation.enableBlending=!1}goToFrame(e){var t;const i=this._runtimeAnimations;if(i[0]){const s=i[0].animation.framePerSecond;this._frameToSyncFromJump=(t=this._frameToSyncFromJump)!==null&&t!==void 0?t:i[0].currentFrame;const r=this.speedRatio===0?0:(e-this._frameToSyncFromJump)/s*1e3/this.speedRatio;this._manualJumpDelay=-r}for(let s=0;s<i.length;s++)i[s].goToFrame(e);this._goToFrame=e}pause(){this._paused||(this._paused=!0)}restart(){this._paused=!1}_raiseOnAnimationEnd(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)}stop(e,t,i=!1){if(e||t){const s=this._scene._activeAnimatables.indexOf(this);if(s>-1){const r=this._runtimeAnimations;for(let n=r.length-1;n>=0;n--){const a=r[n];e&&a.animation.name!=e||t&&!t(a.target)||(a.dispose(),r.splice(n,1))}r.length==0&&(i||this._scene._activeAnimatables.splice(s,1),this._raiseOnAnimationEnd())}}else{const s=this._scene._activeAnimatables.indexOf(this);if(s>-1){i||this._scene._activeAnimatables.splice(s,1);const r=this._runtimeAnimations;for(let n=0;n<r.length;n++)r[n].dispose();this._runtimeAnimations.length=0,this._raiseOnAnimationEnd()}}}waitAsync(){return new Promise(e=>{this.onAnimationEndObservable.add(()=>{e(this)},void 0,void 0,this,!0)})}_animate(e){if(this._paused)return this.animationStarted=!1,this._pausedDelay===null&&(this._pausedDelay=e),!0;if(this._localDelayOffset===null?(this._localDelayOffset=e,this._pausedDelay=null):this._pausedDelay!==null&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null),this._manualJumpDelay!==null&&(this._localDelayOffset+=this._manualJumpDelay,this._manualJumpDelay=null,this._frameToSyncFromJump=null),this._goToFrame=null,this._weight===0)return!0;let t=!1;const i=this._runtimeAnimations;let s;for(s=0;s<i.length;s++){const n=i[s].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);t=t||n}if(this.animationStarted=t,!t){if(this.disposeOnEnd)for(s=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(s,1),s=0;s<i.length;s++)i[s].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationLoop=null,this.onAnimationLoopObservable.clear(),this.onAnimationEndObservable.clear())}return t}}Ie.prototype._animate=function(){if(!this.animationsEnabled)return;const l=ii.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=l}this.deltaTime=this.useConstantAnimationDeltaTime?16:(l-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=l;const e=this._activeAnimatables;if(e.length===0)return;this._animationTime+=this.deltaTime;const t=this._animationTime;for(let i=0;i<e.length;i++){const s=e[i];!s._animate(t)&&s.disposeOnEnd&&i--}this._processLateAnimationBindings()},Ie.prototype.sortActiveAnimatables=function(){this._activeAnimatables.sort((l,e)=>l.playOrder-e.playOrder)},Ie.prototype.beginWeightedAnimation=function(l,e,t,i=1,s,r=1,n,a,o,h,c=!1){const u=this.beginAnimation(l,e,t,s,r,n,a,!1,o,h,c);return u.weight=i,u},Ie.prototype.beginAnimation=function(l,e,t,i,s=1,r,n,a=!0,o,h,c=!1){e>t&&s>0&&(s*=-1),a&&this.stopAnimation(l,void 0,o),n||(n=new Ol(this,l,e,t,i,s,r,void 0,h,c));const u=o?o(l):!0;if(l.animations&&u&&n.appendAnimations(l,l.animations),l.getAnimatables){const f=l.getAnimatables();for(let d=0;d<f.length;d++)this.beginAnimation(f[d],e,t,i,s,r,n,a,o,h)}return n.reset(),n},Ie.prototype.beginHierarchyAnimation=function(l,e,t,i,s,r=1,n,a,o=!0,h,c,u=!1){const f=l.getDescendants(e),d=[];d.push(this.beginAnimation(l,t,i,s,r,n,a,o,h,void 0,u));for(const _ of f)d.push(this.beginAnimation(_,t,i,s,r,n,a,o,h,void 0,u));return d},Ie.prototype.beginDirectAnimation=function(l,e,t,i,s,r,n,a,o=!1){if(r===void 0&&(r=1),t>i&&r>0)r*=-1;else if(i>t&&r<0){const c=i;i=t,t=c}return new Ol(this,l,t,i,s,r,n,e,a,o)},Ie.prototype.beginDirectHierarchyAnimation=function(l,e,t,i,s,r,n,a,o,h=!1){const c=l.getDescendants(e),u=[];u.push(this.beginDirectAnimation(l,t,i,s,r,n,a,o,h));for(const f of c)u.push(this.beginDirectAnimation(f,t,i,s,r,n,a,o,h));return u},Ie.prototype.getAnimatableByTarget=function(l){for(let e=0;e<this._activeAnimatables.length;e++)if(this._activeAnimatables[e].target===l)return this._activeAnimatables[e];return null},Ie.prototype.getAllAnimatablesByTarget=function(l){const e=[];for(let t=0;t<this._activeAnimatables.length;t++)this._activeAnimatables[t].target===l&&e.push(this._activeAnimatables[t]);return e},Ie.prototype.stopAnimation=function(l,e,t){const i=this.getAllAnimatablesByTarget(l);for(const s of i)s.stop(e,t)},Ie.prototype.stopAllAnimations=function(){if(this._activeAnimatables){for(let l=0;l<this._activeAnimatables.length;l++)this._activeAnimatables[l].stop(void 0,void 0,!0);this._activeAnimatables.length=0}for(const l of this.animationGroups)l.stop()},Ie.prototype._registerTargetForLateAnimationBinding=function(l,e){const t=l.target;this._registeredForLateAnimationBindings.pushNoDuplicate(t),t._lateAnimationHolders||(t._lateAnimationHolders={}),t._lateAnimationHolders[l.targetPath]||(t._lateAnimationHolders[l.targetPath]={totalWeight:0,totalAdditiveWeight:0,animations:[],additiveAnimations:[],originalValue:e}),l.isAdditive?(t._lateAnimationHolders[l.targetPath].additiveAnimations.push(l),t._lateAnimationHolders[l.targetPath].totalAdditiveWeight+=l.weight):(t._lateAnimationHolders[l.targetPath].animations.push(l),t._lateAnimationHolders[l.targetPath].totalWeight+=l.weight)},Ie.prototype._processLateAnimationBindingsForMatrices=function(l){if(l.totalWeight===0&&l.totalAdditiveWeight===0)return l.originalValue;let e=1;const t=D.Vector3[0],i=D.Vector3[1],s=D.Quaternion[0];let r=0;const n=l.animations[0],a=l.originalValue;let o=1,h=!1;if(l.totalWeight<1)o=1-l.totalWeight,a.decompose(i,s,t);else{if(r=1,e=l.totalWeight,o=n.weight/e,o==1)if(l.totalAdditiveWeight)h=!0;else return n.currentValue;n.currentValue.decompose(i,s,t)}if(!h){i.scaleInPlace(o),t.scaleInPlace(o),s.scaleInPlace(o);for(let u=r;u<l.animations.length;u++){const f=l.animations[u];if(f.weight===0)continue;o=f.weight/e;const d=D.Vector3[2],_=D.Vector3[3],p=D.Quaternion[1];f.currentValue.decompose(_,p,d),_.scaleAndAddToRef(o,i),p.scaleAndAddToRef(K.Dot(s,p)>0?o:-o,s),d.scaleAndAddToRef(o,t)}s.normalize()}for(let u=0;u<l.additiveAnimations.length;u++){const f=l.additiveAnimations[u];if(f.weight===0)continue;const d=D.Vector3[2],_=D.Vector3[3],p=D.Quaternion[1];f.currentValue.decompose(_,p,d),_.multiplyToRef(i,_),E.LerpToRef(i,_,f.weight,i),s.multiplyToRef(p,p),K.SlerpToRef(s,p,f.weight,s),d.scaleAndAddToRef(f.weight,t)}const c=n?n._animationState.workValue:D.Matrix[0].clone();return M.ComposeToRef(i,s,t,c),c},Ie.prototype._processLateAnimationBindingsForQuaternions=function(l,e){if(l.totalWeight===0&&l.totalAdditiveWeight===0)return e;const t=l.animations[0],i=l.originalValue;let s=e;if(l.totalWeight===0&&l.totalAdditiveWeight>0)s.copyFrom(i);else if(l.animations.length===1){if(K.SlerpToRef(i,t.currentValue,Math.min(1,l.totalWeight),s),l.totalAdditiveWeight===0)return s}else if(l.animations.length>1){let r=1,n,a;if(l.totalWeight<1){const h=1-l.totalWeight;n=[],a=[],n.push(i),a.push(h)}else{if(l.animations.length===2&&(K.SlerpToRef(l.animations[0].currentValue,l.animations[1].currentValue,l.animations[1].weight/l.totalWeight,e),l.totalAdditiveWeight===0))return e;n=[],a=[],r=l.totalWeight}for(let h=0;h<l.animations.length;h++){const c=l.animations[h];n.push(c.currentValue),a.push(c.weight/r)}let o=0;for(let h=0;h<n.length;){if(!h){K.SlerpToRef(n[h],n[h+1],a[h+1]/(a[h]+a[h+1]),e),s=e,o=a[h]+a[h+1],h+=2;continue}o+=a[h],K.SlerpToRef(s,n[h],a[h]/o,s),h++}}for(let r=0;r<l.additiveAnimations.length;r++){const n=l.additiveAnimations[r];n.weight!==0&&(s.multiplyToRef(n.currentValue,D.Quaternion[0]),K.SlerpToRef(s,D.Quaternion[0],n.weight,s))}return s},Ie.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(let l=0;l<this._registeredForLateAnimationBindings.length;l++){const e=this._registeredForLateAnimationBindings.data[l];for(const t in e._lateAnimationHolders){const i=e._lateAnimationHolders[t],s=i.animations[0],r=i.originalValue;if(r==null)continue;const n=N.AllowMatrixDecomposeForInterpolation&&r.m;let a=e[t];if(n)a=this._processLateAnimationBindingsForMatrices(i);else if(r.w!==void 0)a=this._processLateAnimationBindingsForQuaternions(i,a||K.Identity());else{let h=0,c=1;if(i.totalWeight<1)s&&r.scale?a=r.scale(1-i.totalWeight):s?a=r*(1-i.totalWeight):r.clone?a=r.clone():a=r;else if(s){c=i.totalWeight;const u=s.weight/c;u!==1?s.currentValue.scale?a=s.currentValue.scale(u):a=s.currentValue*u:a=s.currentValue,h=1}for(let u=h;u<i.animations.length;u++){const f=i.animations[u],d=f.weight/c;if(d)f.currentValue.scaleAndAddToRef?f.currentValue.scaleAndAddToRef(d,a):a+=f.currentValue*d;else continue}for(let u=0;u<i.additiveAnimations.length;u++){const f=i.additiveAnimations[u],d=f.weight;if(d)f.currentValue.scaleAndAddToRef?f.currentValue.scaleAndAddToRef(d,a):a+=f.currentValue*d;else continue}}e[t]=a}e._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},Ue.prototype.copyAnimationRange=function(l,e,t,i=!1,s=null){this.animations.length===0&&(this.animations.push(new N(this.name,"_matrix",l.animations[0].framePerSecond,N.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));const r=l.animations[0].getRange(e);if(!r)return!1;const n=r.from,a=r.to,o=l.animations[0].getKeys(),h=l.length,c=l.getParent(),u=this.getParent(),f=i&&c&&h&&this.length&&h!==this.length,d=f&&u&&c?u.length/c.length:1,_=i&&!u&&s&&(s.x!==1||s.y!==1||s.z!==1),p=this.animations[0].getKeys();let m,T,S;for(let x=0,b=o.length;x<b;x++)m=o[x],m.frame>=n&&m.frame<=a&&(i?(S=m.value.clone(),f?(T=S.getTranslation(),S.setTranslation(T.scaleInPlace(d))):_&&s?(T=S.getTranslation(),S.setTranslation(T.multiplyInPlace(s))):S=m.value):S=m.value,p.push({frame:m.frame+t,value:S}));return this.animations[0].createRange(e,n+t,a+t),!0},Object.defineProperty(Ie.prototype,"geometryBufferRenderer",{get:function(){return this._geometryBufferRenderer},set:function(l){l&&l.isSupported&&(this._geometryBufferRenderer=l)},enumerable:!0,configurable:!0}),Ie.prototype.enableGeometryBufferRenderer=function(l=1,e=15){return this._geometryBufferRenderer?this._geometryBufferRenderer:(this._geometryBufferRenderer=new at(this,l,e),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null),this._geometryBufferRenderer)},Ie.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};class nE{constructor(e){this.name=ee.NAME_GEOMETRYBUFFERRENDERER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(ee.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)}rebuild(){}dispose(){}_gatherRenderTargets(e){this.scene._geometryBufferRenderer&&e.push(this.scene._geometryBufferRenderer.getGBuffer())}}at._SceneComponentInitialization=l=>{let e=l._getComponent(ee.NAME_GEOMETRYBUFFERRENDERER);e||(e=new nE(l),l._addComponent(e))};const aE="motionBlurPixelShader",oE=`varying vec2 vUV;
8793
8793
  uniform sampler2D textureSampler;
8794
8794
  uniform float motionStrength;
8795
8795
  uniform float motionScale;
@@ -8860,10 +8860,10 @@ gl_FragColor=result/float(nSamples);
8860
8860
  gl_FragColor=texture2D(textureSampler,vUV);
8861
8861
  #endif
8862
8862
  }
8863
- `;U.ShadersStore[nE]=aE;class Ps extends ue{get motionBlurSamples(){return this._motionBlurSamples}set motionBlurSamples(e){this._motionBlurSamples=e,this._updateEffect()}get isObjectBased(){return this._isObjectBased}set isObjectBased(e){this._isObjectBased!==e&&(this._isObjectBased=e,this._applyMode())}get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}getClassName(){return"MotionBlurPostProcess"}constructor(e,t,i,s,r,n,a,o=0,h=!1,c=!1){super(e,"motionBlur",["motionStrength","motionScale","screenSize","inverseViewProjection","prevViewProjection","projection"],["velocitySampler","depthSampler"],i,s,r,n,a,`#define GEOMETRY_SUPPORTED
8863
+ `;U.ShadersStore[aE]=oE;class Ps extends ue{get motionBlurSamples(){return this._motionBlurSamples}set motionBlurSamples(e){this._motionBlurSamples=e,this._updateEffect()}get isObjectBased(){return this._isObjectBased}set isObjectBased(e){this._isObjectBased!==e&&(this._isObjectBased=e,this._applyMode())}get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}getClassName(){return"MotionBlurPostProcess"}constructor(e,t,i,s,r,n,a,o=0,h=!1,c=!1){super(e,"motionBlur",["motionStrength","motionScale","screenSize","inverseViewProjection","prevViewProjection","projection"],["velocitySampler","depthSampler"],i,s,r,n,a,`#define GEOMETRY_SUPPORTED
8864
8864
  #define SAMPLES 64.0
8865
- #define OBJECT_BASED`,o,void 0,null,h),this.motionStrength=1,this._motionBlurSamples=32,this._isObjectBased=!0,this._forceGeometryBuffer=!1,this._invViewProjection=null,this._previousViewProjection=null,this._forceGeometryBuffer=c,this._forceGeometryBuffer?(t.enableGeometryBufferRenderer(),this._geometryBufferRenderer&&(this._geometryBufferRenderer.enableVelocity=!0)):(t.enablePrePassRenderer(),this._prePassRenderer&&(this._prePassRenderer.markAsDirty(),this._prePassEffectConfiguration=new Qg)),this._applyMode()}excludeSkinnedMesh(e){if(e.skeleton){let t;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else if(this._prePassRenderer)t=this._prePassRenderer.excludedSkinnedMesh;else return;t.push(e)}}removeExcludedSkinnedMesh(e){if(e.skeleton){let t;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else if(this._prePassRenderer)t=this._prePassRenderer.excludedSkinnedMesh;else return;const i=t.indexOf(e);i!==-1&&t.splice(i,1)}}dispose(e){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={},this._geometryBufferRenderer._previousBonesTransformationMatrices={},this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity=[]),super.dispose(e)}_applyMode(){if(!this._geometryBufferRenderer&&!this._prePassRenderer)return F.Warn("Multiple Render Target support needed to compute object based motion blur"),this.updateEffect();this._updateEffect(),this._invViewProjection=null,this._previousViewProjection=null,this.isObjectBased?(this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=2),this.onApply=e=>this._onApplyObjectBased(e)):(this._invViewProjection=M.Identity(),this._previousViewProjection=this._scene.getTransformMatrix().clone(),this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=5),this.onApply=e=>this._onApplyScreenBased(e))}_onApplyObjectBased(e){if(e.setVector2("screenSize",new ae(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){const t=this._geometryBufferRenderer.getTextureIndex(at.VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",this._geometryBufferRenderer.getGBuffer().textures[t])}else if(this._prePassRenderer){const t=this._prePassRenderer.getIndex(2);e.setTexture("velocitySampler",this._prePassRenderer.getRenderTarget().textures[t])}}_onApplyScreenBased(e){const t=D.Matrix[0];if(t.copyFrom(this._scene.getTransformMatrix()),t.invertToRef(this._invViewProjection),e.setMatrix("inverseViewProjection",this._invViewProjection),e.setMatrix("prevViewProjection",this._previousViewProjection),this._previousViewProjection.copyFrom(t),e.setMatrix("projection",this._scene.getProjectionMatrix()),e.setVector2("screenSize",new ae(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){const i=this._geometryBufferRenderer.getTextureIndex(at.DEPTH_TEXTURE_TYPE);e.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[i])}else if(this._prePassRenderer){const i=this._prePassRenderer.getIndex(5);e.setTexture("depthSampler",this._prePassRenderer.getRenderTarget().textures[i])}}_updateEffect(){if(this._geometryBufferRenderer||this._prePassRenderer){const e=["#define GEOMETRY_SUPPORTED","#define SAMPLES "+this._motionBlurSamples.toFixed(1),this._isObjectBased?"#define OBJECT_BASED":"#define SCREEN_BASED"];this.updateEffect(e.join(`
8866
- `))}}static _Parse(e,t,i,s){return J.Parse(()=>new Ps(e.name,i,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1),e,i,s)}}g([v()],Ps.prototype,"motionStrength",void 0),g([v()],Ps.prototype,"motionBlurSamples",null),g([v()],Ps.prototype,"isObjectBased",null),Re("BABYLON.MotionBlurPostProcess",Ps);class oE{constructor(){this.enabled=!1,this.name="screenSpaceReflections",this.texturesRequired=[6,3,1]}}const lE="screenSpaceReflectionPixelShader",hE=`uniform sampler2D textureSampler;
8865
+ #define OBJECT_BASED`,o,void 0,null,h),this.motionStrength=1,this._motionBlurSamples=32,this._isObjectBased=!0,this._forceGeometryBuffer=!1,this._invViewProjection=null,this._previousViewProjection=null,this._forceGeometryBuffer=c,this._forceGeometryBuffer?(t.enableGeometryBufferRenderer(),this._geometryBufferRenderer&&(this._geometryBufferRenderer.enableVelocity=!0)):(t.enablePrePassRenderer(),this._prePassRenderer&&(this._prePassRenderer.markAsDirty(),this._prePassEffectConfiguration=new $g)),this._applyMode()}excludeSkinnedMesh(e){if(e.skeleton){let t;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else if(this._prePassRenderer)t=this._prePassRenderer.excludedSkinnedMesh;else return;t.push(e)}}removeExcludedSkinnedMesh(e){if(e.skeleton){let t;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else if(this._prePassRenderer)t=this._prePassRenderer.excludedSkinnedMesh;else return;const i=t.indexOf(e);i!==-1&&t.splice(i,1)}}dispose(e){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={},this._geometryBufferRenderer._previousBonesTransformationMatrices={},this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity=[]),super.dispose(e)}_applyMode(){if(!this._geometryBufferRenderer&&!this._prePassRenderer)return F.Warn("Multiple Render Target support needed to compute object based motion blur"),this.updateEffect();this._updateEffect(),this._invViewProjection=null,this._previousViewProjection=null,this.isObjectBased?(this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=2),this.onApply=e=>this._onApplyObjectBased(e)):(this._invViewProjection=M.Identity(),this._previousViewProjection=this._scene.getTransformMatrix().clone(),this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=5),this.onApply=e=>this._onApplyScreenBased(e))}_onApplyObjectBased(e){if(e.setVector2("screenSize",new ae(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){const t=this._geometryBufferRenderer.getTextureIndex(at.VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",this._geometryBufferRenderer.getGBuffer().textures[t])}else if(this._prePassRenderer){const t=this._prePassRenderer.getIndex(2);e.setTexture("velocitySampler",this._prePassRenderer.getRenderTarget().textures[t])}}_onApplyScreenBased(e){const t=D.Matrix[0];if(t.copyFrom(this._scene.getTransformMatrix()),t.invertToRef(this._invViewProjection),e.setMatrix("inverseViewProjection",this._invViewProjection),e.setMatrix("prevViewProjection",this._previousViewProjection),this._previousViewProjection.copyFrom(t),e.setMatrix("projection",this._scene.getProjectionMatrix()),e.setVector2("screenSize",new ae(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){const i=this._geometryBufferRenderer.getTextureIndex(at.DEPTH_TEXTURE_TYPE);e.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[i])}else if(this._prePassRenderer){const i=this._prePassRenderer.getIndex(5);e.setTexture("depthSampler",this._prePassRenderer.getRenderTarget().textures[i])}}_updateEffect(){if(this._geometryBufferRenderer||this._prePassRenderer){const e=["#define GEOMETRY_SUPPORTED","#define SAMPLES "+this._motionBlurSamples.toFixed(1),this._isObjectBased?"#define OBJECT_BASED":"#define SCREEN_BASED"];this.updateEffect(e.join(`
8866
+ `))}}static _Parse(e,t,i,s){return J.Parse(()=>new Ps(e.name,i,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1),e,i,s)}}g([v()],Ps.prototype,"motionStrength",void 0),g([v()],Ps.prototype,"motionBlurSamples",null),g([v()],Ps.prototype,"isObjectBased",null),Re("BABYLON.MotionBlurPostProcess",Ps);class lE{constructor(){this.enabled=!1,this.name="screenSpaceReflections",this.texturesRequired=[6,3,1]}}const hE="screenSpaceReflectionPixelShader",cE=`uniform sampler2D textureSampler;
8867
8867
  #ifdef SSR_SUPPORTED
8868
8868
  uniform sampler2D reflectivitySampler;
8869
8869
  uniform sampler2D normalSampler;
@@ -8996,11 +8996,11 @@ gl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFul
8996
8996
  gl_FragColor=texture2D(textureSampler,vUV);
8997
8997
  #endif
8998
8998
  }
8999
- `;U.ShadersStore[lE]=hE;class di extends ue{get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}getClassName(){return"ScreenSpaceReflectionPostProcess"}constructor(e,t,i,s,r,n,a,o=0,h=!1,c=!1){if(super(e,"screenSpaceReflection",["projection","view","threshold","reflectionSpecularFalloffExponent","strength","stepSize","roughnessFactor"],["textureSampler","normalSampler","positionSampler","reflectivitySampler"],i,s,r,n,a,`#define SSR_SUPPORTED
8999
+ `;U.ShadersStore[hE]=cE;class di extends ue{get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}getClassName(){return"ScreenSpaceReflectionPostProcess"}constructor(e,t,i,s,r,n,a,o=0,h=!1,c=!1){if(super(e,"screenSpaceReflection",["projection","view","threshold","reflectionSpecularFalloffExponent","strength","stepSize","roughnessFactor"],["textureSampler","normalSampler","positionSampler","reflectivitySampler"],i,s,r,n,a,`#define SSR_SUPPORTED
9000
9000
  #define REFLECTION_SAMPLES 64
9001
9001
  #define SMOOTH_STEPS 5
9002
- `,o,void 0,null,h),this.threshold=1.2,this.strength=1,this.reflectionSpecularFalloffExponent=3,this.step=1,this.roughnessFactor=.2,this._forceGeometryBuffer=!1,this._enableSmoothReflections=!1,this._reflectionSamples=64,this._smoothSteps=5,this._forceGeometryBuffer=c,this._forceGeometryBuffer){const u=t.enableGeometryBufferRenderer();u&&u.isSupported&&(u.enablePosition=!0,u.enableReflectivity=!0)}else{const u=t.enablePrePassRenderer();u==null||u.markAsDirty(),this._prePassEffectConfiguration=new oE}this._updateEffectDefines(),this.onApply=u=>{const f=this._geometryBufferRenderer,d=this._prePassRenderer;if(!d&&!f)return;if(f){const T=f.getTextureIndex(at.POSITION_TEXTURE_TYPE),S=f.getTextureIndex(at.REFLECTIVITY_TEXTURE_TYPE);u.setTexture("normalSampler",f.getGBuffer().textures[1]),u.setTexture("positionSampler",f.getGBuffer().textures[T]),u.setTexture("reflectivitySampler",f.getGBuffer().textures[S])}else if(d){const T=d.getIndex(1),S=d.getIndex(3),x=d.getIndex(6);u.setTexture("normalSampler",d.getRenderTarget().textures[x]),u.setTexture("positionSampler",d.getRenderTarget().textures[T]),u.setTexture("reflectivitySampler",d.getRenderTarget().textures[S])}const _=t.activeCamera;if(!_)return;const p=_.getViewMatrix(!0),m=_.getProjectionMatrix(!0);u.setMatrix("projection",m),u.setMatrix("view",p),u.setFloat("threshold",this.threshold),u.setFloat("reflectionSpecularFalloffExponent",this.reflectionSpecularFalloffExponent),u.setFloat("strength",this.strength),u.setFloat("stepSize",this.step),u.setFloat("roughnessFactor",this.roughnessFactor)},this._isSceneRightHanded=t.useRightHandedSystem}get enableSmoothReflections(){return this._enableSmoothReflections}set enableSmoothReflections(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())}get reflectionSamples(){return this._reflectionSamples}set reflectionSamples(e){e!==this._reflectionSamples&&(this._reflectionSamples=e,this._updateEffectDefines())}get smoothSteps(){return this._smoothSteps}set smoothSteps(e){e!==this._smoothSteps&&(this._smoothSteps=e,this._updateEffectDefines())}_updateEffectDefines(){const e=[];(this._geometryBufferRenderer||this._prePassRenderer)&&e.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&e.push("#define ENABLE_SMOOTH_REFLECTIONS"),this._isSceneRightHanded&&e.push("#define RIGHT_HANDED_SCENE"),e.push("#define REFLECTION_SAMPLES "+(this._reflectionSamples>>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join(`
9003
- `))}static _Parse(e,t,i,s){return J.Parse(()=>new di(e.name,i,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable),e,i,s)}}g([v()],di.prototype,"threshold",void 0),g([v()],di.prototype,"strength",void 0),g([v()],di.prototype,"reflectionSpecularFalloffExponent",void 0),g([v()],di.prototype,"step",void 0),g([v()],di.prototype,"roughnessFactor",void 0),g([v()],di.prototype,"enableSmoothReflections",null),g([v()],di.prototype,"reflectionSamples",null),g([v()],di.prototype,"smoothSteps",null),Re("BABYLON.ScreenSpaceReflectionPostProcess",di);const cE="standardPixelShader",uE=`uniform sampler2D textureSampler;
9002
+ `,o,void 0,null,h),this.threshold=1.2,this.strength=1,this.reflectionSpecularFalloffExponent=3,this.step=1,this.roughnessFactor=.2,this._forceGeometryBuffer=!1,this._enableSmoothReflections=!1,this._reflectionSamples=64,this._smoothSteps=5,this._forceGeometryBuffer=c,this._forceGeometryBuffer){const u=t.enableGeometryBufferRenderer();u&&u.isSupported&&(u.enablePosition=!0,u.enableReflectivity=!0)}else{const u=t.enablePrePassRenderer();u==null||u.markAsDirty(),this._prePassEffectConfiguration=new lE}this._updateEffectDefines(),this.onApply=u=>{const f=this._geometryBufferRenderer,d=this._prePassRenderer;if(!d&&!f)return;if(f){const T=f.getTextureIndex(at.POSITION_TEXTURE_TYPE),S=f.getTextureIndex(at.REFLECTIVITY_TEXTURE_TYPE);u.setTexture("normalSampler",f.getGBuffer().textures[1]),u.setTexture("positionSampler",f.getGBuffer().textures[T]),u.setTexture("reflectivitySampler",f.getGBuffer().textures[S])}else if(d){const T=d.getIndex(1),S=d.getIndex(3),x=d.getIndex(6);u.setTexture("normalSampler",d.getRenderTarget().textures[x]),u.setTexture("positionSampler",d.getRenderTarget().textures[T]),u.setTexture("reflectivitySampler",d.getRenderTarget().textures[S])}const _=t.activeCamera;if(!_)return;const p=_.getViewMatrix(!0),m=_.getProjectionMatrix(!0);u.setMatrix("projection",m),u.setMatrix("view",p),u.setFloat("threshold",this.threshold),u.setFloat("reflectionSpecularFalloffExponent",this.reflectionSpecularFalloffExponent),u.setFloat("strength",this.strength),u.setFloat("stepSize",this.step),u.setFloat("roughnessFactor",this.roughnessFactor)},this._isSceneRightHanded=t.useRightHandedSystem}get enableSmoothReflections(){return this._enableSmoothReflections}set enableSmoothReflections(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())}get reflectionSamples(){return this._reflectionSamples}set reflectionSamples(e){e!==this._reflectionSamples&&(this._reflectionSamples=e,this._updateEffectDefines())}get smoothSteps(){return this._smoothSteps}set smoothSteps(e){e!==this._smoothSteps&&(this._smoothSteps=e,this._updateEffectDefines())}_updateEffectDefines(){const e=[];(this._geometryBufferRenderer||this._prePassRenderer)&&e.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&e.push("#define ENABLE_SMOOTH_REFLECTIONS"),this._isSceneRightHanded&&e.push("#define RIGHT_HANDED_SCENE"),e.push("#define REFLECTION_SAMPLES "+(this._reflectionSamples>>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join(`
9003
+ `))}static _Parse(e,t,i,s){return J.Parse(()=>new di(e.name,i,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable),e,i,s)}}g([v()],di.prototype,"threshold",void 0),g([v()],di.prototype,"strength",void 0),g([v()],di.prototype,"reflectionSpecularFalloffExponent",void 0),g([v()],di.prototype,"step",void 0),g([v()],di.prototype,"roughnessFactor",void 0),g([v()],di.prototype,"enableSmoothReflections",null),g([v()],di.prototype,"reflectionSamples",null),g([v()],di.prototype,"smoothSteps",null),Re("BABYLON.ScreenSpaceReflectionPostProcess",di);const uE="standardPixelShader",fE=`uniform sampler2D textureSampler;
9004
9004
  varying vec2 vUV;
9005
9005
  #define CUSTOM_FRAGMENT_DEFINITIONS
9006
9006
  #if defined(PASS_POST_PROCESS)
@@ -9335,14 +9335,14 @@ result+=texture2D(textureSampler,offset1);
9335
9335
  gl_FragColor=result/float(nSamples);
9336
9336
  }
9337
9337
  #endif
9338
- `;U.ShadersStore[cE]=uE;class Oe extends lr{get exposure(){return this._fixedExposure}set exposure(e){this._fixedExposure=e,this._currentExposure=e}get hdrAutoExposure(){return this._hdrAutoExposure}set hdrAutoExposure(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){const t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join(`
9338
+ `;U.ShadersStore[uE]=fE;class Oe extends lr{get exposure(){return this._fixedExposure}set exposure(e){this._fixedExposure=e,this._currentExposure=e}get hdrAutoExposure(){return this._hdrAutoExposure}set hdrAutoExposure(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){const t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join(`
9339
9339
  `))}}get motionStrength(){return this._motionStrength}set motionStrength(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)}get objectBasedMotionBlur(){return this._isObjectBasedMotionBlur}set objectBasedMotionBlur(e){const t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()}get BloomEnabled(){return this._bloomEnabled}set BloomEnabled(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())}get DepthOfFieldEnabled(){return this._depthOfFieldEnabled}set DepthOfFieldEnabled(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())}get LensFlareEnabled(){return this._lensFlareEnabled}set LensFlareEnabled(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())}get HDREnabled(){return this._hdrEnabled}set HDREnabled(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())}get VLSEnabled(){return this._vlsEnabled}set VLSEnabled(e){if(this._vlsEnabled!==e){if(e&&!this._scene.enableGeometryBufferRenderer()){F.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");return}this._vlsEnabled=e,this._buildPipeline()}}get MotionBlurEnabled(){return this._motionBlurEnabled}set MotionBlurEnabled(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())}get fxaaEnabled(){return this._fxaaEnabled}set fxaaEnabled(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())}get screenSpaceReflectionsEnabled(){return this._screenSpaceReflectionsEnabled}set screenSpaceReflectionsEnabled(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())}get volumetricLightStepsCount(){return this._volumetricLightStepsCount}set volumetricLightStepsCount(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect(`#define VLS
9340
9340
  #define NB_STEPS `+e.toFixed(1)),this._volumetricLightStepsCount=e}get motionBlurSamples(){return this._motionBlurSamples}set motionBlurSamples(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect(`#define MOTION_BLUR
9341
9341
  #define MAX_MOTION_SAMPLES `+e.toFixed(1))),this._motionBlurSamples=e}get samples(){return this._samples}set samples(e){this._samples!==e&&(this._samples=e,this._buildPipeline())}constructor(e,t,i,s=null,r){super(t.getEngine(),e),this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.blurHPostProcesses=[],this.blurVPostProcesses=[],this.textureAdderPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.luminancePostProcess=null,this.luminanceDownSamplePostProcesses=[],this.hdrPostProcess=null,this.textureAdderFinalPostProcess=null,this.lensFlareFinalPostProcess=null,this.hdrFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.motionBlurPostProcess=null,this.depthOfFieldPostProcess=null,this.fxaaPostProcess=null,this.screenSpaceReflectionPostProcess=null,this.brightThreshold=1,this.blurWidth=512,this.horizontalBlur=!1,this.lensTexture=null,this.volumetricLightCoefficient=.2,this.volumetricLightPower=4,this.volumetricLightBlurScale=64,this.sourceLight=null,this.hdrMinimumLuminance=1,this.hdrDecreaseRate=.5,this.hdrIncreaseRate=.5,this.lensColorTexture=null,this.lensFlareStrength=20,this.lensFlareGhostDispersal=1.4,this.lensFlareHaloWidth=.7,this.lensFlareDistortionStrength=16,this.lensFlareBlurWidth=512,this.lensStarTexture=null,this.lensFlareDirtTexture=null,this.depthOfFieldDistance=10,this.depthOfFieldBlurWidth=64,this.animations=[],this._currentDepthOfFieldSource=null,this._fixedExposure=1,this._currentExposure=1,this._hdrAutoExposure=!1,this._hdrCurrentLuminance=1,this._motionStrength=1,this._isObjectBasedMotionBlur=!1,this._camerasToBeAttached=[],this._bloomEnabled=!1,this._depthOfFieldEnabled=!1,this._vlsEnabled=!1,this._lensFlareEnabled=!1,this._hdrEnabled=!1,this._motionBlurEnabled=!1,this._fxaaEnabled=!1,this._screenSpaceReflectionsEnabled=!1,this._motionBlurSamples=64,this._volumetricLightStepsCount=50,this._samples=1,this._cameras=r||t.cameras,this._cameras=this._cameras.slice(),this._camerasToBeAttached=this._cameras.slice(),this._scene=t,this._basePostProcess=s,this._ratio=i,this._floatTextureType=t.getEngine().getCaps().textureFloatRender?1:2,t.postProcessRenderPipelineManager.addPipeline(this),this._buildPipeline()}_buildPipeline(){const e=this._ratio,t=this._scene;this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new di("HDRPass",t,e,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add(()=>{this._currentDepthOfFieldSource=this.screenSpaceReflectionPostProcess}),this.addEffect(new Le(t.getEngine(),"HDRScreenSpaceReflections",()=>this.screenSpaceReflectionPostProcess,!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new ue("HDRPass","standard",[],[],e,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.autoClear=!this.screenSpaceReflectionPostProcess,this.originalPostProcess.onApplyObservable.add(()=>{this._currentDepthOfFieldSource=this.originalPostProcess}),this.addEffect(new Le(t.getEngine(),"HDRPassPostProcess",()=>this.originalPostProcess,!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(t,e/4),this._createBrightPassPostProcess(t,e/4),this._createBlurPostProcesses(t,e/4,1),this._createTextureAdderPostProcess(t,e),this.textureAdderFinalPostProcess=new ue("HDRDepthOfFieldSource","standard",[],[],e,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Le(t.getEngine(),"HDRBaseDepthOfFieldSource",()=>this.textureAdderFinalPostProcess,!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(t,e),this.volumetricLightFinalPostProcess=new ue("HDRVLSFinal","standard",[],[],e,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Le(t.getEngine(),"HDRVLSFinal",()=>this.volumetricLightFinalPostProcess,!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(t,e),this.lensFlareFinalPostProcess=new ue("HDRPostLensFlareDepthOfFieldSource","standard",[],[],e,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Le(t.getEngine(),"HDRPostLensFlareDepthOfFieldSource",()=>this.lensFlareFinalPostProcess,!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(t,this._floatTextureType),this._createHdrPostProcess(t,e),this.hdrFinalPostProcess=new ue("HDRPostHDReDepthOfFieldSource","standard",[],[],e,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define PASS_POST_PROCESS",0),this.addEffect(new Le(t.getEngine(),"HDRPostHDReDepthOfFieldSource",()=>this.hdrFinalPostProcess,!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(t,e/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(t,e)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(t,e),this._fxaaEnabled&&(this.fxaaPostProcess=new or("fxaa",1,null,O.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,0),this.addEffect(new Le(t.getEngine(),"HDRFxaa",()=>this.fxaaPostProcess,!0))),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&F.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}_createDownSampleX4PostProcess(e,t){const i=new Array(32);this.downSampleX4PostProcess=new ue("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=s=>{let r=0;const n=this.downSampleX4PostProcess.width,a=this.downSampleX4PostProcess.height;for(let o=-2;o<2;o++)for(let h=-2;h<2;h++)i[r]=(o+.5)*(1/n),i[r+1]=(h+.5)*(1/a),r+=2;s.setArray2("dsOffsets",i)},this.addEffect(new Le(e.getEngine(),"HDRDownSampleX4",()=>this.downSampleX4PostProcess,!0))}_createBrightPassPostProcess(e,t){const i=new Array(8);this.brightPassPostProcess=new ue("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=s=>{const r=1/this.brightPassPostProcess.width,n=1/this.brightPassPostProcess.height;i[0]=-.5*r,i[1]=.5*n,i[2]=.5*r,i[3]=.5*n,i[4]=-.5*r,i[5]=-.5*n,i[6]=.5*r,i[7]=-.5*n,s.setArray2("dsOffsets",i),s.setFloat("brightThreshold",this.brightThreshold)},this.addEffect(new Le(e.getEngine(),"HDRBrightPass",()=>this.brightPassPostProcess,!0))}_createBlurPostProcesses(e,t,i,s="blurWidth"){const r=e.getEngine(),n=new gt("HDRBlurH_"+i,new ae(1,0),this[s],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),a=new gt("HDRBlurV_"+i,new ae(0,1),this[s],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);n.onActivateObservable.add(()=>{const o=n.width/r.getRenderWidth();n.kernel=this[s]*o}),a.onActivateObservable.add(()=>{const o=a.height/r.getRenderHeight();a.kernel=this.horizontalBlur?64*o:this[s]*o}),this.addEffect(new Le(e.getEngine(),"HDRBlurH"+i,()=>n,!0)),this.addEffect(new Le(e.getEngine(),"HDRBlurV"+i,()=>a,!0)),this.blurHPostProcesses.push(n),this.blurVPostProcesses.push(a)}_createTextureAdderPostProcess(e,t){this.textureAdderPostProcess=new ue("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=i=>{i.setTextureFromPostProcess("otherSampler",this._vlsEnabled?this._currentDepthOfFieldSource:this.originalPostProcess),i.setTexture("lensSampler",this.lensTexture),i.setFloat("exposure",this._currentExposure),this._currentDepthOfFieldSource=this.textureAdderFinalPostProcess},this.addEffect(new Le(e.getEngine(),"HDRTextureAdder",()=>this.textureAdderPostProcess,!0))}_createVolumetricLightPostProcess(e,t){const i=e.enableGeometryBufferRenderer();i.enablePosition=!0;const s=i.getGBuffer();this.volumetricLightPostProcess=new ue("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,`#define VLS
9342
9342
  #define NB_STEPS `+this._volumetricLightStepsCount.toFixed(1));const r=ae.Zero();this.volumetricLightPostProcess.onApply=n=>{if(this.sourceLight&&this.sourceLight.getShadowGenerator()&&this._scene.activeCamera){const a=this.sourceLight.getShadowGenerator();n.setTexture("shadowMapSampler",a.getShadowMap()),n.setTexture("positionSampler",s.textures[2]),n.setColor3("sunColor",this.sourceLight.diffuse),n.setVector3("sunDirection",this.sourceLight.getShadowDirection()),n.setVector3("cameraPosition",this._scene.activeCamera.globalPosition),n.setMatrix("shadowViewProjection",a.getTransformMatrix()),n.setFloat("scatteringCoefficient",this.volumetricLightCoefficient),n.setFloat("scatteringPower",this.volumetricLightPower),r.x=this.sourceLight.getDepthMinZ(this._scene.activeCamera),r.y=this.sourceLight.getDepthMaxZ(this._scene.activeCamera),n.setVector2("depthValues",r)}},this.addEffect(new Le(e.getEngine(),"HDRVLS",()=>this.volumetricLightPostProcess,!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new ue("HDRVLSMerge","standard",[],["originalSampler"],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=n=>{n.setTextureFromPostProcess("originalSampler",this._bloomEnabled?this.textureAdderFinalPostProcess:this.originalPostProcess),this._currentDepthOfFieldSource=this.volumetricLightFinalPostProcess},this.addEffect(new Le(e.getEngine(),"HDRVLSMerge",()=>this.volumetricLightMergePostProces,!0))}_createLuminancePostProcesses(e,t){let i=Math.pow(3,Oe.LuminanceSteps);this.luminancePostProcess=new ue("HDRLuminance","standard",["lumOffsets"],[],{width:i,height:i},null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",t);const s=[];this.luminancePostProcess.onApply=n=>{const a=1/this.luminancePostProcess.width,o=1/this.luminancePostProcess.height;s[0]=-.5*a,s[1]=.5*o,s[2]=.5*a,s[3]=.5*o,s[4]=-.5*a,s[5]=-.5*o,s[6]=.5*a,s[7]=-.5*o,n.setArray2("lumOffsets",s)},this.addEffect(new Le(e.getEngine(),"HDRLuminance",()=>this.luminancePostProcess,!0));for(let n=Oe.LuminanceSteps-1;n>=0;n--){i=Math.pow(3,n);let a=`#define LUMINANCE_DOWN_SAMPLE
9343
9343
  `;n===0&&(a+="#define FINAL_DOWN_SAMPLER");const o=new ue("HDRLuminanceDownSample"+n,"standard",["dsOffsets","halfDestPixelSize"],[],{width:i,height:i},null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,t);this.luminanceDownSamplePostProcesses.push(o)}let r=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((n,a)=>{const o=new Array(18);n.onApply=h=>{if(!r)return;let c=0;for(let u=-1;u<2;u++)for(let f=-1;f<2;f++)o[c]=u/r.width,o[c+1]=f/r.height,c+=2;h.setArray2("dsOffsets",o),h.setFloat("halfDestPixelSize",.5/r.width),a===this.luminanceDownSamplePostProcesses.length-1?r=this.luminancePostProcess:r=n},a===this.luminanceDownSamplePostProcesses.length-1&&(n.onAfterRender=()=>{const h=e.getEngine().readPixels(0,0,1,1),c=new He(1/(255*255*255),1/(255*255),1/255,1);h.then(u=>{const f=new Uint8Array(u.buffer);this._hdrCurrentLuminance=(f[0]*c.x+f[1]*c.y+f[2]*c.z+f[3]*c.w)/100})}),this.addEffect(new Le(e.getEngine(),"HDRLuminanceDownSample"+a,()=>n,!0))})}_createHdrPostProcess(e,t){const i=["#define HDR"];this._hdrAutoExposure&&i.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new ue("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,i.join(`
9344
9344
  `),0);let s=1,r=0,n=0;this.hdrPostProcess.onApply=a=>{if(a.setTextureFromPostProcess("textureAdderSampler",this._currentDepthOfFieldSource),r+=e.getEngine().getDeltaTime(),s<0)s=this._hdrCurrentLuminance;else{const o=(n-r)/1e3;this._hdrCurrentLuminance<s+this.hdrDecreaseRate*o?s+=this.hdrDecreaseRate*o:this._hdrCurrentLuminance>s-this.hdrIncreaseRate*o?s-=this.hdrIncreaseRate*o:s=this._hdrCurrentLuminance}this.hdrAutoExposure?this._currentExposure=this._fixedExposure/s:(s=$.Clamp(s,this.hdrMinimumLuminance,1e20),a.setFloat("averageLuminance",s)),n=r,this._currentDepthOfFieldSource=this.hdrFinalPostProcess},this.addEffect(new Le(e.getEngine(),"HDR",()=>this.hdrPostProcess,!0))}_createLensFlarePostProcess(e,t){this.lensFlarePostProcess=new ue("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",0),this.addEffect(new Le(e.getEngine(),"HDRLensFlare",()=>this.lensFlarePostProcess,!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new ue("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",0),this.addEffect(new Le(e.getEngine(),"HDRLensFlareCompose",()=>this.lensFlareComposePostProcess,!0));const i=new ae(0,0);this.lensFlarePostProcess.externalTextureSamplerBinding=!0,this.lensFlarePostProcess.onApply=n=>{n.setTextureFromPostProcess("textureSampler",this._bloomEnabled?this.blurHPostProcesses[0]:this.originalPostProcess),n.setTexture("lensColorSampler",this.lensColorTexture),n.setFloat("strength",this.lensFlareStrength),n.setFloat("ghostDispersal",this.lensFlareGhostDispersal),n.setFloat("haloWidth",this.lensFlareHaloWidth),i.x=this.lensFlarePostProcess.width,i.y=this.lensFlarePostProcess.height,n.setVector2("resolution",i),n.setFloat("distortionStrength",this.lensFlareDistortionStrength)};const s=M.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),r=M.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=n=>{if(!this._scene.activeCamera)return;n.setTextureFromPostProcess("otherSampler",this.lensFlarePostProcess),n.setTexture("lensDirtSampler",this.lensFlareDirtTexture),n.setTexture("lensStarSampler",this.lensStarTexture);const a=this._scene.activeCamera.getViewMatrix().getRow(0),o=this._scene.activeCamera.getViewMatrix().getRow(2);let h=E.Dot(a.toVector3(),new E(1,0,0))+E.Dot(o.toVector3(),new E(0,0,1));h*=4;const c=M.FromValues(Math.cos(h)*.5,-Math.sin(h),0,0,Math.sin(h),Math.cos(h)*.5,0,0,0,0,1,0,0,0,0,1),u=r.multiply(c).multiply(s);n.setMatrix("lensStarMatrix",u),this._currentDepthOfFieldSource=this.lensFlareFinalPostProcess}}_createDepthOfFieldPostProcess(e,t){this.depthOfFieldPostProcess=new ue("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",0),this.depthOfFieldPostProcess.onApply=i=>{i.setTextureFromPostProcess("otherSampler",this._currentDepthOfFieldSource),i.setTexture("depthSampler",this._getDepthTexture()),i.setFloat("distance",this.depthOfFieldDistance)},this.addEffect(new Le(e.getEngine(),"HDRDepthOfField",()=>this.depthOfFieldPostProcess,!0))}_createMotionBlurPostProcess(e,t){if(this._isObjectBasedMotionBlur){const i=new Ps("HDRMotionBlur",e,t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,0);i.motionStrength=this.motionStrength,i.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=i}else{this.motionBlurPostProcess=new ue("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,O.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,`#define MOTION_BLUR
9345
- #define MAX_MOTION_SAMPLES `+this.motionBlurSamples.toFixed(1),0);let i=0,s=M.Identity();const r=M.Identity();let n=M.Identity();const a=ae.Zero();this.motionBlurPostProcess.onApply=o=>{n=e.getProjectionMatrix().multiply(e.getViewMatrix()),n.invertToRef(r),o.setMatrix("inverseViewProjection",r),o.setMatrix("prevViewProjection",s),s=n,a.x=this.motionBlurPostProcess.width,a.y=this.motionBlurPostProcess.height,o.setVector2("screenSize",a),i=e.getEngine().getFps()/60,o.setFloat("motionScale",i),o.setFloat("motionStrength",this.motionStrength),o.setTexture("depthSampler",this._getDepthTexture())}}this.addEffect(new Le(e.getEngine(),"HDRMotionBlur",()=>this.motionBlurPostProcess,!0))}_getDepthTexture(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()}_disposePostProcesses(){for(let e=0;e<this._cameras.length;e++){const t=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(t),this.screenSpaceReflectionPostProcess&&this.screenSpaceReflectionPostProcess.dispose(t),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(t),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(t),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(t),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(t),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(t),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(t),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(t),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(t),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(t),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(t);for(let i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(t);this.luminancePostProcess&&this.luminancePostProcess.dispose(t),this.hdrPostProcess&&this.hdrPostProcess.dispose(t),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(t),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(t),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(t),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(t);for(let i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(t);for(let i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(t)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.screenSpaceReflectionPostProcess=null,this.luminanceDownSamplePostProcesses.length=0,this.blurHPostProcesses.length=0,this.blurVPostProcesses.length=0}dispose(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),super.dispose()}serialize(){const e=J.Serialize(this);return this.sourceLight&&(e.sourceLightId=this.sourceLight.id),this.screenSpaceReflectionPostProcess&&(e.screenSpaceReflectionPostProcess=J.Serialize(this.screenSpaceReflectionPostProcess)),e.customType="StandardRenderingPipeline",e}static Parse(e,t,i){const s=J.Parse(()=>new Oe(e._name,t,e._ratio),e,t,i);return e.sourceLightId&&(s.sourceLight=t.getLightById(e.sourceLightId)),e.screenSpaceReflectionPostProcess&&J.Parse(()=>s.screenSpaceReflectionPostProcess,e.screenSpaceReflectionPostProcess,t,i),s}}Oe.LuminanceSteps=6,g([v()],Oe.prototype,"brightThreshold",void 0),g([v()],Oe.prototype,"blurWidth",void 0),g([v()],Oe.prototype,"horizontalBlur",void 0),g([v()],Oe.prototype,"exposure",null),g([Me("lensTexture")],Oe.prototype,"lensTexture",void 0),g([v()],Oe.prototype,"volumetricLightCoefficient",void 0),g([v()],Oe.prototype,"volumetricLightPower",void 0),g([v()],Oe.prototype,"volumetricLightBlurScale",void 0),g([v()],Oe.prototype,"hdrMinimumLuminance",void 0),g([v()],Oe.prototype,"hdrDecreaseRate",void 0),g([v()],Oe.prototype,"hdrIncreaseRate",void 0),g([v()],Oe.prototype,"hdrAutoExposure",null),g([Me("lensColorTexture")],Oe.prototype,"lensColorTexture",void 0),g([v()],Oe.prototype,"lensFlareStrength",void 0),g([v()],Oe.prototype,"lensFlareGhostDispersal",void 0),g([v()],Oe.prototype,"lensFlareHaloWidth",void 0),g([v()],Oe.prototype,"lensFlareDistortionStrength",void 0),g([v()],Oe.prototype,"lensFlareBlurWidth",void 0),g([Me("lensStarTexture")],Oe.prototype,"lensStarTexture",void 0),g([Me("lensFlareDirtTexture")],Oe.prototype,"lensFlareDirtTexture",void 0),g([v()],Oe.prototype,"depthOfFieldDistance",void 0),g([v()],Oe.prototype,"depthOfFieldBlurWidth",void 0),g([v()],Oe.prototype,"motionStrength",null),g([v()],Oe.prototype,"objectBasedMotionBlur",null),g([v()],Oe.prototype,"_ratio",void 0),g([v()],Oe.prototype,"BloomEnabled",null),g([v()],Oe.prototype,"DepthOfFieldEnabled",null),g([v()],Oe.prototype,"LensFlareEnabled",null),g([v()],Oe.prototype,"HDREnabled",null),g([v()],Oe.prototype,"VLSEnabled",null),g([v()],Oe.prototype,"MotionBlurEnabled",null),g([v()],Oe.prototype,"fxaaEnabled",null),g([v()],Oe.prototype,"screenSpaceReflectionsEnabled",null),g([v()],Oe.prototype,"volumetricLightStepsCount",null),g([v()],Oe.prototype,"motionBlurSamples",null),g([v()],Oe.prototype,"samples",null),Re("BABYLON.StandardRenderingPipeline",Oe);class fE{constructor(){this.enabled=!1,this.name="screenSpaceReflections2",this.texturesRequired=[6,3,5]}}const dE="depthPixelShader",_E=`#ifdef ALPHATEST
9345
+ #define MAX_MOTION_SAMPLES `+this.motionBlurSamples.toFixed(1),0);let i=0,s=M.Identity();const r=M.Identity();let n=M.Identity();const a=ae.Zero();this.motionBlurPostProcess.onApply=o=>{n=e.getProjectionMatrix().multiply(e.getViewMatrix()),n.invertToRef(r),o.setMatrix("inverseViewProjection",r),o.setMatrix("prevViewProjection",s),s=n,a.x=this.motionBlurPostProcess.width,a.y=this.motionBlurPostProcess.height,o.setVector2("screenSize",a),i=e.getEngine().getFps()/60,o.setFloat("motionScale",i),o.setFloat("motionStrength",this.motionStrength),o.setTexture("depthSampler",this._getDepthTexture())}}this.addEffect(new Le(e.getEngine(),"HDRMotionBlur",()=>this.motionBlurPostProcess,!0))}_getDepthTexture(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()}_disposePostProcesses(){for(let e=0;e<this._cameras.length;e++){const t=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(t),this.screenSpaceReflectionPostProcess&&this.screenSpaceReflectionPostProcess.dispose(t),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(t),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(t),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(t),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(t),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(t),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(t),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(t),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(t),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(t),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(t);for(let i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(t);this.luminancePostProcess&&this.luminancePostProcess.dispose(t),this.hdrPostProcess&&this.hdrPostProcess.dispose(t),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(t),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(t),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(t),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(t);for(let i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(t);for(let i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(t)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.screenSpaceReflectionPostProcess=null,this.luminanceDownSamplePostProcesses.length=0,this.blurHPostProcesses.length=0,this.blurVPostProcesses.length=0}dispose(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),super.dispose()}serialize(){const e=J.Serialize(this);return this.sourceLight&&(e.sourceLightId=this.sourceLight.id),this.screenSpaceReflectionPostProcess&&(e.screenSpaceReflectionPostProcess=J.Serialize(this.screenSpaceReflectionPostProcess)),e.customType="StandardRenderingPipeline",e}static Parse(e,t,i){const s=J.Parse(()=>new Oe(e._name,t,e._ratio),e,t,i);return e.sourceLightId&&(s.sourceLight=t.getLightById(e.sourceLightId)),e.screenSpaceReflectionPostProcess&&J.Parse(()=>s.screenSpaceReflectionPostProcess,e.screenSpaceReflectionPostProcess,t,i),s}}Oe.LuminanceSteps=6,g([v()],Oe.prototype,"brightThreshold",void 0),g([v()],Oe.prototype,"blurWidth",void 0),g([v()],Oe.prototype,"horizontalBlur",void 0),g([v()],Oe.prototype,"exposure",null),g([Me("lensTexture")],Oe.prototype,"lensTexture",void 0),g([v()],Oe.prototype,"volumetricLightCoefficient",void 0),g([v()],Oe.prototype,"volumetricLightPower",void 0),g([v()],Oe.prototype,"volumetricLightBlurScale",void 0),g([v()],Oe.prototype,"hdrMinimumLuminance",void 0),g([v()],Oe.prototype,"hdrDecreaseRate",void 0),g([v()],Oe.prototype,"hdrIncreaseRate",void 0),g([v()],Oe.prototype,"hdrAutoExposure",null),g([Me("lensColorTexture")],Oe.prototype,"lensColorTexture",void 0),g([v()],Oe.prototype,"lensFlareStrength",void 0),g([v()],Oe.prototype,"lensFlareGhostDispersal",void 0),g([v()],Oe.prototype,"lensFlareHaloWidth",void 0),g([v()],Oe.prototype,"lensFlareDistortionStrength",void 0),g([v()],Oe.prototype,"lensFlareBlurWidth",void 0),g([Me("lensStarTexture")],Oe.prototype,"lensStarTexture",void 0),g([Me("lensFlareDirtTexture")],Oe.prototype,"lensFlareDirtTexture",void 0),g([v()],Oe.prototype,"depthOfFieldDistance",void 0),g([v()],Oe.prototype,"depthOfFieldBlurWidth",void 0),g([v()],Oe.prototype,"motionStrength",null),g([v()],Oe.prototype,"objectBasedMotionBlur",null),g([v()],Oe.prototype,"_ratio",void 0),g([v()],Oe.prototype,"BloomEnabled",null),g([v()],Oe.prototype,"DepthOfFieldEnabled",null),g([v()],Oe.prototype,"LensFlareEnabled",null),g([v()],Oe.prototype,"HDREnabled",null),g([v()],Oe.prototype,"VLSEnabled",null),g([v()],Oe.prototype,"MotionBlurEnabled",null),g([v()],Oe.prototype,"fxaaEnabled",null),g([v()],Oe.prototype,"screenSpaceReflectionsEnabled",null),g([v()],Oe.prototype,"volumetricLightStepsCount",null),g([v()],Oe.prototype,"motionBlurSamples",null),g([v()],Oe.prototype,"samples",null),Re("BABYLON.StandardRenderingPipeline",Oe);class dE{constructor(){this.enabled=!1,this.name="screenSpaceReflections2",this.texturesRequired=[6,3,5]}}const _E="depthPixelShader",pE=`#ifdef ALPHATEST
9346
9346
  varying vec2 vUV;
9347
9347
  uniform sampler2D diffuseSampler;
9348
9348
  #endif
@@ -9383,7 +9383,7 @@ gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
9383
9383
  #endif
9384
9384
  #endif
9385
9385
  #endif
9386
- }`;U.ShadersStore[dE]=_E;const pE="depthVertexShader",mE=`attribute vec3 position;
9386
+ }`;U.ShadersStore[_E]=pE;const mE="depthVertexShader",gE=`attribute vec3 position;
9387
9387
  #include<bonesDeclaration>
9388
9388
  #include<bakedVertexAnimationDeclaration>
9389
9389
  #include<morphTargetsVertexGlobalDeclaration>
@@ -9440,8 +9440,8 @@ vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
9440
9440
  #endif
9441
9441
  #endif
9442
9442
  }
9443
- `;U.ShadersStore[pE]=mE;class cr{setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}constructor(e,t=1,i=null,s=!1,r=O.TRILINEAR_SAMPLINGMODE,n=!1,a){this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._scene=e,this._storeNonLinearDepth=s,this._storeCameraSpaceZ=n,this.isPacked=t===0,this.isPacked?this.clearColor=new ge(1,1,1,1):this.clearColor=new ge(n?1e8:1,0,0,1),cr._SceneComponentInitialization(this._scene);const o=e.getEngine();this._camera=i,r!==O.NEAREST_SAMPLINGMODE&&(t===1&&!o._caps.textureFloatLinearFiltering&&(r=O.NEAREST_SAMPLINGMODE),t===2&&!o._caps.textureHalfFloatLinearFiltering&&(r=O.NEAREST_SAMPLINGMODE));const h=this.isPacked||!o._features.supportExtendedTextureFormats?5:6;this._depthMap=new Dt(a??"DepthRenderer",{width:o.getRenderWidth(),height:o.getRenderHeight()},this._scene,!1,!0,t,!1,r,void 0,void 0,void 0,h),this._depthMap.wrapU=O.CLAMP_ADDRESSMODE,this._depthMap.wrapV=O.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(u=>{u.clear(this.clearColor,!0,!0,!0)}),this._depthMap.onBeforeBindObservable.add(()=>{var u;(u=o._debugPushGroup)===null||u===void 0||u.call(o,"depth renderer",1)}),this._depthMap.onAfterUnbindObservable.add(()=>{var u;(u=o._debugPopGroup)===null||u===void 0||u.call(o,1)}),this._depthMap.customIsReadyFunction=(u,f,d)=>{if((d||f===0)&&u.subMeshes)for(let _=0;_<u.subMeshes.length;++_){const p=u.subMeshes[_],m=p.getRenderingMesh(),T=m._getInstancesRenderList(p._id,!!p.getReplacementMesh()),S=o.getCaps().instancedArrays&&(T.visibleInstances[p._id]!==null&&T.visibleInstances[p._id]!==void 0||m.hasThinInstances);if(!this.isReady(p,S))return!1}return!0};const c=u=>{var f,d;const _=u.getRenderingMesh(),p=u.getEffectiveMesh(),m=this._scene,T=m.getEngine(),S=u.getMaterial();if(p._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!S||p.infiniteDistance||S.disableDepthWrite||u.verticesCount===0||u._renderId===m.getRenderId())return;const x=p._getWorldMatrixDeterminant()<0;let b=(f=_.overrideMaterialSideOrientation)!==null&&f!==void 0?f:S.sideOrientation;x&&(b=b===0?1:0);const I=b===0;T.setState(S.backFaceCulling,0,!1,I,this.reverseCulling?!S.cullBackFaces:S.cullBackFaces);const R=_._getInstancesRenderList(u._id,!!u.getReplacementMesh());if(R.mustReturn)return;const C=T.getCaps().instancedArrays&&(R.visibleInstances[u._id]!==null&&R.visibleInstances[u._id]!==void 0||_.hasThinInstances),y=this._camera||m.activeCamera;if(this.isReady(u,C)&&y){u._renderId=m.getRenderId();const w=(d=p._internalAbstractMeshDataInfo._materialForRenderPass)===null||d===void 0?void 0:d[T.currentRenderPassId];let G=u._getDrawWrapper();!G&&w&&(G=w._getDrawWrapper());const te=y.mode===ie.ORTHOGRAPHIC_CAMERA;if(!G)return;const Q=G.effect;T.enableEffect(G),C||_._bind(u,Q,S.fillMode),w?w.bindForSubMesh(p.getWorldMatrix(),p,u):(Q.setMatrix("viewProjection",m.getTransformMatrix()),Q.setMatrix("world",p.getWorldMatrix()),this._storeCameraSpaceZ&&Q.setMatrix("view",m.getViewMatrix()));let Te,he;if(te?(Te=!T.useReverseDepthBuffer&&T.isNDCHalfZRange?0:1,he=T.useReverseDepthBuffer&&T.isNDCHalfZRange?0:1):(Te=T.useReverseDepthBuffer&&T.isNDCHalfZRange?y.minZ:T.isNDCHalfZRange?0:y.minZ,he=T.useReverseDepthBuffer&&T.isNDCHalfZRange?0:y.maxZ),Q.setFloat2("depthValues",Te,Te+he),!w){if(S.needAlphaTesting()){const ve=S.getAlphaTestTexture();ve&&(Q.setTexture("diffuseSampler",ve),Q.setMatrix("diffuseMatrix",ve.getTextureMatrix()))}if(_.useBones&&_.computeBonesUsingShaders&&_.skeleton){const ve=_.skeleton;if(ve.isUsingTextureForMatrices){const le=ve.getTransformMatrixTexture(_);if(!le)return;Q.setTexture("boneSampler",le),Q.setFloat("boneTextureWidth",4*(ve.bones.length+1))}else Q.setMatrices("mBones",ve.getTransformMatrices(_))}Xs(Q,S,m),X.BindMorphTargetParameters(_,Q),_.morphTargetManager&&_.morphTargetManager.isUsingTextureForTargets&&_.morphTargetManager._bind(Q)}_._processRendering(p,u,Q,S.fillMode,R,C,(ve,le)=>Q.setMatrix("world",le))}};this._depthMap.customRenderFunction=(u,f,d,_)=>{let p;if(_.length)for(p=0;p<_.length;p++)c(_.data[p]);for(p=0;p<u.length;p++)c(u.data[p]);for(p=0;p<f.length;p++)c(f.data[p]);if(this.forceDepthWriteTransparentMeshes)for(p=0;p<d.length;p++)c(d.data[p]);else for(p=0;p<d.length;p++)d.data[p].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1}}isReady(e,t){var i;const s=this._scene.getEngine(),r=e.getMesh(),n=r.getScene(),a=(i=r._internalAbstractMeshDataInfo._materialForRenderPass)===null||i===void 0?void 0:i[s.currentRenderPassId];if(a)return a.isReadyForSubMesh(r,e,t);const o=e.getMaterial();if(!o||o.disableDepthWrite)return!1;const h=[],c=[A.PositionKind];if(o&&o.needAlphaTesting()&&o.getAlphaTestTexture()&&(h.push("#define ALPHATEST"),r.isVerticesDataPresent(A.UVKind)&&(c.push(A.UVKind),h.push("#define UV1")),r.isVerticesDataPresent(A.UV2Kind)&&(c.push(A.UV2Kind),h.push("#define UV2"))),r.useBones&&r.computeBonesUsingShaders){c.push(A.MatricesIndicesKind),c.push(A.MatricesWeightsKind),r.numBoneInfluencers>4&&(c.push(A.MatricesIndicesExtraKind),c.push(A.MatricesWeightsExtraKind)),h.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),h.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0));const m=e.getRenderingMesh().skeleton;m!=null&&m.isUsingTextureForMatrices&&h.push("#define BONETEXTURE")}else h.push("#define NUM_BONE_INFLUENCERS 0");const u=r.morphTargetManager;let f=0;u&&u.numInfluencers>0&&(f=u.numInfluencers,h.push("#define MORPHTARGETS"),h.push("#define NUM_MORPH_INFLUENCERS "+f),u.isUsingTextureForTargets&&h.push("#define MORPHTARGETS_TEXTURE"),X.PrepareAttributesForMorphTargetsInfluencers(c,r,f)),t&&(h.push("#define INSTANCES"),X.PushAttributesForInstances(c),e.getRenderingMesh().hasThinInstances&&h.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&h.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&h.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&h.push("#define PACKED"),nn(o,n,h);const d=e._getDrawWrapper(void 0,!0),_=d.defines,p=h.join(`
9444
- `);if(_!==p){const m=["world","mBones","boneTextureWidth","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"];zs(m),d.setEffect(s.createEffect("depth",c,m,["diffuseSampler","morphTargets","boneSampler"],p,void 0,void 0,void 0,{maxSimultaneousMorphTargets:f}),p)}return d.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){const e=[];for(const t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(const t of e)delete this._scene._depthRenderer[t]}}}cr._SceneComponentInitialization=l=>{throw fe("DepthRendererSceneComponent")};const gE="screenSpaceRayTrace",EE=`float distanceSquared(vec2 a,vec2 b) { a-=b; return dot(a,a); }
9443
+ `;U.ShadersStore[mE]=gE;class cr{setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}constructor(e,t=1,i=null,s=!1,r=O.TRILINEAR_SAMPLINGMODE,n=!1,a){this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._scene=e,this._storeNonLinearDepth=s,this._storeCameraSpaceZ=n,this.isPacked=t===0,this.isPacked?this.clearColor=new ge(1,1,1,1):this.clearColor=new ge(n?1e8:1,0,0,1),cr._SceneComponentInitialization(this._scene);const o=e.getEngine();this._camera=i,r!==O.NEAREST_SAMPLINGMODE&&(t===1&&!o._caps.textureFloatLinearFiltering&&(r=O.NEAREST_SAMPLINGMODE),t===2&&!o._caps.textureHalfFloatLinearFiltering&&(r=O.NEAREST_SAMPLINGMODE));const h=this.isPacked||!o._features.supportExtendedTextureFormats?5:6;this._depthMap=new Dt(a??"DepthRenderer",{width:o.getRenderWidth(),height:o.getRenderHeight()},this._scene,!1,!0,t,!1,r,void 0,void 0,void 0,h),this._depthMap.wrapU=O.CLAMP_ADDRESSMODE,this._depthMap.wrapV=O.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(u=>{u.clear(this.clearColor,!0,!0,!0)}),this._depthMap.onBeforeBindObservable.add(()=>{var u;(u=o._debugPushGroup)===null||u===void 0||u.call(o,"depth renderer",1)}),this._depthMap.onAfterUnbindObservable.add(()=>{var u;(u=o._debugPopGroup)===null||u===void 0||u.call(o,1)}),this._depthMap.customIsReadyFunction=(u,f,d)=>{if((d||f===0)&&u.subMeshes)for(let _=0;_<u.subMeshes.length;++_){const p=u.subMeshes[_],m=p.getRenderingMesh(),T=m._getInstancesRenderList(p._id,!!p.getReplacementMesh()),S=o.getCaps().instancedArrays&&(T.visibleInstances[p._id]!==null&&T.visibleInstances[p._id]!==void 0||m.hasThinInstances);if(!this.isReady(p,S))return!1}return!0};const c=u=>{var f,d;const _=u.getRenderingMesh(),p=u.getEffectiveMesh(),m=this._scene,T=m.getEngine(),S=u.getMaterial();if(p._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!S||p.infiniteDistance||S.disableDepthWrite||u.verticesCount===0||u._renderId===m.getRenderId())return;const x=p._getWorldMatrixDeterminant()<0;let b=(f=_.overrideMaterialSideOrientation)!==null&&f!==void 0?f:S.sideOrientation;x&&(b=b===0?1:0);const I=b===0;T.setState(S.backFaceCulling,0,!1,I,this.reverseCulling?!S.cullBackFaces:S.cullBackFaces);const R=_._getInstancesRenderList(u._id,!!u.getReplacementMesh());if(R.mustReturn)return;const C=T.getCaps().instancedArrays&&(R.visibleInstances[u._id]!==null&&R.visibleInstances[u._id]!==void 0||_.hasThinInstances),y=this._camera||m.activeCamera;if(this.isReady(u,C)&&y){u._renderId=m.getRenderId();const w=(d=p._internalAbstractMeshDataInfo._materialForRenderPass)===null||d===void 0?void 0:d[T.currentRenderPassId];let G=u._getDrawWrapper();!G&&w&&(G=w._getDrawWrapper());const te=y.mode===ie.ORTHOGRAPHIC_CAMERA;if(!G)return;const Q=G.effect;T.enableEffect(G),C||_._bind(u,Q,S.fillMode),w?w.bindForSubMesh(p.getWorldMatrix(),p,u):(Q.setMatrix("viewProjection",m.getTransformMatrix()),Q.setMatrix("world",p.getWorldMatrix()),this._storeCameraSpaceZ&&Q.setMatrix("view",m.getViewMatrix()));let Te,he;if(te?(Te=!T.useReverseDepthBuffer&&T.isNDCHalfZRange?0:1,he=T.useReverseDepthBuffer&&T.isNDCHalfZRange?0:1):(Te=T.useReverseDepthBuffer&&T.isNDCHalfZRange?y.minZ:T.isNDCHalfZRange?0:y.minZ,he=T.useReverseDepthBuffer&&T.isNDCHalfZRange?0:y.maxZ),Q.setFloat2("depthValues",Te,Te+he),!w){if(S.needAlphaTesting()){const ve=S.getAlphaTestTexture();ve&&(Q.setTexture("diffuseSampler",ve),Q.setMatrix("diffuseMatrix",ve.getTextureMatrix()))}if(_.useBones&&_.computeBonesUsingShaders&&_.skeleton){const ve=_.skeleton;if(ve.isUsingTextureForMatrices){const le=ve.getTransformMatrixTexture(_);if(!le)return;Q.setTexture("boneSampler",le),Q.setFloat("boneTextureWidth",4*(ve.bones.length+1))}else Q.setMatrices("mBones",ve.getTransformMatrices(_))}Xs(Q,S,m),X.BindMorphTargetParameters(_,Q),_.morphTargetManager&&_.morphTargetManager.isUsingTextureForTargets&&_.morphTargetManager._bind(Q)}_._processRendering(p,u,Q,S.fillMode,R,C,(ve,le)=>Q.setMatrix("world",le))}};this._depthMap.customRenderFunction=(u,f,d,_)=>{let p;if(_.length)for(p=0;p<_.length;p++)c(_.data[p]);for(p=0;p<u.length;p++)c(u.data[p]);for(p=0;p<f.length;p++)c(f.data[p]);if(this.forceDepthWriteTransparentMeshes)for(p=0;p<d.length;p++)c(d.data[p]);else for(p=0;p<d.length;p++)d.data[p].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1}}isReady(e,t){var i;const s=this._scene.getEngine(),r=e.getMesh(),n=r.getScene(),a=(i=r._internalAbstractMeshDataInfo._materialForRenderPass)===null||i===void 0?void 0:i[s.currentRenderPassId];if(a)return a.isReadyForSubMesh(r,e,t);const o=e.getMaterial();if(!o||o.disableDepthWrite)return!1;const h=[],c=[A.PositionKind];if(o&&o.needAlphaTesting()&&o.getAlphaTestTexture()&&(h.push("#define ALPHATEST"),r.isVerticesDataPresent(A.UVKind)&&(c.push(A.UVKind),h.push("#define UV1")),r.isVerticesDataPresent(A.UV2Kind)&&(c.push(A.UV2Kind),h.push("#define UV2"))),r.useBones&&r.computeBonesUsingShaders){c.push(A.MatricesIndicesKind),c.push(A.MatricesWeightsKind),r.numBoneInfluencers>4&&(c.push(A.MatricesIndicesExtraKind),c.push(A.MatricesWeightsExtraKind)),h.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),h.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0));const m=e.getRenderingMesh().skeleton;m!=null&&m.isUsingTextureForMatrices&&h.push("#define BONETEXTURE")}else h.push("#define NUM_BONE_INFLUENCERS 0");const u=r.morphTargetManager;let f=0;u&&u.numInfluencers>0&&(f=u.numInfluencers,h.push("#define MORPHTARGETS"),h.push("#define NUM_MORPH_INFLUENCERS "+f),u.isUsingTextureForTargets&&h.push("#define MORPHTARGETS_TEXTURE"),X.PrepareAttributesForMorphTargetsInfluencers(c,r,f)),t&&(h.push("#define INSTANCES"),X.PushAttributesForInstances(c),e.getRenderingMesh().hasThinInstances&&h.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&h.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&h.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&h.push("#define PACKED"),nn(o,n,h);const d=e._getDrawWrapper(void 0,!0),_=d.defines,p=h.join(`
9444
+ `);if(_!==p){const m=["world","mBones","boneTextureWidth","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"];zs(m),d.setEffect(s.createEffect("depth",c,m,["diffuseSampler","morphTargets","boneSampler"],p,void 0,void 0,void 0,{maxSimultaneousMorphTargets:f}),p)}return d.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){const e=[];for(const t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(const t of e)delete this._scene._depthRenderer[t]}}}cr._SceneComponentInitialization=l=>{throw fe("DepthRendererSceneComponent")};const EE="screenSpaceRayTrace",TE=`float distanceSquared(vec2 a,vec2 b) { a-=b; return dot(a,a); }
9445
9445
  /**
9446
9446
  param csOrigin Camera-space ray origin,which must be
9447
9447
  within the view volume and must have z>0.01 and project within the valid screen rectangle
@@ -9646,7 +9646,7 @@ vec4 eyePos=invProjectionMatrix*ndc;
9646
9646
  eyePos.xyz/=eyePos.w;
9647
9647
  return eyePos.xyz;
9648
9648
  }
9649
- `;U.IncludesShadersStore[gE]=EE;const TE="screenSpaceReflection2PixelShader",AE=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
9649
+ `;U.IncludesShadersStore[EE]=TE;const AE="screenSpaceReflection2PixelShader",vE=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
9650
9650
  #define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
9651
9651
  #define TEXTURECUBEFUNC(s,c,lod) textureLod(s,c,lod)
9652
9652
  #else
@@ -9855,7 +9855,7 @@ gl_FragColor=vec4(finalColor,colorFull.a);
9855
9855
  gl_FragColor=TEXTUREFUNC(textureSampler,vUV,0.0);
9856
9856
  #endif
9857
9857
  }
9858
- `;U.ShadersStore[TE]=AE;const vE="screenSpaceReflection2BlurPixelShader",SE=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
9858
+ `;U.ShadersStore[AE]=vE;const SE="screenSpaceReflection2BlurPixelShader",RE=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
9859
9859
  #define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
9860
9860
  #else
9861
9861
  #define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
@@ -9904,7 +9904,7 @@ processSample(vUV,-1.0*1.8,stepSize,accumulator,denominator);
9904
9904
  processSample(vUV,-1.0*2.0,stepSize,accumulator,denominator);
9905
9905
  gl_FragColor=vec4(accumulator.rgb/denominator,colorFull.a);
9906
9906
  }
9907
- `;U.ShadersStore[vE]=SE;const RE="screenSpaceReflection2BlurCombinerPixelShader",xE=`uniform sampler2D textureSampler;
9907
+ `;U.ShadersStore[SE]=RE;const xE="screenSpaceReflection2BlurCombinerPixelShader",CE=`uniform sampler2D textureSampler;
9908
9908
  uniform sampler2D mainSampler;
9909
9909
  uniform sampler2D reflectivitySampler;
9910
9910
  uniform float strength;
@@ -9957,13 +9957,13 @@ finalColor=toGammaSpace(finalColor);
9957
9957
  gl_FragColor=vec4(finalColor,color.a);
9958
9958
  #endif
9959
9959
  }
9960
- `;U.ShadersStore[RE]=xE;const CE=M.Compose(new E(.5,.5,.5),K.Identity(),new E(.5,.5,.5)),bE=M.Compose(new E(.5,.5,1),K.Identity(),new E(.5,.5,0));class ze extends lr{set samples(e){this._samples!==e&&(this._samples=e,this._buildPipeline())}get samples(){return this._samples}get reflectivityThreshold(){return this._reflectivityThreshold}set reflectivityThreshold(e){e!==this._reflectivityThreshold&&(e===0&&this._reflectivityThreshold!==0||e!==0&&this._reflectivityThreshold===0?(this._reflectivityThreshold=e,this._buildPipeline()):this._reflectivityThreshold=e)}get ssrDownsample(){return this._ssrDownsample}set ssrDownsample(e){e!==this._ssrDownsample&&(this._ssrDownsample=e,this._buildPipeline())}get blurDispersionStrength(){return this._blurDispersionStrength}set blurDispersionStrength(e){if(e===this._blurDispersionStrength)return;const t=e===0&&this._blurDispersionStrength!==0||e!==0&&this._blurDispersionStrength===0;this._blurDispersionStrength=e,t&&this._buildPipeline()}_useBlur(){return this._blurDispersionStrength>0}get blurDownsample(){return this._blurDownsample}set blurDownsample(e){e!==this._blurDownsample&&(this._blurDownsample=e,this._buildPipeline())}get enableSmoothReflections(){return this._enableSmoothReflections}set enableSmoothReflections(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture=e,this._updateEffectDefines()}get environmentTextureIsProbe(){return this._environmentTextureIsProbe}set environmentTextureIsProbe(e){this._environmentTextureIsProbe=e,this._updateEffectDefines()}get attenuateScreenBorders(){return this._attenuateScreenBorders}set attenuateScreenBorders(e){this._attenuateScreenBorders!==e&&(this._attenuateScreenBorders=e,this._updateEffectDefines())}get attenuateIntersectionDistance(){return this._attenuateIntersectionDistance}set attenuateIntersectionDistance(e){this._attenuateIntersectionDistance!==e&&(this._attenuateIntersectionDistance=e,this._updateEffectDefines())}get attenuateIntersectionIterations(){return this._attenuateIntersectionIterations}set attenuateIntersectionIterations(e){this._attenuateIntersectionIterations!==e&&(this._attenuateIntersectionIterations=e,this._updateEffectDefines())}get attenuateFacingCamera(){return this._attenuateFacingCamera}set attenuateFacingCamera(e){this._attenuateFacingCamera!==e&&(this._attenuateFacingCamera=e,this._updateEffectDefines())}get attenuateBackfaceReflection(){return this._attenuateBackfaceReflection}set attenuateBackfaceReflection(e){this._attenuateBackfaceReflection!==e&&(this._attenuateBackfaceReflection=e,this._updateEffectDefines())}get clipToFrustum(){return this._clipToFrustum}set clipToFrustum(e){this._clipToFrustum!==e&&(this._clipToFrustum=e,this._updateEffectDefines())}get useFresnel(){return this._useFresnel}set useFresnel(e){this._useFresnel!==e&&(this._useFresnel=e,this._buildPipeline())}get enableAutomaticThicknessComputation(){return this._enableAutomaticThicknessComputation}set enableAutomaticThicknessComputation(e){this._enableAutomaticThicknessComputation!==e&&(this._enableAutomaticThicknessComputation=e,this._buildPipeline())}get backfaceDepthRenderer(){return this._depthRenderer}get backfaceDepthTextureDownsample(){return this._backfaceDepthTextureDownsample}set backfaceDepthTextureDownsample(e){this._backfaceDepthTextureDownsample!==e&&(this._backfaceDepthTextureDownsample=e,this._resizeDepthRenderer())}get backfaceForceDepthWriteTransparentMeshes(){return this._backfaceForceDepthWriteTransparentMeshes}set backfaceForceDepthWriteTransparentMeshes(e){this._backfaceForceDepthWriteTransparentMeshes!==e&&(this._backfaceForceDepthWriteTransparentMeshes=e,this._depthRenderer&&(this._depthRenderer.forceDepthWriteTransparentMeshes=e))}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,e?e&&(this._isDirty?this._buildPipeline():this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)):this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()))}get inputTextureColorIsInGammaSpace(){return this._inputTextureColorIsInGammaSpace}set inputTextureColorIsInGammaSpace(e){this._inputTextureColorIsInGammaSpace!==e&&(this._inputTextureColorIsInGammaSpace=e,this._buildPipeline())}get generateOutputInGammaSpace(){return this._generateOutputInGammaSpace}set generateOutputInGammaSpace(e){this._generateOutputInGammaSpace!==e&&(this._generateOutputInGammaSpace=e,this._buildPipeline())}get debug(){return this._debug}set debug(e){this._debug!==e&&(this._debug=e,this._buildPipeline())}getScene(){return this._scene}get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}get scene(){return this._scene}get isSupported(){const e=this._scene.getEngine().getCaps();return e.drawBuffersExtension&&e.texelFetch}constructor(e,t,i,s=!1,r=0){if(super(t.getEngine(),e),this.SSRRenderEffect="SSRRenderEffect",this.SSRBlurRenderEffect="SSRBlurRenderEffect",this.SSRCombineRenderEffect="SSRCombineRenderEffect",this._samples=1,this.maxDistance=1e3,this.step=1,this.thickness=.5,this.strength=1,this.reflectionSpecularFalloffExponent=1,this.maxSteps=1e3,this.roughnessFactor=.2,this.selfCollisionNumSkip=1,this._reflectivityThreshold=.04,this._ssrDownsample=0,this._blurDispersionStrength=.03,this._blurDownsample=0,this._enableSmoothReflections=!1,this._environmentTextureIsProbe=!1,this._attenuateScreenBorders=!0,this._attenuateIntersectionDistance=!0,this._attenuateIntersectionIterations=!0,this._attenuateFacingCamera=!1,this._attenuateBackfaceReflection=!1,this._clipToFrustum=!0,this._useFresnel=!1,this._enableAutomaticThicknessComputation=!1,this._backfaceDepthTextureDownsample=0,this._backfaceForceDepthWriteTransparentMeshes=!0,this._isEnabled=!0,this._inputTextureColorIsInGammaSpace=!0,this._generateOutputInGammaSpace=!0,this._debug=!1,this._forceGeometryBuffer=!1,this._isDirty=!1,this._camerasToBeAttached=[],this._cameras=i||t.cameras,this._cameras=this._cameras.slice(),this._camerasToBeAttached=this._cameras.slice(),this._scene=t,this._textureType=r,this._forceGeometryBuffer=s,this.isSupported){if(t.postProcessRenderPipelineManager.addPipeline(this),this._forceGeometryBuffer){const n=t.enableGeometryBufferRenderer();n&&(n.enableReflectivity=!0,n.useSpecificClearForDepthTexture=!0)}else{const n=t.enablePrePassRenderer();n&&(n.useSpecificClearForDepthTexture=!0,n.markAsDirty())}this._buildPipeline()}}getClassName(){return"SSRRenderingPipeline"}addCamera(e){this._camerasToBeAttached.push(e),this._buildPipeline()}removeCamera(e){const t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()}dispose(e=!1){this._disposeDepthRenderer(),this._disposePostProcesses(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),super.dispose()}_getTextureSize(){var e,t;const i=this._scene.getEngine(),s=this._prePassRenderer;let r={width:i.getRenderWidth(),height:i.getRenderHeight()};if(s&&((e=this._scene.activeCamera)===null||e===void 0?void 0:e._getFirstPostProcess())===this._ssrPostProcess){const n=s.getRenderTarget();n&&n.textures&&(r=n.textures[s.getIndex(4)].getSize())}else!((t=this._ssrPostProcess)===null||t===void 0)&&t.inputTexture&&(r.width=this._ssrPostProcess.inputTexture.width,r.height=this._ssrPostProcess.inputTexture.height);return r}_updateEffectDefines(){var e;const t=[];(this._geometryBufferRenderer||this._prePassRenderer)&&t.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&t.push("#define SSRAYTRACE_ENABLE_REFINEMENT"),this._scene.useRightHandedSystem&&t.push("#define SSRAYTRACE_RIGHT_HANDED_SCENE"),this._environmentTexture&&(t.push("#define SSR_USE_ENVIRONMENT_CUBE"),this._environmentTexture.boundingBoxSize&&t.push("#define SSR_USE_LOCAL_REFLECTIONMAP_CUBIC"),this._environmentTexture.gammaSpace&&t.push("#define SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE")),this._environmentTextureIsProbe&&t.push("#define SSR_INVERTCUBICMAP"),this._enableAutomaticThicknessComputation&&t.push("#define SSRAYTRACE_USE_BACK_DEPTHBUFFER"),this._attenuateScreenBorders&&t.push("#define SSR_ATTENUATE_SCREEN_BORDERS"),this._attenuateIntersectionDistance&&t.push("#define SSR_ATTENUATE_INTERSECTION_DISTANCE"),this._attenuateIntersectionIterations&&t.push("#define SSR_ATTENUATE_INTERSECTION_NUMITERATIONS"),this._attenuateFacingCamera&&t.push("#define SSR_ATTENUATE_FACING_CAMERA"),this._attenuateBackfaceReflection&&t.push("#define SSR_ATTENUATE_BACKFACE_REFLECTION"),this._clipToFrustum&&t.push("#define SSRAYTRACE_CLIP_TO_FRUSTUM"),this._useBlur()&&t.push("#define SSR_USE_BLUR"),this._debug&&t.push("#define SSRAYTRACE_DEBUG"),this._inputTextureColorIsInGammaSpace&&t.push("#define SSR_INPUT_IS_GAMMA_SPACE"),this._generateOutputInGammaSpace&&t.push("#define SSR_OUTPUT_IS_GAMMA_SPACE"),this._useFresnel&&t.push("#define SSR_BLEND_WITH_FRESNEL"),this._reflectivityThreshold===0&&t.push("#define SSR_DISABLE_REFLECTIVITY_TEST"),(e=this._ssrPostProcess)===null||e===void 0||e.updateEffect(t.join(`
9961
- `))}_buildPipeline(){var e;if(!this.isSupported)return;if(!this._isEnabled){this._isDirty=!0;return}this._isDirty=!1;const t=this._scene.getEngine();if(this._disposeDepthRenderer(),this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._enableAutomaticThicknessComputation){const i=(e=this._cameras)===null||e===void 0?void 0:e[0];i&&(this._depthRendererCamera=i,this._depthRenderer=new cr(this._scene,void 0,void 0,void 0,1,!0,"SSRBackDepth"),this._depthRenderer.clearColor.r=1e8,this._depthRenderer.reverseCulling=!0,this._depthRenderer.forceDepthWriteTransparentMeshes=this._backfaceForceDepthWriteTransparentMeshes,this._resizeDepthRenderer(),i.customRenderTargets.push(this._depthRenderer.getDepthMap()))}this._createSSRPostProcess(),this.addEffect(new Le(t,this.SSRRenderEffect,()=>this._ssrPostProcess,!0)),this._useBlur()&&(this._createBlurAndCombinerPostProcesses(),this.addEffect(new Le(t,this.SSRBlurRenderEffect,()=>[this._blurPostProcessX,this._blurPostProcessY],!0)),this.addEffect(new Le(t,this.SSRCombineRenderEffect,()=>this._blurCombinerPostProcess,!0))),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)}_resizeDepthRenderer(){if(!this._depthRenderer)return;const e=this._getTextureSize(),t=this._depthRenderer.getDepthMap().getSize(),i=Math.floor(e.width/(this._backfaceDepthTextureDownsample+1)),s=Math.floor(e.height/(this._backfaceDepthTextureDownsample+1));(t.width!==i||t.height!==s)&&this._depthRenderer.getDepthMap().resize({width:i,height:s})}_disposeDepthRenderer(){var e;if(this._depthRenderer){if(this._depthRendererCamera){const t=(e=this._depthRendererCamera.customRenderTargets.indexOf(this._depthRenderer.getDepthMap()))!==null&&e!==void 0?e:-1;t!==-1&&this._depthRendererCamera.customRenderTargets.splice(t,1)}this._depthRendererCamera=null,this._depthRenderer.getDepthMap().dispose()}this._depthRenderer=null}_disposePostProcesses(){var e,t,i,s;for(let r=0;r<this._cameras.length;r++){const n=this._cameras[r];(e=this._ssrPostProcess)===null||e===void 0||e.dispose(n),(t=this._blurPostProcessX)===null||t===void 0||t.dispose(n),(i=this._blurPostProcessY)===null||i===void 0||i.dispose(n),(s=this._blurCombinerPostProcess)===null||s===void 0||s.dispose(n)}this._ssrPostProcess=null,this._blurPostProcessX=null,this._blurPostProcessY=null,this._blurCombinerPostProcess=null}_createSSRPostProcess(){this._ssrPostProcess=new ue("ssr","screenSpaceReflection2",["projection","invProjectionMatrix","view","invView","thickness","reflectionSpecularFalloffExponent","strength","stepSize","maxSteps","roughnessFactor","projectionPixel","nearPlaneZ","maxDistance","selfCollisionNumSkip","vReflectionPosition","vReflectionSize","backSizeFactor","reflectivityThreshold"],["textureSampler","normalSampler","reflectivitySampler","depthSampler","envCubeSampler","backDepthSampler"],1,null,this._textureType,this._scene.getEngine(),!1,"",this._textureType),this._updateEffectDefines(),this._ssrPostProcess.onApply=e=>{this._resizeDepthRenderer();const t=this._geometryBufferRenderer,i=this._prePassRenderer;if(!i&&!t)return;if(t){const o=t.getTextureIndex(at.REFLECTIVITY_TEXTURE_TYPE);e.setTexture("normalSampler",t.getGBuffer().textures[1]),e.setTexture("reflectivitySampler",t.getGBuffer().textures[o]),e.setTexture("depthSampler",t.getGBuffer().textures[0])}else if(i){const o=i.getIndex(5),h=i.getIndex(3),c=i.getIndex(6);e.setTexture("normalSampler",i.getRenderTarget().textures[c]),e.setTexture("depthSampler",i.getRenderTarget().textures[o]),e.setTexture("reflectivitySampler",i.getRenderTarget().textures[h])}this._enableAutomaticThicknessComputation&&this._depthRenderer&&(e.setTexture("backDepthSampler",this._depthRenderer.getDepthMap()),e.setFloat("backSizeFactor",this._backfaceDepthTextureDownsample+1));const s=this._scene.activeCamera;if(!s)return;const r=s.getViewMatrix(!0),n=s.getProjectionMatrix(!0);n.invertToRef(D.Matrix[0]),r.invertToRef(D.Matrix[1]),e.setMatrix("projection",n),e.setMatrix("view",r),e.setMatrix("invView",D.Matrix[1]),e.setMatrix("invProjectionMatrix",D.Matrix[0]),e.setFloat("thickness",this.thickness),e.setFloat("reflectionSpecularFalloffExponent",this.reflectionSpecularFalloffExponent),e.setFloat("strength",this.strength),e.setFloat("stepSize",this.step),e.setFloat("maxSteps",this.maxSteps),e.setFloat("roughnessFactor",this.roughnessFactor),e.setFloat("nearPlaneZ",s.minZ),e.setFloat("maxDistance",this.maxDistance),e.setFloat("selfCollisionNumSkip",this.selfCollisionNumSkip),e.setFloat("reflectivityThreshold",this._reflectivityThreshold);const a=this._getTextureSize();M.ScalingToRef(a.width,a.height,1,D.Matrix[2]),n.multiplyToRef(this._scene.getEngine().isWebGPU?bE:CE,D.Matrix[3]),D.Matrix[3].multiplyToRef(D.Matrix[2],D.Matrix[4]),e.setMatrix("projectionPixel",D.Matrix[4]),this._environmentTexture&&(e.setTexture("envCubeSampler",this._environmentTexture),this._environmentTexture.boundingBoxSize&&(e.setVector3("vReflectionPosition",this._environmentTexture.boundingBoxPosition),e.setVector3("vReflectionSize",this._environmentTexture.boundingBoxSize)))},this._ssrPostProcess.samples=this.samples,this._forceGeometryBuffer||(this._ssrPostProcess._prePassEffectConfiguration=new fE)}_createBlurAndCombinerPostProcesses(){const e=this._scene.getEngine();this._blurPostProcessX=new ue("SSRblurX","screenSpaceReflection2Blur",["texelOffsetScale"],["textureSampler"],this._useBlur()?1/(this._ssrDownsample+1):1,null,2,e,!1,"",this._textureType),this._blurPostProcessX.autoClear=!1,this._blurPostProcessX.onApplyObservable.add(r=>{var n,a;const o=(a=(n=this._blurPostProcessX)===null||n===void 0?void 0:n.inputTexture.width)!==null&&a!==void 0?a:this._scene.getEngine().getRenderWidth();r.setFloat2("texelOffsetScale",this._blurDispersionStrength/o,0)}),this._blurPostProcessY=new ue("SSRblurY","screenSpaceReflection2Blur",["texelOffsetScale"],["textureSampler"],this._useBlur()?1/(this._blurDownsample+1):1,null,2,e,!1,"",this._textureType),this._blurPostProcessY.autoClear=!1,this._blurPostProcessY.onApplyObservable.add(r=>{var n,a;const o=(a=(n=this._blurPostProcessY)===null||n===void 0?void 0:n.inputTexture.height)!==null&&a!==void 0?a:this._scene.getEngine().getRenderHeight();r.setFloat2("texelOffsetScale",0,this._blurDispersionStrength/o)});const t=["strength","reflectionSpecularFalloffExponent","reflectivityThreshold"],i=["textureSampler","mainSampler","reflectivitySampler"];let s="";this._debug&&(s+=`#define SSRAYTRACE_DEBUG
9960
+ `;U.ShadersStore[xE]=CE;const bE=M.Compose(new E(.5,.5,.5),K.Identity(),new E(.5,.5,.5)),IE=M.Compose(new E(.5,.5,1),K.Identity(),new E(.5,.5,0));class ze extends lr{set samples(e){this._samples!==e&&(this._samples=e,this._buildPipeline())}get samples(){return this._samples}get reflectivityThreshold(){return this._reflectivityThreshold}set reflectivityThreshold(e){e!==this._reflectivityThreshold&&(e===0&&this._reflectivityThreshold!==0||e!==0&&this._reflectivityThreshold===0?(this._reflectivityThreshold=e,this._buildPipeline()):this._reflectivityThreshold=e)}get ssrDownsample(){return this._ssrDownsample}set ssrDownsample(e){e!==this._ssrDownsample&&(this._ssrDownsample=e,this._buildPipeline())}get blurDispersionStrength(){return this._blurDispersionStrength}set blurDispersionStrength(e){if(e===this._blurDispersionStrength)return;const t=e===0&&this._blurDispersionStrength!==0||e!==0&&this._blurDispersionStrength===0;this._blurDispersionStrength=e,t&&this._buildPipeline()}_useBlur(){return this._blurDispersionStrength>0}get blurDownsample(){return this._blurDownsample}set blurDownsample(e){e!==this._blurDownsample&&(this._blurDownsample=e,this._buildPipeline())}get enableSmoothReflections(){return this._enableSmoothReflections}set enableSmoothReflections(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture=e,this._updateEffectDefines()}get environmentTextureIsProbe(){return this._environmentTextureIsProbe}set environmentTextureIsProbe(e){this._environmentTextureIsProbe=e,this._updateEffectDefines()}get attenuateScreenBorders(){return this._attenuateScreenBorders}set attenuateScreenBorders(e){this._attenuateScreenBorders!==e&&(this._attenuateScreenBorders=e,this._updateEffectDefines())}get attenuateIntersectionDistance(){return this._attenuateIntersectionDistance}set attenuateIntersectionDistance(e){this._attenuateIntersectionDistance!==e&&(this._attenuateIntersectionDistance=e,this._updateEffectDefines())}get attenuateIntersectionIterations(){return this._attenuateIntersectionIterations}set attenuateIntersectionIterations(e){this._attenuateIntersectionIterations!==e&&(this._attenuateIntersectionIterations=e,this._updateEffectDefines())}get attenuateFacingCamera(){return this._attenuateFacingCamera}set attenuateFacingCamera(e){this._attenuateFacingCamera!==e&&(this._attenuateFacingCamera=e,this._updateEffectDefines())}get attenuateBackfaceReflection(){return this._attenuateBackfaceReflection}set attenuateBackfaceReflection(e){this._attenuateBackfaceReflection!==e&&(this._attenuateBackfaceReflection=e,this._updateEffectDefines())}get clipToFrustum(){return this._clipToFrustum}set clipToFrustum(e){this._clipToFrustum!==e&&(this._clipToFrustum=e,this._updateEffectDefines())}get useFresnel(){return this._useFresnel}set useFresnel(e){this._useFresnel!==e&&(this._useFresnel=e,this._buildPipeline())}get enableAutomaticThicknessComputation(){return this._enableAutomaticThicknessComputation}set enableAutomaticThicknessComputation(e){this._enableAutomaticThicknessComputation!==e&&(this._enableAutomaticThicknessComputation=e,this._buildPipeline())}get backfaceDepthRenderer(){return this._depthRenderer}get backfaceDepthTextureDownsample(){return this._backfaceDepthTextureDownsample}set backfaceDepthTextureDownsample(e){this._backfaceDepthTextureDownsample!==e&&(this._backfaceDepthTextureDownsample=e,this._resizeDepthRenderer())}get backfaceForceDepthWriteTransparentMeshes(){return this._backfaceForceDepthWriteTransparentMeshes}set backfaceForceDepthWriteTransparentMeshes(e){this._backfaceForceDepthWriteTransparentMeshes!==e&&(this._backfaceForceDepthWriteTransparentMeshes=e,this._depthRenderer&&(this._depthRenderer.forceDepthWriteTransparentMeshes=e))}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,e?e&&(this._isDirty?this._buildPipeline():this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)):this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()))}get inputTextureColorIsInGammaSpace(){return this._inputTextureColorIsInGammaSpace}set inputTextureColorIsInGammaSpace(e){this._inputTextureColorIsInGammaSpace!==e&&(this._inputTextureColorIsInGammaSpace=e,this._buildPipeline())}get generateOutputInGammaSpace(){return this._generateOutputInGammaSpace}set generateOutputInGammaSpace(e){this._generateOutputInGammaSpace!==e&&(this._generateOutputInGammaSpace=e,this._buildPipeline())}get debug(){return this._debug}set debug(e){this._debug!==e&&(this._debug=e,this._buildPipeline())}getScene(){return this._scene}get _geometryBufferRenderer(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null}get _prePassRenderer(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer}get scene(){return this._scene}get isSupported(){const e=this._scene.getEngine().getCaps();return e.drawBuffersExtension&&e.texelFetch}constructor(e,t,i,s=!1,r=0){if(super(t.getEngine(),e),this.SSRRenderEffect="SSRRenderEffect",this.SSRBlurRenderEffect="SSRBlurRenderEffect",this.SSRCombineRenderEffect="SSRCombineRenderEffect",this._samples=1,this.maxDistance=1e3,this.step=1,this.thickness=.5,this.strength=1,this.reflectionSpecularFalloffExponent=1,this.maxSteps=1e3,this.roughnessFactor=.2,this.selfCollisionNumSkip=1,this._reflectivityThreshold=.04,this._ssrDownsample=0,this._blurDispersionStrength=.03,this._blurDownsample=0,this._enableSmoothReflections=!1,this._environmentTextureIsProbe=!1,this._attenuateScreenBorders=!0,this._attenuateIntersectionDistance=!0,this._attenuateIntersectionIterations=!0,this._attenuateFacingCamera=!1,this._attenuateBackfaceReflection=!1,this._clipToFrustum=!0,this._useFresnel=!1,this._enableAutomaticThicknessComputation=!1,this._backfaceDepthTextureDownsample=0,this._backfaceForceDepthWriteTransparentMeshes=!0,this._isEnabled=!0,this._inputTextureColorIsInGammaSpace=!0,this._generateOutputInGammaSpace=!0,this._debug=!1,this._forceGeometryBuffer=!1,this._isDirty=!1,this._camerasToBeAttached=[],this._cameras=i||t.cameras,this._cameras=this._cameras.slice(),this._camerasToBeAttached=this._cameras.slice(),this._scene=t,this._textureType=r,this._forceGeometryBuffer=s,this.isSupported){if(t.postProcessRenderPipelineManager.addPipeline(this),this._forceGeometryBuffer){const n=t.enableGeometryBufferRenderer();n&&(n.enableReflectivity=!0,n.useSpecificClearForDepthTexture=!0)}else{const n=t.enablePrePassRenderer();n&&(n.useSpecificClearForDepthTexture=!0,n.markAsDirty())}this._buildPipeline()}}getClassName(){return"SSRRenderingPipeline"}addCamera(e){this._camerasToBeAttached.push(e),this._buildPipeline()}removeCamera(e){const t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()}dispose(e=!1){this._disposeDepthRenderer(),this._disposePostProcesses(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),super.dispose()}_getTextureSize(){var e,t;const i=this._scene.getEngine(),s=this._prePassRenderer;let r={width:i.getRenderWidth(),height:i.getRenderHeight()};if(s&&((e=this._scene.activeCamera)===null||e===void 0?void 0:e._getFirstPostProcess())===this._ssrPostProcess){const n=s.getRenderTarget();n&&n.textures&&(r=n.textures[s.getIndex(4)].getSize())}else!((t=this._ssrPostProcess)===null||t===void 0)&&t.inputTexture&&(r.width=this._ssrPostProcess.inputTexture.width,r.height=this._ssrPostProcess.inputTexture.height);return r}_updateEffectDefines(){var e;const t=[];(this._geometryBufferRenderer||this._prePassRenderer)&&t.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&t.push("#define SSRAYTRACE_ENABLE_REFINEMENT"),this._scene.useRightHandedSystem&&t.push("#define SSRAYTRACE_RIGHT_HANDED_SCENE"),this._environmentTexture&&(t.push("#define SSR_USE_ENVIRONMENT_CUBE"),this._environmentTexture.boundingBoxSize&&t.push("#define SSR_USE_LOCAL_REFLECTIONMAP_CUBIC"),this._environmentTexture.gammaSpace&&t.push("#define SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE")),this._environmentTextureIsProbe&&t.push("#define SSR_INVERTCUBICMAP"),this._enableAutomaticThicknessComputation&&t.push("#define SSRAYTRACE_USE_BACK_DEPTHBUFFER"),this._attenuateScreenBorders&&t.push("#define SSR_ATTENUATE_SCREEN_BORDERS"),this._attenuateIntersectionDistance&&t.push("#define SSR_ATTENUATE_INTERSECTION_DISTANCE"),this._attenuateIntersectionIterations&&t.push("#define SSR_ATTENUATE_INTERSECTION_NUMITERATIONS"),this._attenuateFacingCamera&&t.push("#define SSR_ATTENUATE_FACING_CAMERA"),this._attenuateBackfaceReflection&&t.push("#define SSR_ATTENUATE_BACKFACE_REFLECTION"),this._clipToFrustum&&t.push("#define SSRAYTRACE_CLIP_TO_FRUSTUM"),this._useBlur()&&t.push("#define SSR_USE_BLUR"),this._debug&&t.push("#define SSRAYTRACE_DEBUG"),this._inputTextureColorIsInGammaSpace&&t.push("#define SSR_INPUT_IS_GAMMA_SPACE"),this._generateOutputInGammaSpace&&t.push("#define SSR_OUTPUT_IS_GAMMA_SPACE"),this._useFresnel&&t.push("#define SSR_BLEND_WITH_FRESNEL"),this._reflectivityThreshold===0&&t.push("#define SSR_DISABLE_REFLECTIVITY_TEST"),(e=this._ssrPostProcess)===null||e===void 0||e.updateEffect(t.join(`
9961
+ `))}_buildPipeline(){var e;if(!this.isSupported)return;if(!this._isEnabled){this._isDirty=!0;return}this._isDirty=!1;const t=this._scene.getEngine();if(this._disposeDepthRenderer(),this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._enableAutomaticThicknessComputation){const i=(e=this._cameras)===null||e===void 0?void 0:e[0];i&&(this._depthRendererCamera=i,this._depthRenderer=new cr(this._scene,void 0,void 0,void 0,1,!0,"SSRBackDepth"),this._depthRenderer.clearColor.r=1e8,this._depthRenderer.reverseCulling=!0,this._depthRenderer.forceDepthWriteTransparentMeshes=this._backfaceForceDepthWriteTransparentMeshes,this._resizeDepthRenderer(),i.customRenderTargets.push(this._depthRenderer.getDepthMap()))}this._createSSRPostProcess(),this.addEffect(new Le(t,this.SSRRenderEffect,()=>this._ssrPostProcess,!0)),this._useBlur()&&(this._createBlurAndCombinerPostProcesses(),this.addEffect(new Le(t,this.SSRBlurRenderEffect,()=>[this._blurPostProcessX,this._blurPostProcessY],!0)),this.addEffect(new Le(t,this.SSRCombineRenderEffect,()=>this._blurCombinerPostProcess,!0))),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)}_resizeDepthRenderer(){if(!this._depthRenderer)return;const e=this._getTextureSize(),t=this._depthRenderer.getDepthMap().getSize(),i=Math.floor(e.width/(this._backfaceDepthTextureDownsample+1)),s=Math.floor(e.height/(this._backfaceDepthTextureDownsample+1));(t.width!==i||t.height!==s)&&this._depthRenderer.getDepthMap().resize({width:i,height:s})}_disposeDepthRenderer(){var e;if(this._depthRenderer){if(this._depthRendererCamera){const t=(e=this._depthRendererCamera.customRenderTargets.indexOf(this._depthRenderer.getDepthMap()))!==null&&e!==void 0?e:-1;t!==-1&&this._depthRendererCamera.customRenderTargets.splice(t,1)}this._depthRendererCamera=null,this._depthRenderer.getDepthMap().dispose()}this._depthRenderer=null}_disposePostProcesses(){var e,t,i,s;for(let r=0;r<this._cameras.length;r++){const n=this._cameras[r];(e=this._ssrPostProcess)===null||e===void 0||e.dispose(n),(t=this._blurPostProcessX)===null||t===void 0||t.dispose(n),(i=this._blurPostProcessY)===null||i===void 0||i.dispose(n),(s=this._blurCombinerPostProcess)===null||s===void 0||s.dispose(n)}this._ssrPostProcess=null,this._blurPostProcessX=null,this._blurPostProcessY=null,this._blurCombinerPostProcess=null}_createSSRPostProcess(){this._ssrPostProcess=new ue("ssr","screenSpaceReflection2",["projection","invProjectionMatrix","view","invView","thickness","reflectionSpecularFalloffExponent","strength","stepSize","maxSteps","roughnessFactor","projectionPixel","nearPlaneZ","maxDistance","selfCollisionNumSkip","vReflectionPosition","vReflectionSize","backSizeFactor","reflectivityThreshold"],["textureSampler","normalSampler","reflectivitySampler","depthSampler","envCubeSampler","backDepthSampler"],1,null,this._textureType,this._scene.getEngine(),!1,"",this._textureType),this._updateEffectDefines(),this._ssrPostProcess.onApply=e=>{this._resizeDepthRenderer();const t=this._geometryBufferRenderer,i=this._prePassRenderer;if(!i&&!t)return;if(t){const o=t.getTextureIndex(at.REFLECTIVITY_TEXTURE_TYPE);e.setTexture("normalSampler",t.getGBuffer().textures[1]),e.setTexture("reflectivitySampler",t.getGBuffer().textures[o]),e.setTexture("depthSampler",t.getGBuffer().textures[0])}else if(i){const o=i.getIndex(5),h=i.getIndex(3),c=i.getIndex(6);e.setTexture("normalSampler",i.getRenderTarget().textures[c]),e.setTexture("depthSampler",i.getRenderTarget().textures[o]),e.setTexture("reflectivitySampler",i.getRenderTarget().textures[h])}this._enableAutomaticThicknessComputation&&this._depthRenderer&&(e.setTexture("backDepthSampler",this._depthRenderer.getDepthMap()),e.setFloat("backSizeFactor",this._backfaceDepthTextureDownsample+1));const s=this._scene.activeCamera;if(!s)return;const r=s.getViewMatrix(!0),n=s.getProjectionMatrix(!0);n.invertToRef(D.Matrix[0]),r.invertToRef(D.Matrix[1]),e.setMatrix("projection",n),e.setMatrix("view",r),e.setMatrix("invView",D.Matrix[1]),e.setMatrix("invProjectionMatrix",D.Matrix[0]),e.setFloat("thickness",this.thickness),e.setFloat("reflectionSpecularFalloffExponent",this.reflectionSpecularFalloffExponent),e.setFloat("strength",this.strength),e.setFloat("stepSize",this.step),e.setFloat("maxSteps",this.maxSteps),e.setFloat("roughnessFactor",this.roughnessFactor),e.setFloat("nearPlaneZ",s.minZ),e.setFloat("maxDistance",this.maxDistance),e.setFloat("selfCollisionNumSkip",this.selfCollisionNumSkip),e.setFloat("reflectivityThreshold",this._reflectivityThreshold);const a=this._getTextureSize();M.ScalingToRef(a.width,a.height,1,D.Matrix[2]),n.multiplyToRef(this._scene.getEngine().isWebGPU?IE:bE,D.Matrix[3]),D.Matrix[3].multiplyToRef(D.Matrix[2],D.Matrix[4]),e.setMatrix("projectionPixel",D.Matrix[4]),this._environmentTexture&&(e.setTexture("envCubeSampler",this._environmentTexture),this._environmentTexture.boundingBoxSize&&(e.setVector3("vReflectionPosition",this._environmentTexture.boundingBoxPosition),e.setVector3("vReflectionSize",this._environmentTexture.boundingBoxSize)))},this._ssrPostProcess.samples=this.samples,this._forceGeometryBuffer||(this._ssrPostProcess._prePassEffectConfiguration=new dE)}_createBlurAndCombinerPostProcesses(){const e=this._scene.getEngine();this._blurPostProcessX=new ue("SSRblurX","screenSpaceReflection2Blur",["texelOffsetScale"],["textureSampler"],this._useBlur()?1/(this._ssrDownsample+1):1,null,2,e,!1,"",this._textureType),this._blurPostProcessX.autoClear=!1,this._blurPostProcessX.onApplyObservable.add(r=>{var n,a;const o=(a=(n=this._blurPostProcessX)===null||n===void 0?void 0:n.inputTexture.width)!==null&&a!==void 0?a:this._scene.getEngine().getRenderWidth();r.setFloat2("texelOffsetScale",this._blurDispersionStrength/o,0)}),this._blurPostProcessY=new ue("SSRblurY","screenSpaceReflection2Blur",["texelOffsetScale"],["textureSampler"],this._useBlur()?1/(this._blurDownsample+1):1,null,2,e,!1,"",this._textureType),this._blurPostProcessY.autoClear=!1,this._blurPostProcessY.onApplyObservable.add(r=>{var n,a;const o=(a=(n=this._blurPostProcessY)===null||n===void 0?void 0:n.inputTexture.height)!==null&&a!==void 0?a:this._scene.getEngine().getRenderHeight();r.setFloat2("texelOffsetScale",0,this._blurDispersionStrength/o)});const t=["strength","reflectionSpecularFalloffExponent","reflectivityThreshold"],i=["textureSampler","mainSampler","reflectivitySampler"];let s="";this._debug&&(s+=`#define SSRAYTRACE_DEBUG
9962
9962
  `),this._inputTextureColorIsInGammaSpace&&(s+=`#define SSR_INPUT_IS_GAMMA_SPACE
9963
9963
  `),this._generateOutputInGammaSpace&&(s+=`#define SSR_OUTPUT_IS_GAMMA_SPACE
9964
9964
  `),this.useFresnel&&(s+=`#define SSR_BLEND_WITH_FRESNEL
9965
- `,t.push("projection","invProjectionMatrix"),i.push("depthSampler","normalSampler")),this._reflectivityThreshold===0&&(s+="#define SSR_DISABLE_REFLECTIVITY_TEST"),this._blurCombinerPostProcess=new ue("SSRblurCombiner","screenSpaceReflection2BlurCombiner",t,i,this._useBlur()?1/(this._blurDownsample+1):1,null,1,e,!1,s,this._textureType),this._blurCombinerPostProcess.autoClear=!1,this._blurCombinerPostProcess.onApplyObservable.add(r=>{var n;const a=this._geometryBufferRenderer,o=this._prePassRenderer;if(!(!o&&!a)){if(o&&((n=this._scene.activeCamera)===null||n===void 0?void 0:n._getFirstPostProcess())===this._ssrPostProcess){const h=o.getRenderTarget();h&&h.textures&&r.setTexture("mainSampler",h.textures[o.getIndex(4)])}else r.setTextureFromPostProcess("mainSampler",this._ssrPostProcess);if(a){const h=a.getTextureIndex(at.REFLECTIVITY_TEXTURE_TYPE);r.setTexture("reflectivitySampler",a.getGBuffer().textures[h]),this.useFresnel&&(r.setTexture("normalSampler",a.getGBuffer().textures[1]),r.setTexture("depthSampler",a.getGBuffer().textures[0]))}else if(o){const h=o.getIndex(3);if(r.setTexture("reflectivitySampler",o.getRenderTarget().textures[h]),this.useFresnel){const c=o.getIndex(5),u=o.getIndex(6);r.setTexture("normalSampler",o.getRenderTarget().textures[u]),r.setTexture("depthSampler",o.getRenderTarget().textures[c])}}if(r.setFloat("strength",this.strength),r.setFloat("reflectionSpecularFalloffExponent",this.reflectionSpecularFalloffExponent),r.setFloat("reflectivityThreshold",this._reflectivityThreshold),this.useFresnel){const h=this._scene.activeCamera;if(h){const c=h.getProjectionMatrix();c.invertToRef(D.Matrix[0]),r.setMatrix("projection",c),r.setMatrix("invProjectionMatrix",D.Matrix[0])}}}})}serialize(){const e=J.Serialize(this);return e.customType="SSRRenderingPipeline",e}static Parse(e,t,i){return J.Parse(()=>new ze(e._name,t,e._ratio),e,t,i)}}g([v()],ze.prototype,"samples",null),g([v()],ze.prototype,"maxDistance",void 0),g([v()],ze.prototype,"step",void 0),g([v()],ze.prototype,"thickness",void 0),g([v()],ze.prototype,"strength",void 0),g([v()],ze.prototype,"reflectionSpecularFalloffExponent",void 0),g([v()],ze.prototype,"maxSteps",void 0),g([v()],ze.prototype,"roughnessFactor",void 0),g([v()],ze.prototype,"selfCollisionNumSkip",void 0),g([v()],ze.prototype,"_reflectivityThreshold",void 0),g([v("_ssrDownsample")],ze.prototype,"_ssrDownsample",void 0),g([v()],ze.prototype,"ssrDownsample",null),g([v("blurDispersionStrength")],ze.prototype,"_blurDispersionStrength",void 0),g([v("blurDownsample")],ze.prototype,"_blurDownsample",void 0),g([v("enableSmoothReflections")],ze.prototype,"_enableSmoothReflections",void 0),g([v("environmentTexture")],ze.prototype,"_environmentTexture",void 0),g([v("environmentTextureIsProbe")],ze.prototype,"_environmentTextureIsProbe",void 0),g([v("attenuateScreenBorders")],ze.prototype,"_attenuateScreenBorders",void 0),g([v("attenuateIntersectionDistance")],ze.prototype,"_attenuateIntersectionDistance",void 0),g([v("attenuateIntersectionIterations")],ze.prototype,"_attenuateIntersectionIterations",void 0),g([v("attenuateFacingCamera")],ze.prototype,"_attenuateFacingCamera",void 0),g([v("attenuateBackfaceReflection")],ze.prototype,"_attenuateBackfaceReflection",void 0),g([v("clipToFrustum")],ze.prototype,"_clipToFrustum",void 0),g([v("useFresnel")],ze.prototype,"_useFresnel",void 0),g([v("enableAutomaticThicknessComputation")],ze.prototype,"_enableAutomaticThicknessComputation",void 0),g([v("backfaceDepthTextureDownsample")],ze.prototype,"_backfaceDepthTextureDownsample",void 0),g([v("backfaceForceDepthWriteTransparentMeshes")],ze.prototype,"_backfaceForceDepthWriteTransparentMeshes",void 0),g([v("isEnabled")],ze.prototype,"_isEnabled",void 0),g([v("inputTextureColorIsInGammaSpace")],ze.prototype,"_inputTextureColorIsInGammaSpace",void 0),g([v("generateOutputInGammaSpace")],ze.prototype,"_generateOutputInGammaSpace",void 0),g([v("debug")],ze.prototype,"_debug",void 0),Re("BABYLON.SSRRenderingPipeline",ze),Ie.prototype.enableDepthRenderer=function(l,e=!1,t=!1,i=3,s=!1){if(l=l||this.activeCamera,!l)throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[l.id]){const r=!!this.getEngine().getCaps().textureFloatRender;let n=0;this.getEngine().getCaps().textureHalfFloatRender&&(!t||!r)?n=2:r?n=1:n=0,this._depthRenderer[l.id]=new cr(this,n,l,e,i,s)}return this._depthRenderer[l.id]},Ie.prototype.disableDepthRenderer=function(l){l=l||this.activeCamera,!(!l||!this._depthRenderer||!this._depthRenderer[l.id])&&this._depthRenderer[l.id].dispose()};class IE{constructor(e){this.name=ee.NAME_DEPTHRENDERER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(ee.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(ee.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)}rebuild(){}dispose(){for(const e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()}_gatherRenderTargets(e){if(this.scene._depthRenderer)for(const t in this.scene._depthRenderer){const i=this.scene._depthRenderer[t];i.enabled&&!i.useOnlyInActiveCamera&&e.push(i.getDepthMap())}}_gatherActiveCameraRenderTargets(e){if(this.scene._depthRenderer)for(const t in this.scene._depthRenderer){const i=this.scene._depthRenderer[t];i.enabled&&i.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(i.getDepthMap())}}}cr._SceneComponentInitialization=l=>{let e=l._getComponent(ee.NAME_DEPTHRENDERER);e||(e=new IE(l),l._addComponent(e))};class yE{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Et("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(De))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,s,r,n,a,o,h,c,u,f,d,_,p,m,T,S,x,b,I,R,C,y,w,G,te,Q,Te,he,ve,le,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??De.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??De.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((s=e.bloom)==null?void 0:s.enabled)??De.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??De.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??De.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??De.bloom.threshold,this.renderingPipeline.bloomWeight=((o=e.bloom)==null?void 0:o.weight)??De.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((h=e.chromaticAberration)==null?void 0:h.enabled)??De.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??De.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((u=e.chromaticAberration)==null?void 0:u.radialIntensity)??De.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new ae(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new ae(De.chromaticAberration.direction.x,De.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((d=e.colorCurves)==null?void 0:d.enabled)??De.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new Ke,this.renderingPipeline.depthOfFieldEnabled=((_=e.depthOfField)==null?void 0:_.enabled)??De.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??De.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=Ki.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=Ki.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=Ki.High;break}if(this.renderingPipeline.depthOfField.focalLength=((p=e.depthOfField)==null?void 0:p.focalLength)??De.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((m=e.depthOfField)==null?void 0:m.fStop)??De.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((T=e.depthOfField)==null?void 0:T.focusDistance)??De.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((S=e.depthOfField)==null?void 0:S.lensSize)??De.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((x=e.grain)==null?void 0:x.enabled)??De.grain.enabled,this.renderingPipeline.grain.animated=((b=e.grain)==null?void 0:b.animated)??De.grain.animated,this.renderingPipeline.grain.intensity=((I=e.grain)==null?void 0:I.intensity)??De.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((R=e.misc)==null?void 0:R.contrast)??De.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((C=e.misc)==null?void 0:C.exposure)??De.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((y=e.misc)==null?void 0:y.toneMappingEnabled)??De.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??De.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=Se.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=Se.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((w=e.sharpen)==null?void 0:w.enabled)??De.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((G=e.sharpen)==null?void 0:G.colorAmount)??De.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((te=e.sharpen)==null?void 0:te.edgeAmount)??De.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((Q=e.vignette)==null?void 0:Q.enabled)??De.vignette.enabled,(Te=e.vignette)!=null&&Te.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=De.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=De.vignette.center.y),e.vignette)switch(((he=e.vignette)==null?void 0:he.blendMode)??De.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=Se.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=Se.VIGNETTEMODE_OPAQUE;break}(ve=e.vignette)!=null&&ve.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new ge(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(le=e.vignette)!=null&&le.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=ge.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new ge(De.vignette.colorRgba.r,De.vignette.colorRgba.g,De.vignette.colorRgba.b,De.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??De.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??De.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new Ke;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}const Dl=new B,Ll=new B;Object.defineProperty(L.prototype,"onBeforeViewRenderObservable",{get:function(){return Dl}}),Object.defineProperty(L.prototype,"onAfterViewRenderObservable",{get:function(){return Ll}}),Object.defineProperty(L.prototype,"inputElement",{get:function(){return this._inputElement},set:function(l){var e;this._inputElement!==l&&(this._inputElement=l,(e=this._onEngineViewChanged)===null||e===void 0||e.call(this))}}),L.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},L.prototype.registerView=function(l,e,t){this.views||(this.views=[]);for(const r of this.views)if(r.target===l)return r;const i=this.getRenderingCanvas();i&&(l.width=i.width,l.height=i.height);const s={target:l,camera:e,clearBeforeCopy:t,enabled:!0,id:(Math.random()*1e5).toFixed()};return this.views.push(s),e&&e.onDisposeObservable.add(()=>{this.unRegisterView(l)}),s},L.prototype.unRegisterView=function(l){if(!this.views||this.views.length===0)return this;for(const e of this.views)if(e.target===l){const t=this.views.indexOf(e);t!==-1&&this.views.splice(t,1);break}return this},L.prototype._renderViewStep=function(l){const e=l.target,t=e.getContext("2d");if(!t)return!0;const i=this.getRenderingCanvas();Dl.notifyObservers(l);const s=l.camera;let r=null,n=null;if(s){if(n=s.getScene(),!n||n.activeCameras&&n.activeCameras.length)return!0;this.activeView=l,r=n.activeCamera,n.activeCamera=s}if(l.customResize)l.customResize(e);else{const a=Math.floor(e.clientWidth/this._hardwareScalingLevel),o=Math.floor(e.clientHeight/this._hardwareScalingLevel),h=a!==e.width||i.width!==e.width||o!==e.height||i.height!==e.height;e.clientWidth&&e.clientHeight&&h&&(e.width=a,e.height=o,this.setSize(a,o))}return!i.width||!i.height?!1:(this._renderFrame(),this.flushFramebuffer(),l.clearBeforeCopy&&t.clearRect(0,0,i.width,i.height),t.drawImage(i,0,0),r&&n&&(n.activeCamera=r),Ll.notifyObservers(l),!0)},L.prototype._renderViews=function(){if(!this.views||this.views.length===0||!this.getRenderingCanvas())return!1;let e;for(const t of this.views){if(!t.enabled)continue;if(t.target===this.inputElement){e=t;continue}if(!this._renderViewStep(t))return!1}return e&&!this._renderViewStep(e)?!1:(this.activeView=null,!0)};const ME=542327876,Nl=131072,Fl=512,wl=4,Bl=64,Ul=131072;function An(l){return l.charCodeAt(0)+(l.charCodeAt(1)<<8)+(l.charCodeAt(2)<<16)+(l.charCodeAt(3)<<24)}function PE(l){return String.fromCharCode(l&255,l>>8&255,l>>16&255,l>>24&255)}const Vl=An("DXT1"),kl=An("DXT3"),Gl=An("DXT5"),wa=An("DX10"),Hl=113,Wl=116,zl=2,Xl=10,OE=88,Ba=31,DE=0,LE=1,Yl=2,Kl=3,Ua=4,jl=7,Va=20,ql=21,NE=22,FE=23,wE=24,BE=25,UE=26,VE=28,kE=32;class Ve{static GetDDSInfo(e){const t=new Int32Array(e.buffer,e.byteOffset,Ba),i=new Int32Array(e.buffer,e.byteOffset,Ba+4);let s=1;t[Yl]&Nl&&(s=Math.max(1,t[jl]));const r=t[ql],n=r===wa?i[kE]:0;let a=0;switch(r){case Hl:a=2;break;case Wl:a=1;break;case wa:if(n===Xl){a=2;break}if(n===zl){a=1;break}}return{width:t[Ua],height:t[Kl],mipmapCount:s,isFourCC:(t[Va]&wl)===wl,isRGB:(t[Va]&Bl)===Bl,isLuminance:(t[Va]&Ul)===Ul,isCube:(t[VE]&Fl)===Fl,isCompressed:r===Vl||r===kl||r===Gl,dxgiFormat:n,textureType:a}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,i,s,r,n){const a=new Float32Array(s),o=new Uint16Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=cs(o[f]),a[h+1]=cs(o[f+1]),a[h+2]=cs(o[f+2]),Ve.StoreLODInAlphaChannel?a[h+3]=n:a[h+3]=cs(o[f+3]),h+=4}return a}static _GetHalfFloatRGBAArrayBuffer(e,t,i,s,r,n){if(Ve.StoreLODInAlphaChannel){const a=new Uint16Array(s),o=new Uint16Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=o[f],a[h+1]=o[f+1],a[h+2]=o[f+2],a[h+3]=ki(n),h+=4}return a}return new Uint16Array(r,i,s)}static _GetFloatRGBAArrayBuffer(e,t,i,s,r,n){if(Ve.StoreLODInAlphaChannel){const a=new Float32Array(s),o=new Float32Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=o[f],a[h+1]=o[f+1],a[h+2]=o[f+2],a[h+3]=n,h+=4}return a}return new Float32Array(r,i,s)}static _GetFloatAsHalfFloatRGBAArrayBuffer(e,t,i,s,r,n){const a=new Uint16Array(s),o=new Float32Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++)a[h]=ki(o[h]),a[h+1]=ki(o[h+1]),a[h+2]=ki(o[h+2]),Ve.StoreLODInAlphaChannel?a[h+3]=ki(n):a[h+3]=ki(o[h+3]),h+=4;return a}static _GetFloatAsUIntRGBAArrayBuffer(e,t,i,s,r,n){const a=new Uint8Array(s),o=new Float32Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=$.Clamp(o[f])*255,a[h+1]=$.Clamp(o[f+1])*255,a[h+2]=$.Clamp(o[f+2])*255,Ve.StoreLODInAlphaChannel?a[h+3]=n:a[h+3]=$.Clamp(o[f+3])*255,h+=4}return a}static _GetHalfFloatAsUIntRGBAArrayBuffer(e,t,i,s,r,n){const a=new Uint8Array(s),o=new Uint16Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=$.Clamp(cs(o[f]))*255,a[h+1]=$.Clamp(cs(o[f+1]))*255,a[h+2]=$.Clamp(cs(o[f+2]))*255,Ve.StoreLODInAlphaChannel?a[h+3]=n:a[h+3]=$.Clamp(cs(o[f+3]))*255,h+=4}return a}static _GetRGBAArrayBuffer(e,t,i,s,r,n,a,o,h){const c=new Uint8Array(s),u=new Uint8Array(r,i);let f=0;for(let d=0;d<t;d++)for(let _=0;_<e;_++){const p=(_+d*e)*4;c[f]=u[p+n],c[f+1]=u[p+a],c[f+2]=u[p+o],c[f+3]=u[p+h],f+=4}return c}static _ExtractLongWordOrder(e){return e===0||e===255||e===-16777216?0:1+Ve._ExtractLongWordOrder(e>>8)}static _GetRGBArrayBuffer(e,t,i,s,r,n,a,o){const h=new Uint8Array(s),c=new Uint8Array(r,i);let u=0;for(let f=0;f<t;f++)for(let d=0;d<e;d++){const _=(d+f*e)*3;h[u]=c[_+n],h[u+1]=c[_+a],h[u+2]=c[_+o],u+=3}return h}static _GetLuminanceArrayBuffer(e,t,i,s,r){const n=new Uint8Array(s),a=new Uint8Array(r,i);let o=0;for(let h=0;h<t;h++)for(let c=0;c<e;c++){const u=c+h*e;n[o]=a[u],o++}return n}static UploadDDSLevels(e,t,i,s,r,n,a=-1,o,h=!0){let c=null;s.sphericalPolynomial&&(c=new Array);const u=!!e.getCaps().s3tc;t.generateMipMaps=r;const f=new Int32Array(i.buffer,i.byteOffset,Ba);let d,_,p,m=0,T,S,x,b,I=0,R=1;if(f[DE]!==ME){F.Error("Invalid magic number in DDS header");return}if(!s.isFourCC&&!s.isRGB&&!s.isLuminance){F.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");return}if(s.isCompressed&&!u){F.Error("Compressed textures are not supported on this platform.");return}let C=f[NE];T=f[LE]+4;let y=!1;if(s.isFourCC)switch(d=f[ql],d){case Vl:R=8,I=33777;break;case kl:R=16,I=33778;break;case Gl:R=16,I=33779;break;case Hl:y=!0,C=64;break;case Wl:y=!0,C=128;break;case wa:{T+=5*4;let ve=!1;switch(s.dxgiFormat){case Xl:y=!0,C=64,ve=!0;break;case zl:y=!0,C=128,ve=!0;break;case OE:s.isRGB=!0,s.isFourCC=!1,C=32,ve=!0;break}if(ve)break}default:console.error("Unsupported FourCC code:",PE(d));return}const w=Ve._ExtractLongWordOrder(f[FE]),G=Ve._ExtractLongWordOrder(f[wE]),te=Ve._ExtractLongWordOrder(f[BE]),Q=Ve._ExtractLongWordOrder(f[UE]);y&&(I=e._getRGBABufferInternalSizedFormat(s.textureType)),x=1,f[Yl]&Nl&&r!==!1&&(x=Math.max(1,f[jl]));const Te=o||0,he=e.getCaps();for(let ve=Te;ve<n;ve++){for(_=f[Ua],p=f[Kl],b=0;b<x;++b){if(a===-1||a===b){const le=a===-1?b:0;if(!s.isCompressed&&s.isFourCC){t.format=5,m=_*p*4;let be=null;if(e._badOS||e._badDesktopOS||!he.textureHalfFloat&&!he.textureFloat)C===128?(be=Ve._GetFloatAsUIntRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le),c&&le==0&&c.push(Ve._GetFloatRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le))):C===64&&(be=Ve._GetHalfFloatAsUIntRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le),c&&le==0&&c.push(Ve._GetHalfFloatAsFloatRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le))),t.type=0;else{const ye=he.textureFloat&&(h&&he.textureFloatLinearFiltering||!h),Ye=he.textureHalfFloat&&(h&&he.textureHalfFloatLinearFiltering||!h),et=(C===128||C===64&&!Ye)&&ye?1:(C===64||C===128&&!ye)&&Ye?2:0;let Ne,pt=null;switch(C){case 128:{switch(et){case 1:Ne=Ve._GetFloatRGBAArrayBuffer,pt=null;break;case 2:Ne=Ve._GetFloatAsHalfFloatRGBAArrayBuffer,pt=Ve._GetFloatRGBAArrayBuffer;break;case 0:Ne=Ve._GetFloatAsUIntRGBAArrayBuffer,pt=Ve._GetFloatRGBAArrayBuffer;break}break}default:{switch(et){case 1:Ne=Ve._GetHalfFloatAsFloatRGBAArrayBuffer,pt=null;break;case 2:Ne=Ve._GetHalfFloatRGBAArrayBuffer,pt=Ve._GetHalfFloatAsFloatRGBAArrayBuffer;break;case 0:Ne=Ve._GetHalfFloatAsUIntRGBAArrayBuffer,pt=Ve._GetHalfFloatAsFloatRGBAArrayBuffer;break}break}}t.type=et,be=Ne(_,p,i.byteOffset+T,m,i.buffer,le),c&&le==0&&c.push(pt?pt(_,p,i.byteOffset+T,m,i.buffer,le):be)}be&&e._uploadDataToTextureDirectly(t,be,ve,le)}else if(s.isRGB)t.type=0,C===24?(t.format=4,m=_*p*3,S=Ve._GetRGBArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,w,G,te),e._uploadDataToTextureDirectly(t,S,ve,le)):(t.format=5,m=_*p*4,S=Ve._GetRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,w,G,te,Q),e._uploadDataToTextureDirectly(t,S,ve,le));else if(s.isLuminance){const be=e._getUnpackAlignement(),ye=_;m=Math.floor((_+be-1)/be)*be*(p-1)+ye,S=Ve._GetLuminanceArrayBuffer(_,p,i.byteOffset+T,m,i.buffer),t.format=1,t.type=0,e._uploadDataToTextureDirectly(t,S,ve,le)}else m=Math.max(4,_)/4*Math.max(4,p)/4*R,S=new Uint8Array(i.buffer,i.byteOffset+T,m),t.type=0,e._uploadCompressedDataToTextureDirectly(t,I,_,p,S,ve,le)}T+=C?_*p*(C/8):m,_*=.5,p*=.5,_=Math.max(1,_),p=Math.max(1,p)}if(o!==void 0)break}c&&c.length>0?s.sphericalPolynomial=Js.ConvertCubeMapToSphericalPolynomial({size:f[Ua],right:c[0],left:c[1],up:c[2],down:c[3],front:c[4],back:c[5],format:5,type:1,gammaSpace:!1}):s.sphericalPolynomial=void 0}}Ve.StoreLODInAlphaChannel=!1,re.prototype.createPrefilteredCubeTexture=function(l,e,t,i,s=null,r=null,n,a=null,o=!0){const h=c=>{if(!c){s&&s(null);return}const u=c.texture;if(o?c.info.sphericalPolynomial&&(u._sphericalPolynomial=c.info.sphericalPolynomial):u._sphericalPolynomial=new us,u._source=Fe.CubePrefiltered,this.getCaps().textureLOD){s&&s(u);return}const f=3,d=this._gl,_=c.width;if(!_)return;const p=[];for(let m=0;m<f;m++){const S=1-m/(f-1),x=i,b=$.Log2(_)*t+i,I=x+(b-x)*S,R=Math.round(Math.min(Math.max(I,0),b)),C=new ht(this,Fe.Temp);if(C.type=u.type,C.format=u.format,C.width=Math.pow(2,Math.max($.Log2(_)-R,0)),C.height=C.width,C.isCube=!0,C._cachedWrapU=0,C._cachedWrapV=0,this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,C,!0),C.samplingMode=2,d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),c.isDDS){const w=c.info,G=c.data;this._unpackFlipY(w.isCompressed),Ve.UploadDDSLevels(this,C,G,w,!0,6,R)}else F.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null);const y=new Ge(e);y._isCube=!0,y._texture=C,C.isReady=!0,p.push(y)}u._lodTextureHigh=p[2],u._lodTextureMid=p[1],u._lodTextureLow=p[0],s&&s(u)};return this.createCubeTexture(l,e,null,!1,h,r,n,a,o,t,i)};class GE{constructor(){this.supportCascades=!0}canLoad(e){return e.endsWith(".dds")}loadCubeData(e,t,i,s){const r=t.getEngine();let n,a=!1,o=1e3;if(Array.isArray(e))for(let h=0;h<e.length;h++){const c=e[h];n=Ve.GetDDSInfo(c),t.width=n.width,t.height=n.height,a=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps,r._unpackFlipY(n.isCompressed),Ve.UploadDDSLevels(r,t,c,n,a,6,-1,h),!n.isFourCC&&n.mipmapCount===1?r.generateMipMapsForCubemap(t):o=n.mipmapCount-1}else{const h=e;n=Ve.GetDDSInfo(h),t.width=n.width,t.height=n.height,i&&(n.sphericalPolynomial=new us),a=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps,r._unpackFlipY(n.isCompressed),Ve.UploadDDSLevels(r,t,h,n,a,6),!n.isFourCC&&n.mipmapCount===1?r.generateMipMapsForCubemap(t,!1):o=n.mipmapCount-1}r._setCubeMapTextureParams(t,a,o),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s({isDDS:!0,width:t.width,info:n,data:e,texture:t})}loadData(e,t,i){const s=Ve.GetDDSInfo(e),r=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&t.generateMipMaps&&s.width>>s.mipmapCount-1===1;i(s.width,s.height,r,s.isFourCC,()=>{Ve.UploadDDSLevels(t.getEngine(),t,e,s,r,1)})}}L._TextureLoaders.push(new GE);class HE{constructor(){this.supportCascades=!1}canLoad(e){return e.endsWith(".env")}loadCubeData(e,t,i,s,r){if(Array.isArray(e))return;const n=Op(e);if(n){t.width=n.width,t.height=n.width;try{Np(t,n),Lp(t,e,n).then(()=>{t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s()},a=>{r==null||r("Can not upload environment levels",a)})}catch(a){r==null||r("Can not upload environment file",a)}}else r&&r("Can not parse the environment file",null)}loadData(){throw".env not supported in 2d."}}L._TextureLoaders.push(new HE);class oi{constructor(e,t){if(this.data=e,this.isInvalid=!1,!oi.IsValid(e)){this.isInvalid=!0,F.Error("texture missing KTX identifier");return}const i=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.data.buffer,this.data.byteOffset+12,13*i),n=s.getUint32(0,!0)===67305985;if(this.glType=s.getUint32(1*i,n),this.glTypeSize=s.getUint32(2*i,n),this.glFormat=s.getUint32(3*i,n),this.glInternalFormat=s.getUint32(4*i,n),this.glBaseInternalFormat=s.getUint32(5*i,n),this.pixelWidth=s.getUint32(6*i,n),this.pixelHeight=s.getUint32(7*i,n),this.pixelDepth=s.getUint32(8*i,n),this.numberOfArrayElements=s.getUint32(9*i,n),this.numberOfFaces=s.getUint32(10*i,n),this.numberOfMipmapLevels=s.getUint32(11*i,n),this.bytesOfKeyValueData=s.getUint32(12*i,n),this.glType!==0){F.Error("only compressed formats currently supported"),this.isInvalid=!0;return}else this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels);if(this.pixelHeight===0||this.pixelDepth!==0){F.Error("only 2D textures currently supported"),this.isInvalid=!0;return}if(this.numberOfArrayElements!==0){F.Error("texture arrays not currently supported"),this.isInvalid=!0;return}if(this.numberOfFaces!==t){F.Error("number of faces expected"+t+", but found "+this.numberOfFaces),this.isInvalid=!0;return}this.loadType=oi.COMPRESSED_2D}uploadLevels(e,t){switch(this.loadType){case oi.COMPRESSED_2D:this._upload2DCompressedLevels(e,t);break}}_upload2DCompressedLevels(e,t){let i=oi.HEADER_LEN+this.bytesOfKeyValueData,s=this.pixelWidth,r=this.pixelHeight;const n=t?this.numberOfMipmapLevels:1;for(let a=0;a<n;a++){const o=new Int32Array(this.data.buffer,this.data.byteOffset+i,1)[0];i+=4;for(let h=0;h<this.numberOfFaces;h++){const c=new Uint8Array(this.data.buffer,this.data.byteOffset+i,o);e.getEngine()._uploadCompressedDataToTextureDirectly(e,e.format,s,r,c,h,a),i+=o,i+=3-(o+3)%4}s=Math.max(1,s*.5),r=Math.max(1,r*.5)}}static IsValid(e){if(e.byteLength>=12){const t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===49&&t[6]===49&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}}oi.HEADER_LEN=12+13*4,oi.COMPRESSED_2D=0,oi.COMPRESSED_3D=1,oi.TEX_2D=2,oi.TEX_3D=3;var Zl;(function(l){l[l.ETC1S=0]="ETC1S",l[l.UASTC4x4=1]="UASTC4x4"})(Zl||(Zl={}));var zr;(function(l){l[l.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",l[l.BC7_RGBA=1]="BC7_RGBA",l[l.BC3_RGBA=2]="BC3_RGBA",l[l.BC1_RGB=3]="BC1_RGB",l[l.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",l[l.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",l[l.ETC2_RGBA=6]="ETC2_RGBA",l[l.ETC1_RGB=7]="ETC1_RGB",l[l.RGBA32=8]="RGBA32",l[l.R8=9]="R8",l[l.RG8=10]="RG8"})(zr||(zr={}));var ka;(function(l){l[l.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",l[l.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",l[l.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",l[l.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",l[l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",l[l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",l[l.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",l[l.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",l[l.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",l[l.RGBA8Format=32856]="RGBA8Format",l[l.R8Format=33321]="R8Format",l[l.RG8Format=33323]="RG8Format"})(ka||(ka={}));function ji(l){return l?k.GetAbsoluteUrl(l):null}function Ga(l){l.wasmUASTCToASTC!==null&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=l.wasmUASTCToASTC),l.wasmUASTCToBC7!==null&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=l.wasmUASTCToBC7),l.wasmUASTCToRGBA_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=l.wasmUASTCToRGBA_UNORM),l.wasmUASTCToRGBA_SRGB!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=l.wasmUASTCToRGBA_SRGB),l.wasmUASTCToR8_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=l.wasmUASTCToR8_UNORM),l.wasmUASTCToRG8_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=l.wasmUASTCToRG8_UNORM),l.jsMSCTranscoder!==null&&(KTX2DECODER.MSCTranscoder.JSModuleURL=l.jsMSCTranscoder),l.wasmMSCTranscoder!==null&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=l.wasmMSCTranscoder),l.wasmZSTDDecoder!==null&&(KTX2DECODER.ZSTDDecoder.WasmModuleURL=l.wasmZSTDDecoder)}class WE{constructor(){this._isDirty=!0,this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=!0,this._ktx2DecoderOptions={}}get isDirty(){return this._isDirty}get useRGBAIfASTCBC7NotAvailableWhenUASTC(){return this._useRGBAIfASTCBC7NotAvailableWhenUASTC}set useRGBAIfASTCBC7NotAvailableWhenUASTC(e){this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==e&&(this._useRGBAIfASTCBC7NotAvailableWhenUASTC=e,this._isDirty=!0)}get useRGBAIfOnlyBC1BC3AvailableWhenUASTC(){return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC}set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(e){this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC!==e&&(this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=e,this._isDirty=!0)}get forceRGBA(){return this._forceRGBA}set forceRGBA(e){this._forceRGBA!==e&&(this._forceRGBA=e,this._isDirty=!0)}get forceR8(){return this._forceR8}set forceR8(e){this._forceR8!==e&&(this._forceR8=e,this._isDirty=!0)}get forceRG8(){return this._forceRG8}set forceRG8(e){this._forceRG8!==e&&(this._forceRG8=e,this._isDirty=!0)}get bypassTranscoders(){return this._bypassTranscoders}set bypassTranscoders(e){this._bypassTranscoders!==e&&(this._bypassTranscoders=e,this._isDirty=!0)}_getKTX2DecoderOptions(){if(!this._isDirty)return this._ktx2DecoderOptions;this._isDirty=!1;const e={useRGBAIfASTCBC7NotAvailableWhenUASTC:this._useRGBAIfASTCBC7NotAvailableWhenUASTC,forceRGBA:this._forceRGBA,forceR8:this._forceR8,forceRG8:this._forceRG8,bypassTranscoders:this._bypassTranscoders};return this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC&&(e.transcodeFormatDecisionTree={UASTC:{transcodeFormat:[zr.BC1_RGB,zr.BC3_RGBA],yes:{transcodeFormat:zr.RGBA32,engineFormat:ka.RGBA8Format,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=e,e}}class Tt{static GetDefaultNumWorkers(){return typeof navigator!="object"||!navigator.hardwareConcurrency?1:Math.min(Math.floor(navigator.hardwareConcurrency*.5),4)}static _Initialize(e){if(Tt._WorkerPoolPromise||Tt._DecoderModulePromise)return;const t={jsDecoderModule:k.GetAbsoluteUrl(this.URLConfig.jsDecoderModule),wasmUASTCToASTC:ji(this.URLConfig.wasmUASTCToASTC),wasmUASTCToBC7:ji(this.URLConfig.wasmUASTCToBC7),wasmUASTCToRGBA_UNORM:ji(this.URLConfig.wasmUASTCToRGBA_UNORM),wasmUASTCToRGBA_SRGB:ji(this.URLConfig.wasmUASTCToRGBA_SRGB),wasmUASTCToR8_UNORM:ji(this.URLConfig.wasmUASTCToR8_UNORM),wasmUASTCToRG8_UNORM:ji(this.URLConfig.wasmUASTCToRG8_UNORM),jsMSCTranscoder:ji(this.URLConfig.jsMSCTranscoder),wasmMSCTranscoder:ji(this.URLConfig.wasmMSCTranscoder),wasmZSTDDecoder:ji(this.URLConfig.wasmZSTDDecoder)};e&&typeof Worker=="function"&&typeof URL<"u"?Tt._WorkerPoolPromise=new Promise(i=>{const s=`${Ga}(${zE})()`,r=URL.createObjectURL(new Blob([s],{type:"application/javascript"}));i(new yr(e,()=>new Promise((n,a)=>{const o=new Worker(r),h=u=>{o.removeEventListener("error",h),o.removeEventListener("message",c),a(u)},c=u=>{u.data.action==="init"&&(o.removeEventListener("error",h),o.removeEventListener("message",c),n(o))};o.addEventListener("error",h),o.addEventListener("message",c),o.postMessage({action:"init",urls:t})})))}):typeof KTX2DECODER>"u"?Tt._DecoderModulePromise=k.LoadScriptAsync(t.jsDecoderModule).then(()=>(KTX2DECODER.MSCTranscoder.UseFromWorkerThread=!1,KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,Ga(t),new KTX2DECODER.KTX2Decoder)):(KTX2DECODER.MSCTranscoder.UseFromWorkerThread=!1,KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,Tt._DecoderModulePromise=Promise.resolve(new KTX2DECODER.KTX2Decoder))}constructor(e,t=Tt.DefaultNumWorkers){this._engine=e,Tt._Initialize(t)}uploadAsync(e,t,i){const s=this._engine.getCaps(),r={astc:!!s.astc,bptc:!!s.bptc,s3tc:!!s.s3tc,pvrtc:!!s.pvrtc,etc2:!!s.etc2,etc1:!!s.etc1};if(Tt._WorkerPoolPromise)return Tt._WorkerPoolPromise.then(n=>new Promise((a,o)=>{n.push((h,c)=>{const u=_=>{h.removeEventListener("error",u),h.removeEventListener("message",f),o(_),c()},f=_=>{if(_.data.action==="decoded"){if(h.removeEventListener("error",u),h.removeEventListener("message",f),!_.data.success)o({message:_.data.msg});else try{this._createTexture(_.data.decodedData,t,i),a()}catch(p){o({message:p})}c()}};h.addEventListener("error",u),h.addEventListener("message",f),h.postMessage({action:"setDefaultDecoderOptions",options:Tt.DefaultDecoderOptions._getKTX2DecoderOptions()});const d=new Uint8Array(e.byteLength);d.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),h.postMessage({action:"decode",data:d,caps:r,options:i},[d.buffer])})}));if(Tt._DecoderModulePromise)return Tt._DecoderModulePromise.then(n=>(Tt.DefaultDecoderOptions.isDirty&&(KTX2DECODER.KTX2Decoder.DefaultDecoderOptions=Tt.DefaultDecoderOptions._getKTX2DecoderOptions()),new Promise((a,o)=>{n.decode(e,s).then(h=>{this._createTexture(h,t),a()}).catch(h=>{o({message:h})})})));throw new Error("KTX2 decoder module is not available")}_createTexture(e,t,i){this._engine._bindTextureDirectly(3553,t),i&&(i.transcodedFormat=e.transcodedFormat,i.isInGammaSpace=e.isInGammaSpace,i.hasAlpha=e.hasAlpha,i.transcoderName=e.transcoderName);let r=!0;switch(e.transcodedFormat){case 32856:t.type=0,t.format=5;break;case 33321:t.type=0,t.format=6;break;case 33323:t.type=0,t.format=7;break;default:t.format=e.transcodedFormat,r=!1;break}if(t._gammaSpace=e.isInGammaSpace,t.generateMipMaps=e.mipmaps.length>1,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(let n=0;n<e.mipmaps.length;++n){const a=e.mipmaps[n];if(!a||!a.data)throw new Error("KTX2 container - could not transcode one of the image");r?(t.width=a.width,t.height=a.height,this._engine._uploadDataToTextureDirectly(t,a.data,0,n,void 0,!0)):this._engine._uploadCompressedDataToTextureDirectly(t,e.transcodedFormat,a.width,a.height,a.data,0,n)}t._extension=".ktx2",t.width=e.mipmaps[0].width,t.height=e.mipmaps[0].height,t.isReady=!0,this._engine._bindTextureDirectly(3553,null)}static IsValid(e){if(e.byteLength>=12){const t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===50&&t[6]===48&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}}Tt.URLConfig={jsDecoderModule:"https://preview.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null},Tt.DefaultNumWorkers=Tt.GetDefaultNumWorkers(),Tt.DefaultDecoderOptions=new WE;function zE(){let l;onmessage=e=>{if(e.data)switch(e.data.action){case"init":{const t=e.data.urls;importScripts(t.jsDecoderModule),Ga(t),l=new KTX2DECODER.KTX2Decoder,postMessage({action:"init"});break}case"setDefaultDecoderOptions":{KTX2DECODER.KTX2Decoder.DefaultDecoderOptions=e.data.options;break}case"decode":l.decode(e.data.data,e.data.caps,e.data.options).then(t=>{const i=[];for(let s=0;s<t.mipmaps.length;++s){const r=t.mipmaps[s];r&&r.data&&i.push(r.data.buffer)}postMessage({action:"decoded",success:!0,decodedData:t},i)}).catch(t=>{postMessage({action:"decoded",success:!1,msg:t})});break}}}function XE(l){switch(l){case 35916:return 33776;case 35918:return 33778;case 35919:return 33779;case 37493:return 37492;case 37497:return 37496;case 37495:return 37494;case 37840:return 37808;case 36493:return 36492}return null}class YE{constructor(){this.supportCascades=!1}canLoad(e,t){return e.endsWith(".ktx")||e.endsWith(".ktx2")||t==="image/ktx"||t==="image/ktx2"}loadCubeData(e,t,i,s){if(Array.isArray(e))return;t._invertVScale=!t.invertY;const r=t.getEngine(),n=new oi(e,6),a=n.numberOfMipmapLevels>1&&t.generateMipMaps;r._unpackFlipY(!0),n.uploadLevels(t,t.generateMipMaps),t.width=n.pixelWidth,t.height=n.pixelHeight,r._setCubeMapTextureParams(t,a,n.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s()}loadData(e,t,i,s){if(oi.IsValid(e)){t._invertVScale=!t.invertY;const r=new oi(e,1),n=XE(r.glInternalFormat);n?(t.format=n,t._useSRGBBuffer=t.getEngine()._getUseSRGBBuffer(!0,t.generateMipMaps),t._gammaSpace=!0):t.format=r.glInternalFormat,i(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,()=>{r.uploadLevels(t,t.generateMipMaps)},r.isInvalid)}else Tt.IsValid(e)?new Tt(t.getEngine()).uploadAsync(e,t,s).then(()=>{i(t.width,t.height,t.generateMipMaps,!0,()=>{},!1)},n=>{F.Warn(`Failed to load KTX2 texture data: ${n.message}`),i(0,0,!1,!1,()=>{},!0)}):(F.Error("texture missing KTX identifier"),i(0,0,!1,!1,()=>{},!0))}}L._TextureLoaders.unshift(new YE);let ps=null;function Ql(l,e,t,i,s="image/png",r=!1,n){const{height:a,width:o}=$l(l,e,t);if(!(a&&o)){F.Error("Invalid 'size' parameter !");return}ps||(ps=document.createElement("canvas")),ps.width=o,ps.height=a;const h=ps.getContext("2d"),c=l.getRenderWidth()/l.getRenderHeight();let u=o,f=u/c;f>a&&(f=a,u=f*c);const d=Math.max(0,o-u)/2,_=Math.max(0,a-f)/2;e.getScene().activeCamera!==e?Ha(l,e,t,m=>{if(r){const T=new Blob([m]);k.DownloadBlob(T),i&&i("")}else i&&i(m)},s,1,l.getCreationOptions().antialias,void 0,void 0,void 0,void 0,n):l.onEndFrameObservable.addOnce(()=>{const m=l.getRenderingCanvas();h&&m&&h.drawImage(m,d,_,u,f),ps&&(r?(k.EncodeScreenshotCanvasData(ps,void 0,s,void 0,n),i&&i("")):k.EncodeScreenshotCanvasData(ps,i,s,void 0,n))})}function KE(l,e,t,i="image/png",s){return new Promise((r,n)=>{Ql(l,e,t,a=>{typeof a<"u"?r(a):n(new Error("Data is undefined"))},i,void 0,s)})}function Ha(l,e,t,i,s="image/png",r=1,n=!1,a,o=!1,h=!1,c=!0,u){const{height:f,width:d,finalWidth:_,finalHeight:p}=$l(l,e,t),m={width:d,height:f};if(!(f&&d)){F.Error("Invalid 'size' parameter !");return}const T={width:l.getRenderWidth(),height:l.getRenderHeight()};l.setSize(d,f);const S=e.getScene(),x=new Dt("screenShot",m,S,!1,!1,0,!1,O.BILINEAR_SAMPLINGMODE,void 0,h,void 0,void 0,void 0,r);x.renderList=S.meshes.slice(),x.samples=r,x.renderSprites=o,x.activeCamera=e,x.forceLayerMaskCheck=c;const b=()=>{l.onEndFrameObservable.addOnce(()=>{_===d&&p===f?x.readPixels(void 0,void 0,void 0,!1).then(I=>{Ot.DumpData(d,f,I,i,s,a,!0,void 0,u),x.dispose()}):il("pass",x.getInternalTexture(),S,void 0,void 0,void 0,_,p).then(I=>{l._readTexturePixels(I,_,p,-1,0,null,!0,!1,0,0).then(R=>{Ot.DumpData(_,p,R,i,s,a,!0,void 0,u),I.dispose()})})}),S.incrementRenderId(),S.resetCachedMaterial(),x.render(!0),S.incrementRenderId(),S.resetCachedMaterial(),l.setSize(T.width,T.height),e.getProjectionMatrix(!0),S.render()};if(n){const I=new or("antialiasing",1,S.activeCamera);x.addPostProcess(I),I.getEffect().isReady()?b():I.getEffect().onCompiled=()=>{b()}}else b()}function jE(l,e,t,i="image/png",s=1,r=!1,n,a=!1,o=!1,h=!0,c){return new Promise((u,f)=>{Ha(l,e,t,d=>{typeof d<"u"?u(d):f(new Error("Data is undefined"))},i,s,r,n,a,o,h,c)})}function $l(l,e,t){let i=0,s=0,r=0,n=0;if(typeof t=="object"){const a=t.precision?Math.abs(t.precision):1;t.width&&t.height?(i=t.height*a,s=t.width*a):t.width&&!t.height?(s=t.width*a,i=Math.round(s/l.getAspectRatio(e))):t.height&&!t.width?(i=t.height*a,s=Math.round(i*l.getAspectRatio(e))):(s=Math.round(l.getRenderWidth()*a),i=Math.round(s/l.getAspectRatio(e))),t.finalWidth&&t.finalHeight?(n=t.finalHeight,r=t.finalWidth):t.finalWidth&&!t.finalHeight?(r=t.finalWidth,n=Math.round(r/l.getAspectRatio(e))):t.finalHeight&&!t.finalWidth?(n=t.finalHeight,r=Math.round(n*l.getAspectRatio(e))):(r=s,n=i)}else isNaN(t)||(i=t,s=t,r=t,n=t);return s&&(s=Math.floor(s)),i&&(i=Math.floor(i)),r&&(r=Math.floor(r)),n&&(n=Math.floor(n)),{height:i|0,width:s|0,finalWidth:r|0,finalHeight:n|0}}(()=>{k.CreateScreenshot=Ql,k.CreateScreenshotAsync=KE,k.CreateScreenshotUsingRenderTarget=Ha,k.CreateScreenshotUsingRenderTargetAsync=jE})();function Wa(l){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=l.width||l.size||1,a=l.height||l.size||1,o=l.depth||l.size||1,h=l.wrap||!1;let c=l.topBaseAt===void 0?1:l.topBaseAt,u=l.bottomBaseAt===void 0?0:l.bottomBaseAt;c=(c+4)%4,u=(u+4)%4;const f=[2,0,3,1],d=[2,0,1,3];let _=f[c],p=d[u],m=[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],m=[-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 C=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],y=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const w=[17,18,19,16],G=[22,23,20,21];for(;_>0;)C.unshift(C.pop()),w.unshift(w.pop()),_--;for(;p>0;)y.unshift(y.pop()),G.unshift(G.pop()),p--;C=C.flat(),y=y.flat(),m=m.concat(C).concat(y),t.push(w[0],w[2],w[3],w[0],w[1],w[2]),t.push(G[0],G[2],G[3],G[0],G[1],G[2])}const T=[n/2,a/2,o/2];r=m.reduce((C,y,w)=>C.concat(y*T[w%3]),[]);const S=l.sideOrientation===0?0:l.sideOrientation||me.DEFAULTSIDE,x=l.faceUV||new Array(6),b=l.faceColors,I=[];for(let C=0;C<6;C++)x[C]===void 0&&(x[C]=new He(0,0,1,1)),b&&b[C]===void 0&&(b[C]=new ge(1,1,1,1));for(let C=0;C<6;C++)if(s.push(x[C].z,si.UseOpenGLOrientationForUV?1-x[C].w:x[C].w),s.push(x[C].x,si.UseOpenGLOrientationForUV?1-x[C].w:x[C].w),s.push(x[C].x,si.UseOpenGLOrientationForUV?1-x[C].y:x[C].y),s.push(x[C].z,si.UseOpenGLOrientationForUV?1-x[C].y:x[C].y),b)for(let y=0;y<4;y++)I.push(b[C].r,b[C].g,b[C].b,b[C].a);me._ComputeSides(S,r,t,i,s,l.frontUVs,l.backUVs);const R=new me;if(R.indices=t,R.positions=r,R.normals=i,R.uvs=s,b){const C=S===me.DOUBLESIDE?I.concat(I):I;R.colors=C}return R}function qE(l,e={},t=null){const i=new ne(l,t);return e.sideOrientation=ne._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Wa(e).applyToMesh(i,e.updatable),i}me.CreateBox=Wa,ne.CreateBox=(l,e,t=null,i,s)=>qE(l,{size:e,sideOrientation:s,updatable:i},t);const ZE="boundingBoxRendererFragmentDeclaration",QE=`uniform vec4 color;
9966
- `;U.IncludesShadersStore[ZE]=QE;const $E="boundingBoxRendererUboDeclaration",JE=`#ifdef WEBGL2
9965
+ `,t.push("projection","invProjectionMatrix"),i.push("depthSampler","normalSampler")),this._reflectivityThreshold===0&&(s+="#define SSR_DISABLE_REFLECTIVITY_TEST"),this._blurCombinerPostProcess=new ue("SSRblurCombiner","screenSpaceReflection2BlurCombiner",t,i,this._useBlur()?1/(this._blurDownsample+1):1,null,1,e,!1,s,this._textureType),this._blurCombinerPostProcess.autoClear=!1,this._blurCombinerPostProcess.onApplyObservable.add(r=>{var n;const a=this._geometryBufferRenderer,o=this._prePassRenderer;if(!(!o&&!a)){if(o&&((n=this._scene.activeCamera)===null||n===void 0?void 0:n._getFirstPostProcess())===this._ssrPostProcess){const h=o.getRenderTarget();h&&h.textures&&r.setTexture("mainSampler",h.textures[o.getIndex(4)])}else r.setTextureFromPostProcess("mainSampler",this._ssrPostProcess);if(a){const h=a.getTextureIndex(at.REFLECTIVITY_TEXTURE_TYPE);r.setTexture("reflectivitySampler",a.getGBuffer().textures[h]),this.useFresnel&&(r.setTexture("normalSampler",a.getGBuffer().textures[1]),r.setTexture("depthSampler",a.getGBuffer().textures[0]))}else if(o){const h=o.getIndex(3);if(r.setTexture("reflectivitySampler",o.getRenderTarget().textures[h]),this.useFresnel){const c=o.getIndex(5),u=o.getIndex(6);r.setTexture("normalSampler",o.getRenderTarget().textures[u]),r.setTexture("depthSampler",o.getRenderTarget().textures[c])}}if(r.setFloat("strength",this.strength),r.setFloat("reflectionSpecularFalloffExponent",this.reflectionSpecularFalloffExponent),r.setFloat("reflectivityThreshold",this._reflectivityThreshold),this.useFresnel){const h=this._scene.activeCamera;if(h){const c=h.getProjectionMatrix();c.invertToRef(D.Matrix[0]),r.setMatrix("projection",c),r.setMatrix("invProjectionMatrix",D.Matrix[0])}}}})}serialize(){const e=J.Serialize(this);return e.customType="SSRRenderingPipeline",e}static Parse(e,t,i){return J.Parse(()=>new ze(e._name,t,e._ratio),e,t,i)}}g([v()],ze.prototype,"samples",null),g([v()],ze.prototype,"maxDistance",void 0),g([v()],ze.prototype,"step",void 0),g([v()],ze.prototype,"thickness",void 0),g([v()],ze.prototype,"strength",void 0),g([v()],ze.prototype,"reflectionSpecularFalloffExponent",void 0),g([v()],ze.prototype,"maxSteps",void 0),g([v()],ze.prototype,"roughnessFactor",void 0),g([v()],ze.prototype,"selfCollisionNumSkip",void 0),g([v()],ze.prototype,"_reflectivityThreshold",void 0),g([v("_ssrDownsample")],ze.prototype,"_ssrDownsample",void 0),g([v()],ze.prototype,"ssrDownsample",null),g([v("blurDispersionStrength")],ze.prototype,"_blurDispersionStrength",void 0),g([v("blurDownsample")],ze.prototype,"_blurDownsample",void 0),g([v("enableSmoothReflections")],ze.prototype,"_enableSmoothReflections",void 0),g([v("environmentTexture")],ze.prototype,"_environmentTexture",void 0),g([v("environmentTextureIsProbe")],ze.prototype,"_environmentTextureIsProbe",void 0),g([v("attenuateScreenBorders")],ze.prototype,"_attenuateScreenBorders",void 0),g([v("attenuateIntersectionDistance")],ze.prototype,"_attenuateIntersectionDistance",void 0),g([v("attenuateIntersectionIterations")],ze.prototype,"_attenuateIntersectionIterations",void 0),g([v("attenuateFacingCamera")],ze.prototype,"_attenuateFacingCamera",void 0),g([v("attenuateBackfaceReflection")],ze.prototype,"_attenuateBackfaceReflection",void 0),g([v("clipToFrustum")],ze.prototype,"_clipToFrustum",void 0),g([v("useFresnel")],ze.prototype,"_useFresnel",void 0),g([v("enableAutomaticThicknessComputation")],ze.prototype,"_enableAutomaticThicknessComputation",void 0),g([v("backfaceDepthTextureDownsample")],ze.prototype,"_backfaceDepthTextureDownsample",void 0),g([v("backfaceForceDepthWriteTransparentMeshes")],ze.prototype,"_backfaceForceDepthWriteTransparentMeshes",void 0),g([v("isEnabled")],ze.prototype,"_isEnabled",void 0),g([v("inputTextureColorIsInGammaSpace")],ze.prototype,"_inputTextureColorIsInGammaSpace",void 0),g([v("generateOutputInGammaSpace")],ze.prototype,"_generateOutputInGammaSpace",void 0),g([v("debug")],ze.prototype,"_debug",void 0),Re("BABYLON.SSRRenderingPipeline",ze),Ie.prototype.enableDepthRenderer=function(l,e=!1,t=!1,i=3,s=!1){if(l=l||this.activeCamera,!l)throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[l.id]){const r=!!this.getEngine().getCaps().textureFloatRender;let n=0;this.getEngine().getCaps().textureHalfFloatRender&&(!t||!r)?n=2:r?n=1:n=0,this._depthRenderer[l.id]=new cr(this,n,l,e,i,s)}return this._depthRenderer[l.id]},Ie.prototype.disableDepthRenderer=function(l){l=l||this.activeCamera,!(!l||!this._depthRenderer||!this._depthRenderer[l.id])&&this._depthRenderer[l.id].dispose()};class yE{constructor(e){this.name=ee.NAME_DEPTHRENDERER,this.scene=e}register(){this.scene._gatherRenderTargetsStage.registerStep(ee.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(ee.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)}rebuild(){}dispose(){for(const e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()}_gatherRenderTargets(e){if(this.scene._depthRenderer)for(const t in this.scene._depthRenderer){const i=this.scene._depthRenderer[t];i.enabled&&!i.useOnlyInActiveCamera&&e.push(i.getDepthMap())}}_gatherActiveCameraRenderTargets(e){if(this.scene._depthRenderer)for(const t in this.scene._depthRenderer){const i=this.scene._depthRenderer[t];i.enabled&&i.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(i.getDepthMap())}}}cr._SceneComponentInitialization=l=>{let e=l._getComponent(ee.NAME_DEPTHRENDERER);e||(e=new yE(l),l._addComponent(e))};class ME{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Et("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(De))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,s,r,n,a,o,h,c,u,f,d,_,p,m,T,S,x,b,I,R,C,y,w,G,te,Q,Te,he,ve,le,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??De.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??De.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((s=e.bloom)==null?void 0:s.enabled)??De.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??De.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??De.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??De.bloom.threshold,this.renderingPipeline.bloomWeight=((o=e.bloom)==null?void 0:o.weight)??De.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((h=e.chromaticAberration)==null?void 0:h.enabled)??De.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??De.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((u=e.chromaticAberration)==null?void 0:u.radialIntensity)??De.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new ae(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new ae(De.chromaticAberration.direction.x,De.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((d=e.colorCurves)==null?void 0:d.enabled)??De.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new Ke,this.renderingPipeline.depthOfFieldEnabled=((_=e.depthOfField)==null?void 0:_.enabled)??De.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??De.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=Ki.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=Ki.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=Ki.High;break}if(this.renderingPipeline.depthOfField.focalLength=((p=e.depthOfField)==null?void 0:p.focalLength)??De.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((m=e.depthOfField)==null?void 0:m.fStop)??De.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((T=e.depthOfField)==null?void 0:T.focusDistance)??De.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((S=e.depthOfField)==null?void 0:S.lensSize)??De.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((x=e.grain)==null?void 0:x.enabled)??De.grain.enabled,this.renderingPipeline.grain.animated=((b=e.grain)==null?void 0:b.animated)??De.grain.animated,this.renderingPipeline.grain.intensity=((I=e.grain)==null?void 0:I.intensity)??De.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((R=e.misc)==null?void 0:R.contrast)??De.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((C=e.misc)==null?void 0:C.exposure)??De.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((y=e.misc)==null?void 0:y.toneMappingEnabled)??De.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??De.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=Se.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=Se.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((w=e.sharpen)==null?void 0:w.enabled)??De.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((G=e.sharpen)==null?void 0:G.colorAmount)??De.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((te=e.sharpen)==null?void 0:te.edgeAmount)??De.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((Q=e.vignette)==null?void 0:Q.enabled)??De.vignette.enabled,(Te=e.vignette)!=null&&Te.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=De.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=De.vignette.center.y),e.vignette)switch(((he=e.vignette)==null?void 0:he.blendMode)??De.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=Se.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=Se.VIGNETTEMODE_OPAQUE;break}(ve=e.vignette)!=null&&ve.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new ge(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(le=e.vignette)!=null&&le.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=ge.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new ge(De.vignette.colorRgba.r,De.vignette.colorRgba.g,De.vignette.colorRgba.b,De.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??De.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??De.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new Ke;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}const Dl=new B,Ll=new B;Object.defineProperty(L.prototype,"onBeforeViewRenderObservable",{get:function(){return Dl}}),Object.defineProperty(L.prototype,"onAfterViewRenderObservable",{get:function(){return Ll}}),Object.defineProperty(L.prototype,"inputElement",{get:function(){return this._inputElement},set:function(l){var e;this._inputElement!==l&&(this._inputElement=l,(e=this._onEngineViewChanged)===null||e===void 0||e.call(this))}}),L.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},L.prototype.registerView=function(l,e,t){this.views||(this.views=[]);for(const r of this.views)if(r.target===l)return r;const i=this.getRenderingCanvas();i&&(l.width=i.width,l.height=i.height);const s={target:l,camera:e,clearBeforeCopy:t,enabled:!0,id:(Math.random()*1e5).toFixed()};return this.views.push(s),e&&e.onDisposeObservable.add(()=>{this.unRegisterView(l)}),s},L.prototype.unRegisterView=function(l){if(!this.views||this.views.length===0)return this;for(const e of this.views)if(e.target===l){const t=this.views.indexOf(e);t!==-1&&this.views.splice(t,1);break}return this},L.prototype._renderViewStep=function(l){const e=l.target,t=e.getContext("2d");if(!t)return!0;const i=this.getRenderingCanvas();Dl.notifyObservers(l);const s=l.camera;let r=null,n=null;if(s){if(n=s.getScene(),!n||n.activeCameras&&n.activeCameras.length)return!0;this.activeView=l,r=n.activeCamera,n.activeCamera=s}if(l.customResize)l.customResize(e);else{const a=Math.floor(e.clientWidth/this._hardwareScalingLevel),o=Math.floor(e.clientHeight/this._hardwareScalingLevel),h=a!==e.width||i.width!==e.width||o!==e.height||i.height!==e.height;e.clientWidth&&e.clientHeight&&h&&(e.width=a,e.height=o,this.setSize(a,o))}return!i.width||!i.height?!1:(this._renderFrame(),this.flushFramebuffer(),l.clearBeforeCopy&&t.clearRect(0,0,i.width,i.height),t.drawImage(i,0,0),r&&n&&(n.activeCamera=r),Ll.notifyObservers(l),!0)},L.prototype._renderViews=function(){if(!this.views||this.views.length===0||!this.getRenderingCanvas())return!1;let e;for(const t of this.views){if(!t.enabled)continue;if(t.target===this.inputElement){e=t;continue}if(!this._renderViewStep(t))return!1}return e&&!this._renderViewStep(e)?!1:(this.activeView=null,!0)};const PE=542327876,Nl=131072,Fl=512,wl=4,Bl=64,Ul=131072;function An(l){return l.charCodeAt(0)+(l.charCodeAt(1)<<8)+(l.charCodeAt(2)<<16)+(l.charCodeAt(3)<<24)}function OE(l){return String.fromCharCode(l&255,l>>8&255,l>>16&255,l>>24&255)}const Vl=An("DXT1"),kl=An("DXT3"),Gl=An("DXT5"),wa=An("DX10"),Hl=113,Wl=116,zl=2,Xl=10,DE=88,Ba=31,LE=0,NE=1,Yl=2,Kl=3,Ua=4,jl=7,Va=20,ql=21,FE=22,wE=23,BE=24,UE=25,VE=26,kE=28,GE=32;class Ve{static GetDDSInfo(e){const t=new Int32Array(e.buffer,e.byteOffset,Ba),i=new Int32Array(e.buffer,e.byteOffset,Ba+4);let s=1;t[Yl]&Nl&&(s=Math.max(1,t[jl]));const r=t[ql],n=r===wa?i[GE]:0;let a=0;switch(r){case Hl:a=2;break;case Wl:a=1;break;case wa:if(n===Xl){a=2;break}if(n===zl){a=1;break}}return{width:t[Ua],height:t[Kl],mipmapCount:s,isFourCC:(t[Va]&wl)===wl,isRGB:(t[Va]&Bl)===Bl,isLuminance:(t[Va]&Ul)===Ul,isCube:(t[kE]&Fl)===Fl,isCompressed:r===Vl||r===kl||r===Gl,dxgiFormat:n,textureType:a}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,i,s,r,n){const a=new Float32Array(s),o=new Uint16Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=cs(o[f]),a[h+1]=cs(o[f+1]),a[h+2]=cs(o[f+2]),Ve.StoreLODInAlphaChannel?a[h+3]=n:a[h+3]=cs(o[f+3]),h+=4}return a}static _GetHalfFloatRGBAArrayBuffer(e,t,i,s,r,n){if(Ve.StoreLODInAlphaChannel){const a=new Uint16Array(s),o=new Uint16Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=o[f],a[h+1]=o[f+1],a[h+2]=o[f+2],a[h+3]=ki(n),h+=4}return a}return new Uint16Array(r,i,s)}static _GetFloatRGBAArrayBuffer(e,t,i,s,r,n){if(Ve.StoreLODInAlphaChannel){const a=new Float32Array(s),o=new Float32Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=o[f],a[h+1]=o[f+1],a[h+2]=o[f+2],a[h+3]=n,h+=4}return a}return new Float32Array(r,i,s)}static _GetFloatAsHalfFloatRGBAArrayBuffer(e,t,i,s,r,n){const a=new Uint16Array(s),o=new Float32Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++)a[h]=ki(o[h]),a[h+1]=ki(o[h+1]),a[h+2]=ki(o[h+2]),Ve.StoreLODInAlphaChannel?a[h+3]=ki(n):a[h+3]=ki(o[h+3]),h+=4;return a}static _GetFloatAsUIntRGBAArrayBuffer(e,t,i,s,r,n){const a=new Uint8Array(s),o=new Float32Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=$.Clamp(o[f])*255,a[h+1]=$.Clamp(o[f+1])*255,a[h+2]=$.Clamp(o[f+2])*255,Ve.StoreLODInAlphaChannel?a[h+3]=n:a[h+3]=$.Clamp(o[f+3])*255,h+=4}return a}static _GetHalfFloatAsUIntRGBAArrayBuffer(e,t,i,s,r,n){const a=new Uint8Array(s),o=new Uint16Array(r,i);let h=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const f=(u+c*e)*4;a[h]=$.Clamp(cs(o[f]))*255,a[h+1]=$.Clamp(cs(o[f+1]))*255,a[h+2]=$.Clamp(cs(o[f+2]))*255,Ve.StoreLODInAlphaChannel?a[h+3]=n:a[h+3]=$.Clamp(cs(o[f+3]))*255,h+=4}return a}static _GetRGBAArrayBuffer(e,t,i,s,r,n,a,o,h){const c=new Uint8Array(s),u=new Uint8Array(r,i);let f=0;for(let d=0;d<t;d++)for(let _=0;_<e;_++){const p=(_+d*e)*4;c[f]=u[p+n],c[f+1]=u[p+a],c[f+2]=u[p+o],c[f+3]=u[p+h],f+=4}return c}static _ExtractLongWordOrder(e){return e===0||e===255||e===-16777216?0:1+Ve._ExtractLongWordOrder(e>>8)}static _GetRGBArrayBuffer(e,t,i,s,r,n,a,o){const h=new Uint8Array(s),c=new Uint8Array(r,i);let u=0;for(let f=0;f<t;f++)for(let d=0;d<e;d++){const _=(d+f*e)*3;h[u]=c[_+n],h[u+1]=c[_+a],h[u+2]=c[_+o],u+=3}return h}static _GetLuminanceArrayBuffer(e,t,i,s,r){const n=new Uint8Array(s),a=new Uint8Array(r,i);let o=0;for(let h=0;h<t;h++)for(let c=0;c<e;c++){const u=c+h*e;n[o]=a[u],o++}return n}static UploadDDSLevels(e,t,i,s,r,n,a=-1,o,h=!0){let c=null;s.sphericalPolynomial&&(c=new Array);const u=!!e.getCaps().s3tc;t.generateMipMaps=r;const f=new Int32Array(i.buffer,i.byteOffset,Ba);let d,_,p,m=0,T,S,x,b,I=0,R=1;if(f[LE]!==PE){F.Error("Invalid magic number in DDS header");return}if(!s.isFourCC&&!s.isRGB&&!s.isLuminance){F.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");return}if(s.isCompressed&&!u){F.Error("Compressed textures are not supported on this platform.");return}let C=f[FE];T=f[NE]+4;let y=!1;if(s.isFourCC)switch(d=f[ql],d){case Vl:R=8,I=33777;break;case kl:R=16,I=33778;break;case Gl:R=16,I=33779;break;case Hl:y=!0,C=64;break;case Wl:y=!0,C=128;break;case wa:{T+=5*4;let ve=!1;switch(s.dxgiFormat){case Xl:y=!0,C=64,ve=!0;break;case zl:y=!0,C=128,ve=!0;break;case DE:s.isRGB=!0,s.isFourCC=!1,C=32,ve=!0;break}if(ve)break}default:console.error("Unsupported FourCC code:",OE(d));return}const w=Ve._ExtractLongWordOrder(f[wE]),G=Ve._ExtractLongWordOrder(f[BE]),te=Ve._ExtractLongWordOrder(f[UE]),Q=Ve._ExtractLongWordOrder(f[VE]);y&&(I=e._getRGBABufferInternalSizedFormat(s.textureType)),x=1,f[Yl]&Nl&&r!==!1&&(x=Math.max(1,f[jl]));const Te=o||0,he=e.getCaps();for(let ve=Te;ve<n;ve++){for(_=f[Ua],p=f[Kl],b=0;b<x;++b){if(a===-1||a===b){const le=a===-1?b:0;if(!s.isCompressed&&s.isFourCC){t.format=5,m=_*p*4;let be=null;if(e._badOS||e._badDesktopOS||!he.textureHalfFloat&&!he.textureFloat)C===128?(be=Ve._GetFloatAsUIntRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le),c&&le==0&&c.push(Ve._GetFloatRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le))):C===64&&(be=Ve._GetHalfFloatAsUIntRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le),c&&le==0&&c.push(Ve._GetHalfFloatAsFloatRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,le))),t.type=0;else{const ye=he.textureFloat&&(h&&he.textureFloatLinearFiltering||!h),Ye=he.textureHalfFloat&&(h&&he.textureHalfFloatLinearFiltering||!h),et=(C===128||C===64&&!Ye)&&ye?1:(C===64||C===128&&!ye)&&Ye?2:0;let Ne,pt=null;switch(C){case 128:{switch(et){case 1:Ne=Ve._GetFloatRGBAArrayBuffer,pt=null;break;case 2:Ne=Ve._GetFloatAsHalfFloatRGBAArrayBuffer,pt=Ve._GetFloatRGBAArrayBuffer;break;case 0:Ne=Ve._GetFloatAsUIntRGBAArrayBuffer,pt=Ve._GetFloatRGBAArrayBuffer;break}break}default:{switch(et){case 1:Ne=Ve._GetHalfFloatAsFloatRGBAArrayBuffer,pt=null;break;case 2:Ne=Ve._GetHalfFloatRGBAArrayBuffer,pt=Ve._GetHalfFloatAsFloatRGBAArrayBuffer;break;case 0:Ne=Ve._GetHalfFloatAsUIntRGBAArrayBuffer,pt=Ve._GetHalfFloatAsFloatRGBAArrayBuffer;break}break}}t.type=et,be=Ne(_,p,i.byteOffset+T,m,i.buffer,le),c&&le==0&&c.push(pt?pt(_,p,i.byteOffset+T,m,i.buffer,le):be)}be&&e._uploadDataToTextureDirectly(t,be,ve,le)}else if(s.isRGB)t.type=0,C===24?(t.format=4,m=_*p*3,S=Ve._GetRGBArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,w,G,te),e._uploadDataToTextureDirectly(t,S,ve,le)):(t.format=5,m=_*p*4,S=Ve._GetRGBAArrayBuffer(_,p,i.byteOffset+T,m,i.buffer,w,G,te,Q),e._uploadDataToTextureDirectly(t,S,ve,le));else if(s.isLuminance){const be=e._getUnpackAlignement(),ye=_;m=Math.floor((_+be-1)/be)*be*(p-1)+ye,S=Ve._GetLuminanceArrayBuffer(_,p,i.byteOffset+T,m,i.buffer),t.format=1,t.type=0,e._uploadDataToTextureDirectly(t,S,ve,le)}else m=Math.max(4,_)/4*Math.max(4,p)/4*R,S=new Uint8Array(i.buffer,i.byteOffset+T,m),t.type=0,e._uploadCompressedDataToTextureDirectly(t,I,_,p,S,ve,le)}T+=C?_*p*(C/8):m,_*=.5,p*=.5,_=Math.max(1,_),p=Math.max(1,p)}if(o!==void 0)break}c&&c.length>0?s.sphericalPolynomial=Js.ConvertCubeMapToSphericalPolynomial({size:f[Ua],right:c[0],left:c[1],up:c[2],down:c[3],front:c[4],back:c[5],format:5,type:1,gammaSpace:!1}):s.sphericalPolynomial=void 0}}Ve.StoreLODInAlphaChannel=!1,re.prototype.createPrefilteredCubeTexture=function(l,e,t,i,s=null,r=null,n,a=null,o=!0){const h=c=>{if(!c){s&&s(null);return}const u=c.texture;if(o?c.info.sphericalPolynomial&&(u._sphericalPolynomial=c.info.sphericalPolynomial):u._sphericalPolynomial=new us,u._source=Fe.CubePrefiltered,this.getCaps().textureLOD){s&&s(u);return}const f=3,d=this._gl,_=c.width;if(!_)return;const p=[];for(let m=0;m<f;m++){const S=1-m/(f-1),x=i,b=$.Log2(_)*t+i,I=x+(b-x)*S,R=Math.round(Math.min(Math.max(I,0),b)),C=new ht(this,Fe.Temp);if(C.type=u.type,C.format=u.format,C.width=Math.pow(2,Math.max($.Log2(_)-R,0)),C.height=C.width,C.isCube=!0,C._cachedWrapU=0,C._cachedWrapV=0,this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,C,!0),C.samplingMode=2,d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),c.isDDS){const w=c.info,G=c.data;this._unpackFlipY(w.isCompressed),Ve.UploadDDSLevels(this,C,G,w,!0,6,R)}else F.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null);const y=new Ge(e);y._isCube=!0,y._texture=C,C.isReady=!0,p.push(y)}u._lodTextureHigh=p[2],u._lodTextureMid=p[1],u._lodTextureLow=p[0],s&&s(u)};return this.createCubeTexture(l,e,null,!1,h,r,n,a,o,t,i)};class HE{constructor(){this.supportCascades=!0}canLoad(e){return e.endsWith(".dds")}loadCubeData(e,t,i,s){const r=t.getEngine();let n,a=!1,o=1e3;if(Array.isArray(e))for(let h=0;h<e.length;h++){const c=e[h];n=Ve.GetDDSInfo(c),t.width=n.width,t.height=n.height,a=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps,r._unpackFlipY(n.isCompressed),Ve.UploadDDSLevels(r,t,c,n,a,6,-1,h),!n.isFourCC&&n.mipmapCount===1?r.generateMipMapsForCubemap(t):o=n.mipmapCount-1}else{const h=e;n=Ve.GetDDSInfo(h),t.width=n.width,t.height=n.height,i&&(n.sphericalPolynomial=new us),a=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps,r._unpackFlipY(n.isCompressed),Ve.UploadDDSLevels(r,t,h,n,a,6),!n.isFourCC&&n.mipmapCount===1?r.generateMipMapsForCubemap(t,!1):o=n.mipmapCount-1}r._setCubeMapTextureParams(t,a,o),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s({isDDS:!0,width:t.width,info:n,data:e,texture:t})}loadData(e,t,i){const s=Ve.GetDDSInfo(e),r=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&t.generateMipMaps&&s.width>>s.mipmapCount-1===1;i(s.width,s.height,r,s.isFourCC,()=>{Ve.UploadDDSLevels(t.getEngine(),t,e,s,r,1)})}}L._TextureLoaders.push(new HE);class WE{constructor(){this.supportCascades=!1}canLoad(e){return e.endsWith(".env")}loadCubeData(e,t,i,s,r){if(Array.isArray(e))return;const n=Op(e);if(n){t.width=n.width,t.height=n.width;try{Np(t,n),Lp(t,e,n).then(()=>{t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s()},a=>{r==null||r("Can not upload environment levels",a)})}catch(a){r==null||r("Can not upload environment file",a)}}else r&&r("Can not parse the environment file",null)}loadData(){throw".env not supported in 2d."}}L._TextureLoaders.push(new WE);class oi{constructor(e,t){if(this.data=e,this.isInvalid=!1,!oi.IsValid(e)){this.isInvalid=!0,F.Error("texture missing KTX identifier");return}const i=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.data.buffer,this.data.byteOffset+12,13*i),n=s.getUint32(0,!0)===67305985;if(this.glType=s.getUint32(1*i,n),this.glTypeSize=s.getUint32(2*i,n),this.glFormat=s.getUint32(3*i,n),this.glInternalFormat=s.getUint32(4*i,n),this.glBaseInternalFormat=s.getUint32(5*i,n),this.pixelWidth=s.getUint32(6*i,n),this.pixelHeight=s.getUint32(7*i,n),this.pixelDepth=s.getUint32(8*i,n),this.numberOfArrayElements=s.getUint32(9*i,n),this.numberOfFaces=s.getUint32(10*i,n),this.numberOfMipmapLevels=s.getUint32(11*i,n),this.bytesOfKeyValueData=s.getUint32(12*i,n),this.glType!==0){F.Error("only compressed formats currently supported"),this.isInvalid=!0;return}else this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels);if(this.pixelHeight===0||this.pixelDepth!==0){F.Error("only 2D textures currently supported"),this.isInvalid=!0;return}if(this.numberOfArrayElements!==0){F.Error("texture arrays not currently supported"),this.isInvalid=!0;return}if(this.numberOfFaces!==t){F.Error("number of faces expected"+t+", but found "+this.numberOfFaces),this.isInvalid=!0;return}this.loadType=oi.COMPRESSED_2D}uploadLevels(e,t){switch(this.loadType){case oi.COMPRESSED_2D:this._upload2DCompressedLevels(e,t);break}}_upload2DCompressedLevels(e,t){let i=oi.HEADER_LEN+this.bytesOfKeyValueData,s=this.pixelWidth,r=this.pixelHeight;const n=t?this.numberOfMipmapLevels:1;for(let a=0;a<n;a++){const o=new Int32Array(this.data.buffer,this.data.byteOffset+i,1)[0];i+=4;for(let h=0;h<this.numberOfFaces;h++){const c=new Uint8Array(this.data.buffer,this.data.byteOffset+i,o);e.getEngine()._uploadCompressedDataToTextureDirectly(e,e.format,s,r,c,h,a),i+=o,i+=3-(o+3)%4}s=Math.max(1,s*.5),r=Math.max(1,r*.5)}}static IsValid(e){if(e.byteLength>=12){const t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===49&&t[6]===49&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}}oi.HEADER_LEN=12+13*4,oi.COMPRESSED_2D=0,oi.COMPRESSED_3D=1,oi.TEX_2D=2,oi.TEX_3D=3;var Zl;(function(l){l[l.ETC1S=0]="ETC1S",l[l.UASTC4x4=1]="UASTC4x4"})(Zl||(Zl={}));var zr;(function(l){l[l.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",l[l.BC7_RGBA=1]="BC7_RGBA",l[l.BC3_RGBA=2]="BC3_RGBA",l[l.BC1_RGB=3]="BC1_RGB",l[l.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",l[l.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",l[l.ETC2_RGBA=6]="ETC2_RGBA",l[l.ETC1_RGB=7]="ETC1_RGB",l[l.RGBA32=8]="RGBA32",l[l.R8=9]="R8",l[l.RG8=10]="RG8"})(zr||(zr={}));var ka;(function(l){l[l.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",l[l.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",l[l.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",l[l.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",l[l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",l[l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",l[l.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",l[l.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",l[l.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",l[l.RGBA8Format=32856]="RGBA8Format",l[l.R8Format=33321]="R8Format",l[l.RG8Format=33323]="RG8Format"})(ka||(ka={}));function ji(l){return l?k.GetAbsoluteUrl(l):null}function Ga(l){l.wasmUASTCToASTC!==null&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=l.wasmUASTCToASTC),l.wasmUASTCToBC7!==null&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=l.wasmUASTCToBC7),l.wasmUASTCToRGBA_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=l.wasmUASTCToRGBA_UNORM),l.wasmUASTCToRGBA_SRGB!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=l.wasmUASTCToRGBA_SRGB),l.wasmUASTCToR8_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=l.wasmUASTCToR8_UNORM),l.wasmUASTCToRG8_UNORM!==null&&(KTX2DECODER.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=l.wasmUASTCToRG8_UNORM),l.jsMSCTranscoder!==null&&(KTX2DECODER.MSCTranscoder.JSModuleURL=l.jsMSCTranscoder),l.wasmMSCTranscoder!==null&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=l.wasmMSCTranscoder),l.wasmZSTDDecoder!==null&&(KTX2DECODER.ZSTDDecoder.WasmModuleURL=l.wasmZSTDDecoder)}class zE{constructor(){this._isDirty=!0,this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=!0,this._ktx2DecoderOptions={}}get isDirty(){return this._isDirty}get useRGBAIfASTCBC7NotAvailableWhenUASTC(){return this._useRGBAIfASTCBC7NotAvailableWhenUASTC}set useRGBAIfASTCBC7NotAvailableWhenUASTC(e){this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==e&&(this._useRGBAIfASTCBC7NotAvailableWhenUASTC=e,this._isDirty=!0)}get useRGBAIfOnlyBC1BC3AvailableWhenUASTC(){return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC}set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(e){this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC!==e&&(this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=e,this._isDirty=!0)}get forceRGBA(){return this._forceRGBA}set forceRGBA(e){this._forceRGBA!==e&&(this._forceRGBA=e,this._isDirty=!0)}get forceR8(){return this._forceR8}set forceR8(e){this._forceR8!==e&&(this._forceR8=e,this._isDirty=!0)}get forceRG8(){return this._forceRG8}set forceRG8(e){this._forceRG8!==e&&(this._forceRG8=e,this._isDirty=!0)}get bypassTranscoders(){return this._bypassTranscoders}set bypassTranscoders(e){this._bypassTranscoders!==e&&(this._bypassTranscoders=e,this._isDirty=!0)}_getKTX2DecoderOptions(){if(!this._isDirty)return this._ktx2DecoderOptions;this._isDirty=!1;const e={useRGBAIfASTCBC7NotAvailableWhenUASTC:this._useRGBAIfASTCBC7NotAvailableWhenUASTC,forceRGBA:this._forceRGBA,forceR8:this._forceR8,forceRG8:this._forceRG8,bypassTranscoders:this._bypassTranscoders};return this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC&&(e.transcodeFormatDecisionTree={UASTC:{transcodeFormat:[zr.BC1_RGB,zr.BC3_RGBA],yes:{transcodeFormat:zr.RGBA32,engineFormat:ka.RGBA8Format,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=e,e}}class Tt{static GetDefaultNumWorkers(){return typeof navigator!="object"||!navigator.hardwareConcurrency?1:Math.min(Math.floor(navigator.hardwareConcurrency*.5),4)}static _Initialize(e){if(Tt._WorkerPoolPromise||Tt._DecoderModulePromise)return;const t={jsDecoderModule:k.GetAbsoluteUrl(this.URLConfig.jsDecoderModule),wasmUASTCToASTC:ji(this.URLConfig.wasmUASTCToASTC),wasmUASTCToBC7:ji(this.URLConfig.wasmUASTCToBC7),wasmUASTCToRGBA_UNORM:ji(this.URLConfig.wasmUASTCToRGBA_UNORM),wasmUASTCToRGBA_SRGB:ji(this.URLConfig.wasmUASTCToRGBA_SRGB),wasmUASTCToR8_UNORM:ji(this.URLConfig.wasmUASTCToR8_UNORM),wasmUASTCToRG8_UNORM:ji(this.URLConfig.wasmUASTCToRG8_UNORM),jsMSCTranscoder:ji(this.URLConfig.jsMSCTranscoder),wasmMSCTranscoder:ji(this.URLConfig.wasmMSCTranscoder),wasmZSTDDecoder:ji(this.URLConfig.wasmZSTDDecoder)};e&&typeof Worker=="function"&&typeof URL<"u"?Tt._WorkerPoolPromise=new Promise(i=>{const s=`${Ga}(${XE})()`,r=URL.createObjectURL(new Blob([s],{type:"application/javascript"}));i(new yr(e,()=>new Promise((n,a)=>{const o=new Worker(r),h=u=>{o.removeEventListener("error",h),o.removeEventListener("message",c),a(u)},c=u=>{u.data.action==="init"&&(o.removeEventListener("error",h),o.removeEventListener("message",c),n(o))};o.addEventListener("error",h),o.addEventListener("message",c),o.postMessage({action:"init",urls:t})})))}):typeof KTX2DECODER>"u"?Tt._DecoderModulePromise=k.LoadScriptAsync(t.jsDecoderModule).then(()=>(KTX2DECODER.MSCTranscoder.UseFromWorkerThread=!1,KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,Ga(t),new KTX2DECODER.KTX2Decoder)):(KTX2DECODER.MSCTranscoder.UseFromWorkerThread=!1,KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,Tt._DecoderModulePromise=Promise.resolve(new KTX2DECODER.KTX2Decoder))}constructor(e,t=Tt.DefaultNumWorkers){this._engine=e,Tt._Initialize(t)}uploadAsync(e,t,i){const s=this._engine.getCaps(),r={astc:!!s.astc,bptc:!!s.bptc,s3tc:!!s.s3tc,pvrtc:!!s.pvrtc,etc2:!!s.etc2,etc1:!!s.etc1};if(Tt._WorkerPoolPromise)return Tt._WorkerPoolPromise.then(n=>new Promise((a,o)=>{n.push((h,c)=>{const u=_=>{h.removeEventListener("error",u),h.removeEventListener("message",f),o(_),c()},f=_=>{if(_.data.action==="decoded"){if(h.removeEventListener("error",u),h.removeEventListener("message",f),!_.data.success)o({message:_.data.msg});else try{this._createTexture(_.data.decodedData,t,i),a()}catch(p){o({message:p})}c()}};h.addEventListener("error",u),h.addEventListener("message",f),h.postMessage({action:"setDefaultDecoderOptions",options:Tt.DefaultDecoderOptions._getKTX2DecoderOptions()});const d=new Uint8Array(e.byteLength);d.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),h.postMessage({action:"decode",data:d,caps:r,options:i},[d.buffer])})}));if(Tt._DecoderModulePromise)return Tt._DecoderModulePromise.then(n=>(Tt.DefaultDecoderOptions.isDirty&&(KTX2DECODER.KTX2Decoder.DefaultDecoderOptions=Tt.DefaultDecoderOptions._getKTX2DecoderOptions()),new Promise((a,o)=>{n.decode(e,s).then(h=>{this._createTexture(h,t),a()}).catch(h=>{o({message:h})})})));throw new Error("KTX2 decoder module is not available")}_createTexture(e,t,i){this._engine._bindTextureDirectly(3553,t),i&&(i.transcodedFormat=e.transcodedFormat,i.isInGammaSpace=e.isInGammaSpace,i.hasAlpha=e.hasAlpha,i.transcoderName=e.transcoderName);let r=!0;switch(e.transcodedFormat){case 32856:t.type=0,t.format=5;break;case 33321:t.type=0,t.format=6;break;case 33323:t.type=0,t.format=7;break;default:t.format=e.transcodedFormat,r=!1;break}if(t._gammaSpace=e.isInGammaSpace,t.generateMipMaps=e.mipmaps.length>1,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(let n=0;n<e.mipmaps.length;++n){const a=e.mipmaps[n];if(!a||!a.data)throw new Error("KTX2 container - could not transcode one of the image");r?(t.width=a.width,t.height=a.height,this._engine._uploadDataToTextureDirectly(t,a.data,0,n,void 0,!0)):this._engine._uploadCompressedDataToTextureDirectly(t,e.transcodedFormat,a.width,a.height,a.data,0,n)}t._extension=".ktx2",t.width=e.mipmaps[0].width,t.height=e.mipmaps[0].height,t.isReady=!0,this._engine._bindTextureDirectly(3553,null)}static IsValid(e){if(e.byteLength>=12){const t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===50&&t[6]===48&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}}Tt.URLConfig={jsDecoderModule:"https://preview.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null},Tt.DefaultNumWorkers=Tt.GetDefaultNumWorkers(),Tt.DefaultDecoderOptions=new zE;function XE(){let l;onmessage=e=>{if(e.data)switch(e.data.action){case"init":{const t=e.data.urls;importScripts(t.jsDecoderModule),Ga(t),l=new KTX2DECODER.KTX2Decoder,postMessage({action:"init"});break}case"setDefaultDecoderOptions":{KTX2DECODER.KTX2Decoder.DefaultDecoderOptions=e.data.options;break}case"decode":l.decode(e.data.data,e.data.caps,e.data.options).then(t=>{const i=[];for(let s=0;s<t.mipmaps.length;++s){const r=t.mipmaps[s];r&&r.data&&i.push(r.data.buffer)}postMessage({action:"decoded",success:!0,decodedData:t},i)}).catch(t=>{postMessage({action:"decoded",success:!1,msg:t})});break}}}function YE(l){switch(l){case 35916:return 33776;case 35918:return 33778;case 35919:return 33779;case 37493:return 37492;case 37497:return 37496;case 37495:return 37494;case 37840:return 37808;case 36493:return 36492}return null}class KE{constructor(){this.supportCascades=!1}canLoad(e,t){return e.endsWith(".ktx")||e.endsWith(".ktx2")||t==="image/ktx"||t==="image/ktx2"}loadCubeData(e,t,i,s){if(Array.isArray(e))return;t._invertVScale=!t.invertY;const r=t.getEngine(),n=new oi(e,6),a=n.numberOfMipmapLevels>1&&t.generateMipMaps;r._unpackFlipY(!0),n.uploadLevels(t,t.generateMipMaps),t.width=n.pixelWidth,t.height=n.pixelHeight,r._setCubeMapTextureParams(t,a,n.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),s&&s()}loadData(e,t,i,s){if(oi.IsValid(e)){t._invertVScale=!t.invertY;const r=new oi(e,1),n=YE(r.glInternalFormat);n?(t.format=n,t._useSRGBBuffer=t.getEngine()._getUseSRGBBuffer(!0,t.generateMipMaps),t._gammaSpace=!0):t.format=r.glInternalFormat,i(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,()=>{r.uploadLevels(t,t.generateMipMaps)},r.isInvalid)}else Tt.IsValid(e)?new Tt(t.getEngine()).uploadAsync(e,t,s).then(()=>{i(t.width,t.height,t.generateMipMaps,!0,()=>{},!1)},n=>{F.Warn(`Failed to load KTX2 texture data: ${n.message}`),i(0,0,!1,!1,()=>{},!0)}):(F.Error("texture missing KTX identifier"),i(0,0,!1,!1,()=>{},!0))}}L._TextureLoaders.unshift(new KE);let ps=null;function Ql(l,e,t,i,s="image/png",r=!1,n){const{height:a,width:o}=$l(l,e,t);if(!(a&&o)){F.Error("Invalid 'size' parameter !");return}ps||(ps=document.createElement("canvas")),ps.width=o,ps.height=a;const h=ps.getContext("2d"),c=l.getRenderWidth()/l.getRenderHeight();let u=o,f=u/c;f>a&&(f=a,u=f*c);const d=Math.max(0,o-u)/2,_=Math.max(0,a-f)/2;e.getScene().activeCamera!==e?Ha(l,e,t,m=>{if(r){const T=new Blob([m]);k.DownloadBlob(T),i&&i("")}else i&&i(m)},s,1,l.getCreationOptions().antialias,void 0,void 0,void 0,void 0,n):l.onEndFrameObservable.addOnce(()=>{const m=l.getRenderingCanvas();h&&m&&h.drawImage(m,d,_,u,f),ps&&(r?(k.EncodeScreenshotCanvasData(ps,void 0,s,void 0,n),i&&i("")):k.EncodeScreenshotCanvasData(ps,i,s,void 0,n))})}function jE(l,e,t,i="image/png",s){return new Promise((r,n)=>{Ql(l,e,t,a=>{typeof a<"u"?r(a):n(new Error("Data is undefined"))},i,void 0,s)})}function Ha(l,e,t,i,s="image/png",r=1,n=!1,a,o=!1,h=!1,c=!0,u){const{height:f,width:d,finalWidth:_,finalHeight:p}=$l(l,e,t),m={width:d,height:f};if(!(f&&d)){F.Error("Invalid 'size' parameter !");return}const T={width:l.getRenderWidth(),height:l.getRenderHeight()};l.setSize(d,f);const S=e.getScene(),x=new Dt("screenShot",m,S,!1,!1,0,!1,O.BILINEAR_SAMPLINGMODE,void 0,h,void 0,void 0,void 0,r);x.renderList=S.meshes.slice(),x.samples=r,x.renderSprites=o,x.activeCamera=e,x.forceLayerMaskCheck=c;const b=()=>{l.onEndFrameObservable.addOnce(()=>{_===d&&p===f?x.readPixels(void 0,void 0,void 0,!1).then(I=>{Ot.DumpData(d,f,I,i,s,a,!0,void 0,u),x.dispose()}):il("pass",x.getInternalTexture(),S,void 0,void 0,void 0,_,p).then(I=>{l._readTexturePixels(I,_,p,-1,0,null,!0,!1,0,0).then(R=>{Ot.DumpData(_,p,R,i,s,a,!0,void 0,u),I.dispose()})})}),S.incrementRenderId(),S.resetCachedMaterial(),x.render(!0),S.incrementRenderId(),S.resetCachedMaterial(),l.setSize(T.width,T.height),e.getProjectionMatrix(!0),S.render()};if(n){const I=new or("antialiasing",1,S.activeCamera);x.addPostProcess(I),I.getEffect().isReady()?b():I.getEffect().onCompiled=()=>{b()}}else b()}function qE(l,e,t,i="image/png",s=1,r=!1,n,a=!1,o=!1,h=!0,c){return new Promise((u,f)=>{Ha(l,e,t,d=>{typeof d<"u"?u(d):f(new Error("Data is undefined"))},i,s,r,n,a,o,h,c)})}function $l(l,e,t){let i=0,s=0,r=0,n=0;if(typeof t=="object"){const a=t.precision?Math.abs(t.precision):1;t.width&&t.height?(i=t.height*a,s=t.width*a):t.width&&!t.height?(s=t.width*a,i=Math.round(s/l.getAspectRatio(e))):t.height&&!t.width?(i=t.height*a,s=Math.round(i*l.getAspectRatio(e))):(s=Math.round(l.getRenderWidth()*a),i=Math.round(s/l.getAspectRatio(e))),t.finalWidth&&t.finalHeight?(n=t.finalHeight,r=t.finalWidth):t.finalWidth&&!t.finalHeight?(r=t.finalWidth,n=Math.round(r/l.getAspectRatio(e))):t.finalHeight&&!t.finalWidth?(n=t.finalHeight,r=Math.round(n*l.getAspectRatio(e))):(r=s,n=i)}else isNaN(t)||(i=t,s=t,r=t,n=t);return s&&(s=Math.floor(s)),i&&(i=Math.floor(i)),r&&(r=Math.floor(r)),n&&(n=Math.floor(n)),{height:i|0,width:s|0,finalWidth:r|0,finalHeight:n|0}}(()=>{k.CreateScreenshot=Ql,k.CreateScreenshotAsync=jE,k.CreateScreenshotUsingRenderTarget=Ha,k.CreateScreenshotUsingRenderTargetAsync=qE})();function Wa(l){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=l.width||l.size||1,a=l.height||l.size||1,o=l.depth||l.size||1,h=l.wrap||!1;let c=l.topBaseAt===void 0?1:l.topBaseAt,u=l.bottomBaseAt===void 0?0:l.bottomBaseAt;c=(c+4)%4,u=(u+4)%4;const f=[2,0,3,1],d=[2,0,1,3];let _=f[c],p=d[u],m=[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],m=[-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 C=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],y=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const w=[17,18,19,16],G=[22,23,20,21];for(;_>0;)C.unshift(C.pop()),w.unshift(w.pop()),_--;for(;p>0;)y.unshift(y.pop()),G.unshift(G.pop()),p--;C=C.flat(),y=y.flat(),m=m.concat(C).concat(y),t.push(w[0],w[2],w[3],w[0],w[1],w[2]),t.push(G[0],G[2],G[3],G[0],G[1],G[2])}const T=[n/2,a/2,o/2];r=m.reduce((C,y,w)=>C.concat(y*T[w%3]),[]);const S=l.sideOrientation===0?0:l.sideOrientation||me.DEFAULTSIDE,x=l.faceUV||new Array(6),b=l.faceColors,I=[];for(let C=0;C<6;C++)x[C]===void 0&&(x[C]=new He(0,0,1,1)),b&&b[C]===void 0&&(b[C]=new ge(1,1,1,1));for(let C=0;C<6;C++)if(s.push(x[C].z,si.UseOpenGLOrientationForUV?1-x[C].w:x[C].w),s.push(x[C].x,si.UseOpenGLOrientationForUV?1-x[C].w:x[C].w),s.push(x[C].x,si.UseOpenGLOrientationForUV?1-x[C].y:x[C].y),s.push(x[C].z,si.UseOpenGLOrientationForUV?1-x[C].y:x[C].y),b)for(let y=0;y<4;y++)I.push(b[C].r,b[C].g,b[C].b,b[C].a);me._ComputeSides(S,r,t,i,s,l.frontUVs,l.backUVs);const R=new me;if(R.indices=t,R.positions=r,R.normals=i,R.uvs=s,b){const C=S===me.DOUBLESIDE?I.concat(I):I;R.colors=C}return R}function ZE(l,e={},t=null){const i=new ne(l,t);return e.sideOrientation=ne._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Wa(e).applyToMesh(i,e.updatable),i}me.CreateBox=Wa,ne.CreateBox=(l,e,t=null,i,s)=>ZE(l,{size:e,sideOrientation:s,updatable:i},t);const QE="boundingBoxRendererFragmentDeclaration",$E=`uniform vec4 color;
9966
+ `;U.IncludesShadersStore[QE]=$E;const JE="boundingBoxRendererUboDeclaration",eT=`#ifdef WEBGL2
9967
9967
  uniform vec4 color;
9968
9968
  uniform mat4 world;
9969
9969
  uniform mat4 viewProjection;
@@ -9979,18 +9979,18 @@ mat4 viewProjection;
9979
9979
  mat4 viewProjectionR;
9980
9980
  };
9981
9981
  #endif
9982
- `;U.IncludesShadersStore[$E]=JE;const eT="boundingBoxRendererPixelShader",tT=`#include<__decl__boundingBoxRendererFragment>
9982
+ `;U.IncludesShadersStore[JE]=eT;const tT="boundingBoxRendererPixelShader",iT=`#include<__decl__boundingBoxRendererFragment>
9983
9983
  #define CUSTOM_FRAGMENT_DEFINITIONS
9984
9984
  void main(void) {
9985
9985
  #define CUSTOM_FRAGMENT_MAIN_BEGIN
9986
9986
  gl_FragColor=color;
9987
9987
  #define CUSTOM_FRAGMENT_MAIN_END
9988
- }`;U.ShadersStore[eT]=tT;const iT="boundingBoxRendererVertexDeclaration",sT=`uniform mat4 world;
9988
+ }`;U.ShadersStore[tT]=iT;const sT="boundingBoxRendererVertexDeclaration",rT=`uniform mat4 world;
9989
9989
  uniform mat4 viewProjection;
9990
9990
  #ifdef MULTIVIEW
9991
9991
  uniform mat4 viewProjectionR;
9992
9992
  #endif
9993
- `;U.IncludesShadersStore[iT]=sT;const rT="boundingBoxRendererVertexShader",nT=`attribute vec3 position;
9993
+ `;U.IncludesShadersStore[sT]=rT;const nT="boundingBoxRendererVertexShader",aT=`attribute vec3 position;
9994
9994
  #include<__decl__boundingBoxRendererVertex>
9995
9995
  #define CUSTOM_VERTEX_DEFINITIONS
9996
9996
  void main(void) {
@@ -10007,4 +10007,4 @@ gl_Position=viewProjection*worldPos;
10007
10007
  #endif
10008
10008
  #define CUSTOM_VERTEX_MAIN_END
10009
10009
  }
10010
- `;U.ShadersStore[rT]=nT,Object.defineProperty(Ie.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(l){this._forceShowBoundingBoxes=l,l&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),Ie.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new aT(this)),this._boundingBoxRenderer},Object.defineProperty(Vt.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(l){this._showBoundingBox=l,l&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});class aT{constructor(e){this.name=ee.NAME_BOUNDINGBOXRENDERER,this.frontColor=new z(1,1,1),this.backColor=new z(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new B,this.onAfterBoxRenderingObservable=new B,this.onResourcesReadyObservable=new B,this.enabled=!0,this.renderList=new vt(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=e,e._addComponent(this),this._uniformBufferFront=new q(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront",!this.scene.getEngine().isWebGPU),this._buildUniformLayout(this._uniformBufferFront),this._uniformBufferBack=new q(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack",!this.scene.getEngine().isWebGPU),this._buildUniformLayout(this._uniformBufferBack)}_buildUniformLayout(e){e.addUniform("color",4),e.addUniform("world",16),e.addUniform("viewProjection",16),e.addUniform("viewProjectionR",16),e.create()}register(){this.scene._beforeEvaluateActiveMeshStage.registerStep(ee.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(ee.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(ee.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(ee.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)}_evaluateSubMesh(e,t){if(e.showSubMeshesBoundingBox){const i=t.getBoundingInfo();i!=null&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}}_preActiveMesh(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){const t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}}_prepareResources(){if(this._colorShader)return;this._colorShader=new vi("colorShader",this.scene,"boundingBoxRenderer",{attributes:[A.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"]},!1),this._colorShader.doNotSerialize=!0,this._colorShader.reservedDataStore={hidden:!0},this._colorShaderForOcclusionQuery=new vi("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{attributes:[A.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"]},!0),this._colorShaderForOcclusionQuery.doNotSerialize=!0,this._colorShaderForOcclusionQuery.reservedDataStore={hidden:!0};const e=this.scene.getEngine(),t=Wa({size:1});this._vertexBuffers[A.PositionKind]=new A(e,t.positions,A.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}_createIndexBuffer(){const e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}rebuild(){const e=this._vertexBuffers[A.PositionKind];e&&e._rebuild(),this._createIndexBuffer()}reset(){this.renderList.reset()}render(e){var t,i;if(this.renderList.length===0||!this.enabled||(this._prepareResources(),!this._colorShader.isReady()))return;const s=this.scene.getEngine();s.setDepthWrite(!1);const r=this.scene.getTransformMatrix();for(let n=0;n<this.renderList.length;n++){const a=this.renderList.data[n];if(a._tag!==e)continue;this._createWrappersForBoundingBox(a),this.onBeforeBoxRenderingObservable.notifyObservers(a);const o=a.minimum,c=a.maximum.subtract(o),u=o.add(c.scale(.5)),f=M.Scaling(c.x,c.y,c.z).multiply(M.Translation(u.x,u.y,u.z)).multiply(a.getWorldMatrix()),d=s.useReverseDepthBuffer;if(this.showBackLines){const p=(t=a._drawWrapperBack)!==null&&t!==void 0?t:this._colorShader._getDrawWrapper();this._colorShader._preBind(p),s.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),d?s.setDepthFunctionToLessOrEqual():s.setDepthFunctionToGreaterOrEqual(),this._uniformBufferBack.bindToEffect(p.effect,"BoundingBoxRenderer"),this._uniformBufferBack.updateColor4("color",this.backColor,1),this._uniformBufferBack.updateMatrix("world",f),this._uniformBufferBack.updateMatrix("viewProjection",r),this._uniformBufferBack.update(),s.drawElementsType(V.LineListDrawMode,0,24)}const _=(i=a._drawWrapperFront)!==null&&i!==void 0?i:this._colorShader._getDrawWrapper();this._colorShader._preBind(_),s.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),d?s.setDepthFunctionToGreater():s.setDepthFunctionToLess(),this._uniformBufferFront.bindToEffect(_.effect,"BoundingBoxRenderer"),this._uniformBufferFront.updateColor4("color",this.frontColor,1),this._uniformBufferFront.updateMatrix("world",f),this._uniformBufferFront.updateMatrix("viewProjection",r),this._uniformBufferFront.update(),s.drawElementsType(V.LineListDrawMode,0,24),this.onAfterBoxRenderingObservable.notifyObservers(a)}this._colorShader.unbind(),s.setDepthFunctionToLessOrEqual(),s.setDepthWrite(!0)}_createWrappersForBoundingBox(e){if(!e._drawWrapperFront){const t=this.scene.getEngine();e._drawWrapperFront=new Li(t),e._drawWrapperBack=new Li(t),e._drawWrapperFront.setEffect(this._colorShader.getEffect()),e._drawWrapperBack.setEffect(this._colorShader.getEffect())}}renderOcclusionBoundingBox(e){const t=this.scene.getEngine();this._renderPassIdForOcclusionQuery===void 0&&(this._renderPassIdForOcclusionQuery=t.createRenderPassId("Render pass for occlusion query"));const i=t.currentRenderPassId;t.currentRenderPassId=this._renderPassIdForOcclusionQuery,this._prepareResources();const s=e.subMeshes[0];if(!this._colorShaderForOcclusionQuery.isReady(e,void 0,s)||!e.hasBoundingInfo){t.currentRenderPassId=i;return}this._fillIndexBuffer||(this._fillIndexBuffer=t.createIndexBuffer(this._fillIndexData));const r=t.useReverseDepthBuffer;t.setDepthWrite(!1),t.setColorWrite(!1);const n=e.getBoundingInfo().boundingBox,a=n.minimum,h=n.maximum.subtract(a),c=a.add(h.scale(.5)),u=M.Scaling(h.x,h.y,h.z).multiply(M.Translation(c.x,c.y,c.z)).multiply(n.getWorldMatrix()),f=s._drawWrapper;this._colorShaderForOcclusionQuery._preBind(f),t.bindBuffers(this._vertexBuffers,this._fillIndexBuffer,f.effect),r?t.setDepthFunctionToGreater():t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._uniformBufferFront.bindToEffect(f.effect,"BoundingBoxRenderer"),this._uniformBufferFront.updateMatrix("world",u),this._uniformBufferFront.updateMatrix("viewProjection",this.scene.getTransformMatrix()),this._uniformBufferFront.update(),t.drawElementsType(V.TriangleFillMode,0,36),this._colorShaderForOcclusionQuery.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0),t.setColorWrite(!0),t.currentRenderPassId=i}dispose(){if(this._renderPassIdForOcclusionQuery!==void 0&&(this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery),this._renderPassIdForOcclusionQuery=void 0),!this._colorShader)return;this.onBeforeBoxRenderingObservable.clear(),this.onAfterBoxRenderingObservable.clear(),this.onResourcesReadyObservable.clear(),this.renderList.dispose(),this._colorShader.dispose(),this._colorShaderForOcclusionQuery.dispose(),this._uniformBufferFront.dispose(),this._uniformBufferBack.dispose();const e=this._vertexBuffers[A.PositionKind];e&&(e.dispose(),this._vertexBuffers[A.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer),this._fillIndexBuffer&&(this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),this._fillIndexBuffer=null)}}Z.RegisterExtension("glbPostProcessor",function(l){return new gm(l)}),Ce.OnPluginActivatedObservable.add(l=>{if(l.name==="gltf"){const e=l;e.transparencyAsCoverage=!0}});const vn="initialScene";class oT{constructor(e){this.loadProgress=new Map([[vn,0]]),this.focusLostNotified=!1,this.loadObservable=new B,this.focusLostObservable=new B,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new mm(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),s="1.5.6";Xt.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const n=i?new L(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new uc;console.log=r,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new Ie(n),this.camera=Da.create(this.scene,this.configuration),this.renderingPipeline=new yE(this.scene,!1,this.camera),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new Em(this.scene,this.configuration.emissiveGlowIntensity)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(Ji.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}getSceneInitializationProgress(){return this.loadProgress.get(vn)}async initialize(e){var i,s;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=It.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,n=>{this.loadProgress.set(vn,n.loaded*100/n.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(vn,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),Dm(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(s=this.configuration.options)!=null&&s.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const n=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,n.width,n.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}Lm(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new E(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===Ji.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,t.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=t.camera.limits.min.radius),t.camera.limits.max.radius&&(this.camera.upperRadiusLimit=t.camera.limits.max.radius),e()})})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new je("screenshotCamera",0,0,0,E.Zero(),this.scene);try{const s=t.latDeg*Math.PI/180,r=t.lonDeg*Math.PI/180;i.target=t.target?new E(t.target.x,t.target.y,t.target.z):E.Zero(),i.alpha=r,i.beta=s,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await k.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,s=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||s===void 0||r===void 0)return!0;const n=[t,i],a=[s,r],o=n.every(c=>c===t),h=a.every(c=>c===s);return!o&&!h}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var s;e.length===0&&((s=this.highlightLayer)==null||s.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Lt("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new z(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(r=>{const n=this.scene.materials.find(a=>a.name===r.name&&a.id===r.id);n&&n.getBindedMeshes().forEach(a=>{var o;return(o=this.highlightLayer)==null?void 0:o.addMesh(a,i||z.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new ng({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.registerMaterialVariantListener(s=>this.handleMaterialProgressCallback(s.remainingCount,s.totalCount,s.taskName)),i.registerModelVariantListener(s=>this.handleModelProgressCallback(s,s.key)),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(s=>{this.setHighlights([s])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(s=>s.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}handleMaterialProgressCallback(e,t,i){this.loadProgress.set(`key_${i}`,e/t*100),this.notifyLoadHandlers()}handleModelProgressCallback(e,t){this.loadProgress.set(t,e.loaded*100/e.total),this.notifyLoadHandlers()}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}getLoadListenerEvent(){const e=Array.from(this.loadProgress.values()).filter(s=>s<100),i=e.reduce((s,r)=>s+r,0)/e.length||0;return{loadValue:e.length===0?100:i,sceneInitialized:this.getSceneInitializationProgress()===100}}notifyLoadHandlers(){this.loadObservable.notifyObservers(this.getLoadListenerEvent())}}_i.MaterialEffectMode=Xr,_i.ProductCameraRig=Ji,_i.REFLECTION_PROBE_RESOLUTION=pl,_i.RenderingConfiguration=sr,_i.SpiffCommerce3DPreviewService=oT,_i.renderingPipelineDefaults=De,Object.defineProperty(_i,Symbol.toStringTag,{value:"Module"})});
10010
+ `;U.ShadersStore[nT]=aT,Object.defineProperty(Ie.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(l){this._forceShowBoundingBoxes=l,l&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),Ie.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new oT(this)),this._boundingBoxRenderer},Object.defineProperty(Vt.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(l){this._showBoundingBox=l,l&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});class oT{constructor(e){this.name=ee.NAME_BOUNDINGBOXRENDERER,this.frontColor=new z(1,1,1),this.backColor=new z(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new B,this.onAfterBoxRenderingObservable=new B,this.onResourcesReadyObservable=new B,this.enabled=!0,this.renderList=new vt(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=e,e._addComponent(this),this._uniformBufferFront=new q(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront",!this.scene.getEngine().isWebGPU),this._buildUniformLayout(this._uniformBufferFront),this._uniformBufferBack=new q(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack",!this.scene.getEngine().isWebGPU),this._buildUniformLayout(this._uniformBufferBack)}_buildUniformLayout(e){e.addUniform("color",4),e.addUniform("world",16),e.addUniform("viewProjection",16),e.addUniform("viewProjectionR",16),e.create()}register(){this.scene._beforeEvaluateActiveMeshStage.registerStep(ee.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(ee.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(ee.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(ee.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)}_evaluateSubMesh(e,t){if(e.showSubMeshesBoundingBox){const i=t.getBoundingInfo();i!=null&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}}_preActiveMesh(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){const t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}}_prepareResources(){if(this._colorShader)return;this._colorShader=new vi("colorShader",this.scene,"boundingBoxRenderer",{attributes:[A.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"]},!1),this._colorShader.doNotSerialize=!0,this._colorShader.reservedDataStore={hidden:!0},this._colorShaderForOcclusionQuery=new vi("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{attributes:[A.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"]},!0),this._colorShaderForOcclusionQuery.doNotSerialize=!0,this._colorShaderForOcclusionQuery.reservedDataStore={hidden:!0};const e=this.scene.getEngine(),t=Wa({size:1});this._vertexBuffers[A.PositionKind]=new A(e,t.positions,A.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}_createIndexBuffer(){const e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}rebuild(){const e=this._vertexBuffers[A.PositionKind];e&&e._rebuild(),this._createIndexBuffer()}reset(){this.renderList.reset()}render(e){var t,i;if(this.renderList.length===0||!this.enabled||(this._prepareResources(),!this._colorShader.isReady()))return;const s=this.scene.getEngine();s.setDepthWrite(!1);const r=this.scene.getTransformMatrix();for(let n=0;n<this.renderList.length;n++){const a=this.renderList.data[n];if(a._tag!==e)continue;this._createWrappersForBoundingBox(a),this.onBeforeBoxRenderingObservable.notifyObservers(a);const o=a.minimum,c=a.maximum.subtract(o),u=o.add(c.scale(.5)),f=M.Scaling(c.x,c.y,c.z).multiply(M.Translation(u.x,u.y,u.z)).multiply(a.getWorldMatrix()),d=s.useReverseDepthBuffer;if(this.showBackLines){const p=(t=a._drawWrapperBack)!==null&&t!==void 0?t:this._colorShader._getDrawWrapper();this._colorShader._preBind(p),s.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),d?s.setDepthFunctionToLessOrEqual():s.setDepthFunctionToGreaterOrEqual(),this._uniformBufferBack.bindToEffect(p.effect,"BoundingBoxRenderer"),this._uniformBufferBack.updateColor4("color",this.backColor,1),this._uniformBufferBack.updateMatrix("world",f),this._uniformBufferBack.updateMatrix("viewProjection",r),this._uniformBufferBack.update(),s.drawElementsType(V.LineListDrawMode,0,24)}const _=(i=a._drawWrapperFront)!==null&&i!==void 0?i:this._colorShader._getDrawWrapper();this._colorShader._preBind(_),s.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),d?s.setDepthFunctionToGreater():s.setDepthFunctionToLess(),this._uniformBufferFront.bindToEffect(_.effect,"BoundingBoxRenderer"),this._uniformBufferFront.updateColor4("color",this.frontColor,1),this._uniformBufferFront.updateMatrix("world",f),this._uniformBufferFront.updateMatrix("viewProjection",r),this._uniformBufferFront.update(),s.drawElementsType(V.LineListDrawMode,0,24),this.onAfterBoxRenderingObservable.notifyObservers(a)}this._colorShader.unbind(),s.setDepthFunctionToLessOrEqual(),s.setDepthWrite(!0)}_createWrappersForBoundingBox(e){if(!e._drawWrapperFront){const t=this.scene.getEngine();e._drawWrapperFront=new Li(t),e._drawWrapperBack=new Li(t),e._drawWrapperFront.setEffect(this._colorShader.getEffect()),e._drawWrapperBack.setEffect(this._colorShader.getEffect())}}renderOcclusionBoundingBox(e){const t=this.scene.getEngine();this._renderPassIdForOcclusionQuery===void 0&&(this._renderPassIdForOcclusionQuery=t.createRenderPassId("Render pass for occlusion query"));const i=t.currentRenderPassId;t.currentRenderPassId=this._renderPassIdForOcclusionQuery,this._prepareResources();const s=e.subMeshes[0];if(!this._colorShaderForOcclusionQuery.isReady(e,void 0,s)||!e.hasBoundingInfo){t.currentRenderPassId=i;return}this._fillIndexBuffer||(this._fillIndexBuffer=t.createIndexBuffer(this._fillIndexData));const r=t.useReverseDepthBuffer;t.setDepthWrite(!1),t.setColorWrite(!1);const n=e.getBoundingInfo().boundingBox,a=n.minimum,h=n.maximum.subtract(a),c=a.add(h.scale(.5)),u=M.Scaling(h.x,h.y,h.z).multiply(M.Translation(c.x,c.y,c.z)).multiply(n.getWorldMatrix()),f=s._drawWrapper;this._colorShaderForOcclusionQuery._preBind(f),t.bindBuffers(this._vertexBuffers,this._fillIndexBuffer,f.effect),r?t.setDepthFunctionToGreater():t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._uniformBufferFront.bindToEffect(f.effect,"BoundingBoxRenderer"),this._uniformBufferFront.updateMatrix("world",u),this._uniformBufferFront.updateMatrix("viewProjection",this.scene.getTransformMatrix()),this._uniformBufferFront.update(),t.drawElementsType(V.TriangleFillMode,0,36),this._colorShaderForOcclusionQuery.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0),t.setColorWrite(!0),t.currentRenderPassId=i}dispose(){if(this._renderPassIdForOcclusionQuery!==void 0&&(this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery),this._renderPassIdForOcclusionQuery=void 0),!this._colorShader)return;this.onBeforeBoxRenderingObservable.clear(),this.onAfterBoxRenderingObservable.clear(),this.onResourcesReadyObservable.clear(),this.renderList.dispose(),this._colorShader.dispose(),this._colorShaderForOcclusionQuery.dispose(),this._uniformBufferFront.dispose(),this._uniformBufferBack.dispose();const e=this._vertexBuffers[A.PositionKind];e&&(e.dispose(),this._vertexBuffers[A.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer),this._fillIndexBuffer&&(this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),this._fillIndexBuffer=null)}}Z.RegisterExtension("glbPostProcessor",function(l){return new gm(l)}),Ce.OnPluginActivatedObservable.add(l=>{if(l.name==="gltf"){const e=l;e.transparencyAsCoverage=!0}});const vn="initialScene";class lT{constructor(e){this.loadProgress=new Map([[vn,0]]),this.focusLostNotified=!1,this.loadObservable=new B,this.focusLostObservable=new B,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new mm(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),s="1.5.6";Xt.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const n=i?new L(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new uc;console.log=r,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new Ie(n),this.camera=Da.create(this.scene,this.configuration),this.renderingPipeline=new ME(this.scene,!1,this.camera),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new Tm(this.scene,this.configuration.emissiveGlowIntensity)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(Ji.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}getSceneInitializationProgress(){return this.loadProgress.get(vn)}async initialize(e){var i,s;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=It.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,n=>{this.loadProgress.set(vn,n.loaded*100/n.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(vn,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),Lm(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(s=this.configuration.options)!=null&&s.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const n=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,n.width,n.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}Nm(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new E(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===Ji.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,t.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=t.camera.limits.min.radius),t.camera.limits.max.radius&&(this.camera.upperRadiusLimit=t.camera.limits.max.radius),e()})})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new je("screenshotCamera",0,0,0,E.Zero(),this.scene);try{const s=t.latDeg*Math.PI/180,r=t.lonDeg*Math.PI/180;i.target=t.target?new E(t.target.x,t.target.y,t.target.z):E.Zero(),i.alpha=r,i.beta=s,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await k.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,s=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||s===void 0||r===void 0)return!0;const n=[t,i],a=[s,r],o=n.every(c=>c===t),h=a.every(c=>c===s);return!o&&!h}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var s;e.length===0&&((s=this.highlightLayer)==null||s.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Lt("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new z(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(r=>{const n=this.scene.materials.find(a=>a.name===r.name&&a.id===r.id);n&&n.getBindedMeshes().forEach(a=>{var o;return(o=this.highlightLayer)==null?void 0:o.addMesh(a,i||z.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new ag({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.registerMaterialVariantListener(s=>this.handleMaterialProgressCallback(s.remainingCount,s.totalCount,s.taskName)),i.registerModelVariantListener(s=>this.handleModelProgressCallback(s,s.key)),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(s=>{this.setHighlights([s])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(s=>s.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}handleMaterialProgressCallback(e,t,i){this.loadProgress.set(`key_${i}`,e/t*100),this.notifyLoadHandlers()}handleModelProgressCallback(e,t){this.loadProgress.set(t,e.loaded*100/e.total),this.notifyLoadHandlers()}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}getLoadListenerEvent(){const e=Array.from(this.loadProgress.values()).filter(s=>s<100),i=e.reduce((s,r)=>s+r,0)/e.length||0;return{loadValue:e.length===0?100:i,sceneInitialized:this.getSceneInitializationProgress()===100}}notifyLoadHandlers(){this.loadObservable.notifyObservers(this.getLoadListenerEvent())}}_i.MaterialEffectMode=Xr,_i.ProductCameraRig=Ji,_i.REFLECTION_PROBE_RESOLUTION=pl,_i.RenderingConfiguration=sr,_i.SpiffCommerce3DPreviewService=lT,_i.renderingPipelineDefaults=De,Object.defineProperty(_i,Symbol.toStringTag,{value:"Module"})});