@onerjs/core 8.53.5 → 8.53.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 (841) hide show
  1. package/Animations/animationGroup.d.ts +0 -1
  2. package/Animations/animationGroup.js +0 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Animations/animationGroup.pure.js +2 -0
  5. package/Animations/animationGroup.pure.js.map +1 -1
  6. package/Animations/runtimeAnimation.js +11 -0
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.pure.js +1 -1
  9. package/AudioV2/abstractAudio/abstractSound.d.ts +2 -1
  10. package/AudioV2/abstractAudio/abstractSound.js +7 -2
  11. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  12. package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +3 -1
  13. package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -1
  14. package/AudioV2/abstractAudio/staticSound.d.ts +6 -0
  15. package/AudioV2/abstractAudio/staticSound.js +17 -1
  16. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/staticSoundInstance.d.ts +4 -2
  18. package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
  19. package/AudioV2/abstractAudio/streamingSound.d.ts +6 -0
  20. package/AudioV2/abstractAudio/streamingSound.js +9 -1
  21. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  22. package/AudioV2/webAudio/webAudioStaticSound.d.ts +7 -1
  23. package/AudioV2/webAudio/webAudioStaticSound.js +56 -8
  24. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  25. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -1
  26. package/AudioV2/webAudio/webAudioStreamingSound.js +16 -4
  27. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  28. package/BakedVertexAnimation/bakedVertexAnimationManager.d.ts +2 -2
  29. package/BakedVertexAnimation/bakedVertexAnimationManager.js +151 -121
  30. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  31. package/Behaviors/Cameras/interpolatingBehavior.d.ts +17 -2
  32. package/Behaviors/Cameras/interpolatingBehavior.js +53 -23
  33. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  34. package/Bones/bone.pure.js +3 -3
  35. package/Buffers/buffer.pure.js +0 -12
  36. package/Buffers/buffer.pure.js.map +1 -1
  37. package/Cameras/Inputs/BaseCameraMouseWheelInput.js +141 -126
  38. package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
  39. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +2 -1
  40. package/Cameras/Inputs/BaseCameraPointersInput.js +290 -277
  41. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  42. package/Cameras/Inputs/arcRotateCameraGamepadInput.js +115 -102
  43. package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
  44. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.d.ts +3 -0
  45. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js +334 -273
  46. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
  47. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +273 -258
  48. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  49. package/Cameras/Inputs/arcRotateCameraPointersInput.js +237 -213
  50. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  51. package/Cameras/Inputs/flyCameraKeyboardInput.js +199 -168
  52. package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
  53. package/Cameras/Inputs/flyCameraMouseInput.js +243 -229
  54. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  55. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +311 -266
  56. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  57. package/Cameras/Inputs/followCameraMouseWheelInput.js +139 -119
  58. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  59. package/Cameras/Inputs/followCameraPointersInput.js +239 -203
  60. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  61. package/Cameras/Inputs/freeCameraGamepadInput.js +127 -114
  62. package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
  63. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +278 -244
  64. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  65. package/Cameras/Inputs/freeCameraMouseInput.js +216 -202
  66. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  67. package/Cameras/Inputs/freeCameraMouseWheelInput.js +368 -353
  68. package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
  69. package/Cameras/Inputs/freeCameraTouchInput.js +185 -172
  70. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  71. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +2 -0
  72. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +291 -246
  73. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  74. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +11 -1
  75. package/Cameras/Inputs/geospatialCameraPointersInput.js +18 -2
  76. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  77. package/Cameras/Inputs/orbitCameraPointersInput.js +112 -96
  78. package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -1
  79. package/Cameras/VR/vrExperienceHelper.d.ts +0 -2
  80. package/Cameras/VR/vrExperienceHelper.js +0 -2
  81. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  82. package/Cameras/VR/vrExperienceHelper.pure.js +5 -0
  83. package/Cameras/VR/vrExperienceHelper.pure.js.map +1 -1
  84. package/Cameras/arcRotateCamera.pure.js +1559 -1479
  85. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  86. package/Cameras/camera.pure.js +1225 -1178
  87. package/Cameras/camera.pure.js.map +1 -1
  88. package/Cameras/flyCamera.pure.js +369 -351
  89. package/Cameras/flyCamera.pure.js.map +1 -1
  90. package/Cameras/followCamera.pure.js +229 -192
  91. package/Cameras/followCamera.pure.js.map +1 -1
  92. package/Cameras/freeCamera.pure.js +373 -351
  93. package/Cameras/freeCamera.pure.js.map +1 -1
  94. package/Cameras/geospatialCamera.pure.d.ts +30 -7
  95. package/Cameras/geospatialCamera.pure.js +502 -457
  96. package/Cameras/geospatialCamera.pure.js.map +1 -1
  97. package/Cameras/geospatialCameraMovement.js +2 -2
  98. package/Cameras/geospatialCameraMovement.js.map +1 -1
  99. package/Cameras/targetCamera.pure.d.ts +7 -0
  100. package/Cameras/targetCamera.pure.js +550 -509
  101. package/Cameras/targetCamera.pure.js.map +1 -1
  102. package/Cameras/universalCamera.pure.js +98 -85
  103. package/Cameras/universalCamera.pure.js.map +1 -1
  104. package/Collisions/gpuPicker.d.ts +111 -4
  105. package/Collisions/gpuPicker.js +696 -119
  106. package/Collisions/gpuPicker.js.map +1 -1
  107. package/Compute/computeShader.pure.js +372 -355
  108. package/Compute/computeShader.pure.js.map +1 -1
  109. package/Culling/Helper/transformFeedbackBoundingHelper.pure.js +2 -2
  110. package/Decorators/nodeDecorator.d.ts +11 -1
  111. package/Decorators/nodeDecorator.js +43 -6
  112. package/Decorators/nodeDecorator.js.map +1 -1
  113. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js +8 -0
  114. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js.map +1 -1
  115. package/Engines/Native/nativeHelpers.js +15 -0
  116. package/Engines/Native/nativeHelpers.js.map +1 -1
  117. package/Engines/Native/nativeInterfaces.d.ts +7 -2
  118. package/Engines/Native/nativeInterfaces.js.map +1 -1
  119. package/Engines/Native/nativeRenderTargetWrapper.d.ts +5 -0
  120. package/Engines/Native/nativeRenderTargetWrapper.js +35 -1
  121. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  122. package/Engines/Processors/shaderProcessor.js +5 -3
  123. package/Engines/Processors/shaderProcessor.js.map +1 -1
  124. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js +16 -3
  125. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js.map +1 -1
  126. package/Engines/WebGPU/webgpuClearQuad.pure.js +7 -1
  127. package/Engines/WebGPU/webgpuClearQuad.pure.js.map +1 -1
  128. package/Engines/abstractEngine.functions.d.ts +8 -2
  129. package/Engines/abstractEngine.functions.js +12 -4
  130. package/Engines/abstractEngine.functions.js.map +1 -1
  131. package/Engines/abstractEngine.pure.d.ts +20 -1
  132. package/Engines/abstractEngine.pure.js +21 -134
  133. package/Engines/abstractEngine.pure.js.map +1 -1
  134. package/Engines/engine.d.ts +208 -0
  135. package/Engines/engine.pure.js +0 -15
  136. package/Engines/engine.pure.js.map +1 -1
  137. package/Engines/nullEngine.pure.d.ts +66 -0
  138. package/Engines/nullEngine.pure.js +97 -0
  139. package/Engines/nullEngine.pure.js.map +1 -1
  140. package/Engines/thinEngine.pure.d.ts +0 -13
  141. package/Engines/thinEngine.pure.js +4 -23
  142. package/Engines/thinEngine.pure.js.map +1 -1
  143. package/Engines/thinNativeEngine.d.ts +0 -1
  144. package/Engines/thinNativeEngine.js +0 -1
  145. package/Engines/thinNativeEngine.js.map +1 -1
  146. package/Engines/thinNativeEngine.pure.d.ts +27 -0
  147. package/Engines/thinNativeEngine.pure.js +383 -17
  148. package/Engines/thinNativeEngine.pure.js.map +1 -1
  149. package/Engines/webgpuEngine.d.ts +1 -0
  150. package/Engines/webgpuEngine.js +1 -0
  151. package/Engines/webgpuEngine.js.map +1 -1
  152. package/Engines/webgpuEngine.pure.d.ts +9 -0
  153. package/Engines/webgpuEngine.pure.js +7 -0
  154. package/Engines/webgpuEngine.pure.js.map +1 -1
  155. package/FlowGraph/flowGraph.js +9 -0
  156. package/FlowGraph/flowGraph.js.map +1 -1
  157. package/FlowGraph/flowGraphContext.js +597 -584
  158. package/FlowGraph/flowGraphContext.js.map +1 -1
  159. package/FlowGraph/flowGraphDataConnection.pure.d.ts +14 -0
  160. package/FlowGraph/flowGraphDataConnection.pure.js +38 -1
  161. package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
  162. package/FlowGraph/serialization.d.ts +11 -0
  163. package/FlowGraph/serialization.js +11 -1
  164. package/FlowGraph/serialization.js.map +1 -1
  165. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js +182 -170
  166. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js.map +1 -1
  167. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js +196 -184
  168. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js.map +1 -1
  169. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js +222 -210
  170. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js.map +1 -1
  171. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +123 -111
  172. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  173. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +158 -146
  174. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
  175. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js +63 -51
  176. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js.map +1 -1
  177. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js +122 -110
  178. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js.map +1 -1
  179. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js +76 -64
  180. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js.map +1 -1
  181. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js +89 -77
  182. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js.map +1 -1
  183. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js +134 -122
  184. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js.map +1 -1
  185. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js +58 -46
  186. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js.map +1 -1
  187. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js +107 -95
  188. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js.map +1 -1
  189. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js +181 -169
  190. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js.map +1 -1
  191. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js +63 -51
  192. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js.map +1 -1
  193. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js +63 -51
  194. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js.map +1 -1
  195. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js +76 -64
  196. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js.map +1 -1
  197. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js +246 -234
  198. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js.map +1 -1
  199. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js +108 -96
  200. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js.map +1 -1
  201. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js +87 -75
  202. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js.map +1 -1
  203. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js +76 -64
  204. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js.map +1 -1
  205. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js +313 -301
  206. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js.map +1 -1
  207. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js +502 -490
  208. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js.map +1 -1
  209. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js +147 -135
  210. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js.map +1 -1
  211. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js +90 -78
  212. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js.map +1 -1
  213. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js +179 -167
  214. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js.map +1 -1
  215. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +462 -451
  216. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  217. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +265 -253
  218. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
  219. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js +204 -192
  220. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js.map +1 -1
  221. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +611 -550
  222. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
  223. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js +320 -308
  224. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js.map +1 -1
  225. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js +87 -75
  226. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js.map +1 -1
  227. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js +154 -142
  228. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js.map +1 -1
  229. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js +150 -138
  230. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js.map +1 -1
  231. package/FrameGraph/Node/Blocks/inputBlock.pure.js +270 -256
  232. package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
  233. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js +95 -83
  234. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js.map +1 -1
  235. package/FrameGraph/Node/nodeRenderGraph.js +715 -693
  236. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  237. package/FrameGraph/Node/nodeRenderGraphBlock.js +548 -533
  238. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  239. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +2 -2
  240. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +43 -51
  241. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
  242. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.d.ts +0 -1
  243. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js +0 -1
  244. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js.map +1 -1
  245. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.d.ts +0 -1
  246. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +66 -35
  247. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
  248. package/Helpers/environmentHelper.js +2 -2
  249. package/Helpers/environmentHelper.js.map +1 -1
  250. package/Layers/effectLayer.js +529 -519
  251. package/Layers/effectLayer.js.map +1 -1
  252. package/Layers/glowLayer.pure.js +428 -413
  253. package/Layers/glowLayer.pure.js.map +1 -1
  254. package/Layers/highlightLayer.pure.js +473 -458
  255. package/Layers/highlightLayer.pure.js.map +1 -1
  256. package/Layers/selectionOutlineLayer.pure.js +360 -345
  257. package/Layers/selectionOutlineLayer.pure.js.map +1 -1
  258. package/Lights/Clustered/clusteredLightContainer.pure.d.ts +1 -1
  259. package/Lights/Clustered/clusteredLightContainer.pure.js +583 -558
  260. package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
  261. package/Lights/Shadows/shadowGenerator.js +6 -1
  262. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  263. package/Lights/areaLight.pure.js +61 -39
  264. package/Lights/areaLight.pure.js.map +1 -1
  265. package/Lights/directionalLight.pure.js +308 -284
  266. package/Lights/directionalLight.pure.js.map +1 -1
  267. package/Lights/hemisphericLight.pure.js +123 -104
  268. package/Lights/hemisphericLight.pure.js.map +1 -1
  269. package/Lights/light.d.ts +5 -3
  270. package/Lights/light.js +869 -827
  271. package/Lights/light.js.map +1 -1
  272. package/Lights/pointLight.pure.js +185 -174
  273. package/Lights/pointLight.pure.js.map +1 -1
  274. package/Lights/rectAreaLight.pure.d.ts +17 -0
  275. package/Lights/rectAreaLight.pure.js +238 -159
  276. package/Lights/rectAreaLight.pure.js.map +1 -1
  277. package/Lights/shadowLight.js +280 -268
  278. package/Lights/shadowLight.js.map +1 -1
  279. package/Lights/spotLight.pure.js +460 -427
  280. package/Lights/spotLight.pure.js.map +1 -1
  281. package/Loading/Plugins/babylonFileLoader.pure.js +17 -5
  282. package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
  283. package/Loading/sceneLoader.d.ts +5 -1
  284. package/Loading/sceneLoader.js +299 -402
  285. package/Loading/sceneLoader.js.map +1 -1
  286. package/Materials/Background/backgroundMaterial.pure.d.ts +18 -18
  287. package/Materials/Background/backgroundMaterial.pure.js +949 -794
  288. package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
  289. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.d.ts +15 -0
  290. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +34 -1
  291. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
  292. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +9 -0
  293. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +26 -2
  294. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  295. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.d.ts +2 -1
  296. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js +169 -149
  297. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js.map +1 -1
  298. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +1 -1
  299. package/Materials/Node/Blocks/Dual/lightBlock.pure.js +442 -429
  300. package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
  301. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js +396 -383
  302. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js.map +1 -1
  303. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js +237 -220
  304. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js.map +1 -1
  305. package/Materials/Node/Blocks/Dual/textureBlock.pure.js +1 -1
  306. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js +150 -133
  307. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
  308. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +265 -250
  309. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
  310. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js +159 -142
  311. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js.map +1 -1
  312. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js +214 -201
  313. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js.map +1 -1
  314. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js +419 -400
  315. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js.map +1 -1
  316. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +3 -1
  317. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
  318. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js +302 -289
  319. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js.map +1 -1
  320. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +1327 -1272
  321. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  322. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js +352 -337
  323. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js.map +1 -1
  324. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js +297 -277
  325. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js.map +1 -1
  326. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js +146 -131
  327. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js.map +1 -1
  328. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js +158 -145
  329. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js.map +1 -1
  330. package/Materials/Node/Blocks/clampBlock.pure.js +92 -77
  331. package/Materials/Node/Blocks/clampBlock.pure.js.map +1 -1
  332. package/Materials/Node/Blocks/cloudBlock.pure.js +145 -132
  333. package/Materials/Node/Blocks/cloudBlock.pure.js.map +1 -1
  334. package/Materials/Node/Blocks/conditionalBlock.pure.js +182 -169
  335. package/Materials/Node/Blocks/conditionalBlock.pure.js.map +1 -1
  336. package/Materials/Node/Blocks/curveBlock.pure.js +259 -246
  337. package/Materials/Node/Blocks/curveBlock.pure.js.map +1 -1
  338. package/Materials/Node/Blocks/debugBlock.pure.js +119 -106
  339. package/Materials/Node/Blocks/debugBlock.pure.js.map +1 -1
  340. package/Materials/Node/Blocks/loopBlock.pure.js +123 -110
  341. package/Materials/Node/Blocks/loopBlock.pure.js.map +1 -1
  342. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js +185 -172
  343. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js.map +1 -1
  344. package/Materials/Node/Blocks/remapBlock.pure.js +127 -112
  345. package/Materials/Node/Blocks/remapBlock.pure.js.map +1 -1
  346. package/Materials/Node/Blocks/transformBlock.pure.js +196 -185
  347. package/Materials/Node/Blocks/transformBlock.pure.js.map +1 -1
  348. package/Materials/Node/Blocks/triPlanarBlock.pure.js +451 -438
  349. package/Materials/Node/Blocks/triPlanarBlock.pure.js.map +1 -1
  350. package/Materials/Node/Blocks/trigonometryBlock.pure.js +184 -171
  351. package/Materials/Node/Blocks/trigonometryBlock.pure.js.map +1 -1
  352. package/Materials/Node/Blocks/waveBlock.pure.js +97 -84
  353. package/Materials/Node/Blocks/waveBlock.pure.js.map +1 -1
  354. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js +276 -263
  355. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js.map +1 -1
  356. package/Materials/Node/nodeMaterial.pure.js +1765 -1737
  357. package/Materials/Node/nodeMaterial.pure.js.map +1 -1
  358. package/Materials/Node/nodeMaterialBuildState.d.ts +3 -3
  359. package/Materials/PBR/openpbrMaterial.pure.d.ts +102 -102
  360. package/Materials/PBR/openpbrMaterial.pure.js +3115 -2243
  361. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  362. package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +3 -3
  363. package/Materials/PBR/pbrAnisotropicConfiguration.js +255 -227
  364. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  365. package/Materials/PBR/pbrBRDFConfiguration.d.ts +9 -9
  366. package/Materials/PBR/pbrBRDFConfiguration.js +203 -155
  367. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  368. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +1 -1
  369. package/Materials/PBR/pbrBaseMaterial.pure.js +1751 -1736
  370. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  371. package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +13 -13
  372. package/Materials/PBR/pbrBaseSimpleMaterial.js +205 -117
  373. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  374. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +9 -9
  375. package/Materials/PBR/pbrClearCoatConfiguration.js +464 -406
  376. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  377. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +3 -3
  378. package/Materials/PBR/pbrIridescenceConfiguration.js +271 -239
  379. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  380. package/Materials/PBR/pbrMaterial.pure.d.ts +66 -66
  381. package/Materials/PBR/pbrMaterial.pure.js +1041 -685
  382. package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
  383. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.d.ts +5 -5
  384. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js +176 -115
  385. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js.map +1 -1
  386. package/Materials/PBR/pbrSheenConfiguration.d.ts +7 -7
  387. package/Materials/PBR/pbrSheenConfiguration.js +314 -270
  388. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  389. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.d.ts +5 -5
  390. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js +172 -117
  391. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js.map +1 -1
  392. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +16 -16
  393. package/Materials/PBR/pbrSubSurfaceConfiguration.js +864 -764
  394. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  395. package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +43 -0
  396. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +64 -0
  397. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -0
  398. package/Materials/Textures/HTML/htmlInteractionManager.d.ts +69 -0
  399. package/Materials/Textures/HTML/htmlInteractionManager.js +130 -0
  400. package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -0
  401. package/Materials/Textures/HTML/htmlRaycastInteractionManager.d.ts +84 -0
  402. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js +246 -0
  403. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js.map +1 -0
  404. package/Materials/Textures/HTML/htmlTexture.d.ts +148 -0
  405. package/Materials/Textures/HTML/htmlTexture.js +455 -0
  406. package/Materials/Textures/HTML/htmlTexture.js.map +1 -0
  407. package/Materials/Textures/HTML/index.d.ts +4 -0
  408. package/Materials/Textures/HTML/index.js +5 -0
  409. package/Materials/Textures/HTML/index.js.map +1 -0
  410. package/Materials/Textures/HTML/pure.d.ts +5 -0
  411. package/Materials/Textures/HTML/pure.js +6 -0
  412. package/Materials/Textures/HTML/pure.js.map +1 -0
  413. package/Materials/Textures/Procedurals/proceduralTexture.pure.js +671 -643
  414. package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
  415. package/Materials/Textures/baseTexture.pure.js +880 -825
  416. package/Materials/Textures/baseTexture.pure.js.map +1 -1
  417. package/Materials/Textures/cubeTexture.d.ts +0 -1
  418. package/Materials/Textures/cubeTexture.js +0 -1
  419. package/Materials/Textures/cubeTexture.js.map +1 -1
  420. package/Materials/Textures/cubeTexture.pure.js +368 -333
  421. package/Materials/Textures/cubeTexture.pure.js.map +1 -1
  422. package/Materials/Textures/dynamicTexture.d.ts +0 -1
  423. package/Materials/Textures/dynamicTexture.js +0 -1
  424. package/Materials/Textures/dynamicTexture.js.map +1 -1
  425. package/Materials/Textures/dynamicTexture.pure.js +2 -0
  426. package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
  427. package/Materials/Textures/htmlElementTexture.d.ts +0 -2
  428. package/Materials/Textures/htmlElementTexture.js +0 -2
  429. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  430. package/Materials/Textures/htmlElementTexture.pure.js +4 -0
  431. package/Materials/Textures/htmlElementTexture.pure.js.map +1 -1
  432. package/Materials/Textures/index.d.ts +1 -0
  433. package/Materials/Textures/index.js +1 -1
  434. package/Materials/Textures/index.js.map +1 -1
  435. package/Materials/Textures/multiRenderTarget.d.ts +0 -1
  436. package/Materials/Textures/multiRenderTarget.js +0 -1
  437. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  438. package/Materials/Textures/multiRenderTarget.pure.js +2 -0
  439. package/Materials/Textures/multiRenderTarget.pure.js.map +1 -1
  440. package/Materials/Textures/pure.d.ts +1 -0
  441. package/Materials/Textures/pure.js +1 -0
  442. package/Materials/Textures/pure.js.map +1 -1
  443. package/Materials/Textures/texture.pure.js +961 -923
  444. package/Materials/Textures/texture.pure.js.map +1 -1
  445. package/Materials/Textures/videoTexture.pure.d.ts +3 -0
  446. package/Materials/Textures/videoTexture.pure.js +450 -401
  447. package/Materials/Textures/videoTexture.pure.js.map +1 -1
  448. package/Materials/colorCurves.pure.js +510 -477
  449. package/Materials/colorCurves.pure.js.map +1 -1
  450. package/Materials/effect.pure.js +0 -7
  451. package/Materials/effect.pure.js.map +1 -1
  452. package/Materials/imageProcessing.js +12 -4
  453. package/Materials/imageProcessing.js.map +1 -1
  454. package/Materials/imageProcessingConfiguration.pure.js +647 -587
  455. package/Materials/imageProcessingConfiguration.pure.js.map +1 -1
  456. package/Materials/material.decalMapConfiguration.pure.d.ts +2 -2
  457. package/Materials/material.decalMapConfiguration.pure.js +149 -130
  458. package/Materials/material.decalMapConfiguration.pure.js.map +1 -1
  459. package/Materials/material.detailMapConfiguration.d.ts +3 -3
  460. package/Materials/material.detailMapConfiguration.js +213 -175
  461. package/Materials/material.detailMapConfiguration.js.map +1 -1
  462. package/Materials/material.pure.js +1815 -1721
  463. package/Materials/material.pure.js.map +1 -1
  464. package/Materials/materialPluginBase.pure.js +270 -249
  465. package/Materials/materialPluginBase.pure.js.map +1 -1
  466. package/Materials/materialPluginManager.pure.js +18 -8
  467. package/Materials/materialPluginManager.pure.js.map +1 -1
  468. package/Materials/materialStencilState.js +211 -200
  469. package/Materials/materialStencilState.js.map +1 -1
  470. package/Materials/meshDebugPluginMaterial.pure.d.ts +2 -2
  471. package/Materials/meshDebugPluginMaterial.pure.js +397 -275
  472. package/Materials/meshDebugPluginMaterial.pure.js.map +1 -1
  473. package/Materials/standardMaterial.pure.d.ts +32 -32
  474. package/Materials/standardMaterial.pure.js +1804 -1394
  475. package/Materials/standardMaterial.pure.js.map +1 -1
  476. package/Maths/math.color.pure.js +5 -5
  477. package/Maths/math.functions.js +38 -30
  478. package/Maths/math.functions.js.map +1 -1
  479. package/Maths/math.vector.pure.js +25 -25
  480. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +18 -8
  481. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  482. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +86 -1
  483. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +255 -104
  484. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  485. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.d.ts +39 -0
  486. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +322 -0
  487. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -0
  488. package/Meshes/GreasedLine/greasedLineMesh.pure.js +4 -4
  489. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +3 -3
  490. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +107 -94
  491. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
  492. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js +276 -263
  493. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js.map +1 -1
  494. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js +247 -232
  495. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js.map +1 -1
  496. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js +299 -284
  497. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js.map +1 -1
  498. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js +196 -181
  499. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js.map +1 -1
  500. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js +198 -179
  501. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js.map +1 -1
  502. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js +151 -138
  503. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js.map +1 -1
  504. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js +107 -94
  505. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js.map +1 -1
  506. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js +138 -125
  507. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js.map +1 -1
  508. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js +213 -200
  509. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js.map +1 -1
  510. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js +138 -125
  511. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js.map +1 -1
  512. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js +179 -164
  513. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js.map +1 -1
  514. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js +183 -170
  515. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js.map +1 -1
  516. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js +125 -112
  517. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js.map +1 -1
  518. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js +153 -140
  519. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js.map +1 -1
  520. package/Meshes/Node/Blocks/Sources/discBlock.pure.js +112 -99
  521. package/Meshes/Node/Blocks/Sources/discBlock.pure.js.map +1 -1
  522. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js +133 -120
  523. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js.map +1 -1
  524. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js +128 -115
  525. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js.map +1 -1
  526. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js +116 -103
  527. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js.map +1 -1
  528. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js +160 -147
  529. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js.map +1 -1
  530. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js +144 -131
  531. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js.map +1 -1
  532. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js +112 -99
  533. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js.map +1 -1
  534. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js +200 -185
  535. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js.map +1 -1
  536. package/Meshes/Node/Blocks/bevelBlock.pure.js +111 -98
  537. package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
  538. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js +182 -165
  539. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js.map +1 -1
  540. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js +89 -76
  541. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js.map +1 -1
  542. package/Meshes/Node/Blocks/conditionBlock.pure.js +184 -169
  543. package/Meshes/Node/Blocks/conditionBlock.pure.js.map +1 -1
  544. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js +270 -255
  545. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js.map +1 -1
  546. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js +172 -159
  547. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js.map +1 -1
  548. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js +230 -217
  549. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js.map +1 -1
  550. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js +256 -245
  551. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js.map +1 -1
  552. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js +206 -189
  553. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js.map +1 -1
  554. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js +166 -153
  555. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js.map +1 -1
  556. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js +221 -208
  557. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js.map +1 -1
  558. package/Meshes/Node/Blocks/mappingBlock.pure.js +150 -137
  559. package/Meshes/Node/Blocks/mappingBlock.pure.js.map +1 -1
  560. package/Meshes/Node/Blocks/mathBlock.pure.js +269 -256
  561. package/Meshes/Node/Blocks/mathBlock.pure.js.map +1 -1
  562. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js +141 -128
  563. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js.map +1 -1
  564. package/Meshes/Node/Blocks/randomBlock.pure.js +161 -148
  565. package/Meshes/Node/Blocks/randomBlock.pure.js.map +1 -1
  566. package/Meshes/Node/Blocks/subdivideBlock.pure.js +102 -87
  567. package/Meshes/Node/Blocks/subdivideBlock.pure.js.map +1 -1
  568. package/Meshes/Node/nodeGeometry.js +560 -538
  569. package/Meshes/Node/nodeGeometry.js.map +1 -1
  570. package/Meshes/Node/nodeGeometryBlock.js +473 -458
  571. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  572. package/Meshes/abstractMesh.pure.js +2218 -2207
  573. package/Meshes/abstractMesh.pure.js.map +1 -1
  574. package/Meshes/geometry.js +30 -15
  575. package/Meshes/geometry.js.map +1 -1
  576. package/Meshes/mesh.pure.js +26 -14
  577. package/Meshes/mesh.pure.js.map +1 -1
  578. package/Meshes/mesh.vertexData.js +1665 -1655
  579. package/Meshes/mesh.vertexData.js.map +1 -1
  580. package/Meshes/transformNode.pure.js +1400 -1372
  581. package/Meshes/transformNode.pure.js.map +1 -1
  582. package/Misc/decorators.d.ts +34 -19
  583. package/Misc/decorators.functions.d.ts +33 -2
  584. package/Misc/decorators.functions.js +114 -35
  585. package/Misc/decorators.functions.js.map +1 -1
  586. package/Misc/decorators.js +96 -68
  587. package/Misc/decorators.js.map +1 -1
  588. package/Misc/decorators.serialization.js +47 -40
  589. package/Misc/decorators.serialization.js.map +1 -1
  590. package/Misc/decorators.serializationUtilities.d.ts +24 -0
  591. package/Misc/decorators.serializationUtilities.js +20 -0
  592. package/Misc/decorators.serializationUtilities.js.map +1 -0
  593. package/Misc/dumpTools.pure.js +43 -33
  594. package/Misc/dumpTools.pure.js.map +1 -1
  595. package/Misc/fileTools.pure.js +8 -0
  596. package/Misc/fileTools.pure.js.map +1 -1
  597. package/Misc/observable.pure.js +0 -7
  598. package/Misc/observable.pure.js.map +1 -1
  599. package/Misc/snapshotRenderingHelper.d.ts +4 -1
  600. package/Misc/snapshotRenderingHelper.js.map +1 -1
  601. package/Misc/symbolMetadataPolyfill.d.ts +11 -0
  602. package/Misc/symbolMetadataPolyfill.js +22 -0
  603. package/Misc/symbolMetadataPolyfill.js.map +1 -0
  604. package/Misc/tools.pure.js +2 -2
  605. package/Misc/tools.pure.js.map +1 -1
  606. package/Morph/morphTarget.js +382 -365
  607. package/Morph/morphTarget.js.map +1 -1
  608. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js +160 -145
  609. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js.map +1 -1
  610. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js +187 -174
  611. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js.map +1 -1
  612. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js +238 -219
  613. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js.map +1 -1
  614. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js +140 -115
  615. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js.map +1 -1
  616. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js +157 -144
  617. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js.map +1 -1
  618. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js +133 -119
  619. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js.map +1 -1
  620. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js +93 -80
  621. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js.map +1 -1
  622. package/Particles/Node/Blocks/particleDebugBlock.pure.js +117 -105
  623. package/Particles/Node/Blocks/particleDebugBlock.pure.js.map +1 -1
  624. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js +105 -92
  625. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js.map +1 -1
  626. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js +82 -69
  627. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js.map +1 -1
  628. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js +113 -101
  629. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js.map +1 -1
  630. package/Particles/Node/Blocks/particleMathBlock.pure.js +278 -265
  631. package/Particles/Node/Blocks/particleMathBlock.pure.js.map +1 -1
  632. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js +155 -142
  633. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js.map +1 -1
  634. package/Particles/Node/Blocks/particleRandomBlock.pure.js +156 -143
  635. package/Particles/Node/Blocks/particleRandomBlock.pure.js.map +1 -1
  636. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js +217 -204
  637. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js.map +1 -1
  638. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js +106 -93
  639. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js.map +1 -1
  640. package/Particles/Node/Blocks/systemBlock.pure.js +366 -330
  641. package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
  642. package/Particles/Node/nodeParticleBlock.js +339 -324
  643. package/Particles/Node/nodeParticleBlock.js.map +1 -1
  644. package/Particles/Node/nodeParticleSystemSet.js +494 -473
  645. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  646. package/Particles/gpuParticleSystem.d.ts +0 -1
  647. package/Particles/gpuParticleSystem.js +0 -1
  648. package/Particles/gpuParticleSystem.js.map +1 -1
  649. package/Particles/gpuParticleSystem.pure.d.ts +4 -3
  650. package/Particles/gpuParticleSystem.pure.js +27 -16
  651. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  652. package/Particles/particleSystem.pure.js +57 -2
  653. package/Particles/particleSystem.pure.js.map +1 -1
  654. package/Particles/thinParticleSystem.d.ts +0 -1
  655. package/Particles/thinParticleSystem.js +0 -1
  656. package/Particles/thinParticleSystem.js.map +1 -1
  657. package/Particles/thinParticleSystem.pure.js +2 -0
  658. package/Particles/thinParticleSystem.pure.js.map +1 -1
  659. package/Particles/webgl2ParticleSystem.pure.js +2 -0
  660. package/Particles/webgl2ParticleSystem.pure.js.map +1 -1
  661. package/Physics/v1/physicsImpostor.pure.js +4 -4
  662. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js +675 -656
  663. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js.map +1 -1
  664. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.d.ts +0 -1
  665. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +0 -1
  666. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
  667. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js +521 -486
  668. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js.map +1 -1
  669. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +0 -1
  670. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +0 -1
  671. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  672. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js +241 -220
  673. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
  674. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js +852 -835
  675. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js.map +1 -1
  676. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js +1135 -1073
  677. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js.map +1 -1
  678. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js +319 -303
  679. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js.map +1 -1
  680. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +212 -199
  681. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  682. package/PostProcesses/blackAndWhitePostProcess.pure.js +67 -55
  683. package/PostProcesses/blackAndWhitePostProcess.pure.js.map +1 -1
  684. package/PostProcesses/bloomMergePostProcess.pure.js +74 -62
  685. package/PostProcesses/bloomMergePostProcess.pure.js.map +1 -1
  686. package/PostProcesses/blurPostProcess.pure.js +127 -115
  687. package/PostProcesses/blurPostProcess.pure.js.map +1 -1
  688. package/PostProcesses/chromaticAberrationPostProcess.pure.js +130 -118
  689. package/PostProcesses/chromaticAberrationPostProcess.pure.js.map +1 -1
  690. package/PostProcesses/circleOfConfusionPostProcess.pure.js +115 -104
  691. package/PostProcesses/circleOfConfusionPostProcess.pure.js.map +1 -1
  692. package/PostProcesses/colorCorrectionPostProcess.pure.js +55 -43
  693. package/PostProcesses/colorCorrectionPostProcess.pure.js.map +1 -1
  694. package/PostProcesses/convolutionPostProcess.pure.js +96 -84
  695. package/PostProcesses/convolutionPostProcess.pure.js.map +1 -1
  696. package/PostProcesses/extractHighlightsPostProcess.pure.js +68 -57
  697. package/PostProcesses/extractHighlightsPostProcess.pure.js.map +1 -1
  698. package/PostProcesses/filterPostProcess.pure.js +66 -54
  699. package/PostProcesses/filterPostProcess.pure.js.map +1 -1
  700. package/PostProcesses/fxaaPostProcess.pure.js.map +1 -1
  701. package/PostProcesses/grainPostProcess.pure.js +82 -70
  702. package/PostProcesses/grainPostProcess.pure.js.map +1 -1
  703. package/PostProcesses/imageProcessingPostProcess.js +334 -322
  704. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  705. package/PostProcesses/motionBlurPostProcess.pure.js +246 -235
  706. package/PostProcesses/motionBlurPostProcess.pure.js.map +1 -1
  707. package/PostProcesses/passPostProcess.pure.js +75 -63
  708. package/PostProcesses/passPostProcess.pure.js.map +1 -1
  709. package/PostProcesses/postProcess.pure.js +899 -835
  710. package/PostProcesses/postProcess.pure.js.map +1 -1
  711. package/PostProcesses/refractionPostProcess.pure.js +114 -87
  712. package/PostProcesses/refractionPostProcess.pure.js.map +1 -1
  713. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js +108 -96
  714. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js.map +1 -1
  715. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js +241 -220
  716. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js.map +1 -1
  717. package/PostProcesses/sharpenPostProcess.pure.js +86 -74
  718. package/PostProcesses/sharpenPostProcess.pure.js.map +1 -1
  719. package/PostProcesses/tonemapPostProcess.pure.js +82 -70
  720. package/PostProcesses/tonemapPostProcess.pure.js.map +1 -1
  721. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +500 -465
  722. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
  723. package/PostProcesses/vrMultiviewToSingleviewPostProcess.d.ts +0 -1
  724. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +0 -1
  725. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  726. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js +2 -0
  727. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js.map +1 -1
  728. package/Probes/reflectionProbe.pure.js +238 -224
  729. package/Probes/reflectionProbe.pure.js.map +1 -1
  730. package/Rendering/GlobalIllumination/giRSMManager.pure.d.ts +1 -1
  731. package/Rendering/GlobalIllumination/giRSMManager.pure.js +138 -105
  732. package/Rendering/GlobalIllumination/giRSMManager.pure.js.map +1 -1
  733. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.d.ts +1 -1
  734. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js +155 -138
  735. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js.map +1 -1
  736. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +0 -2
  737. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +0 -2
  738. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  739. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +5 -0
  740. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  741. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +0 -1
  742. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +0 -1
  743. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  744. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +1 -0
  745. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +34 -0
  746. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  747. package/Rendering/edgesRenderer.pure.js.map +1 -1
  748. package/Rendering/prePassRenderer.d.ts +0 -2
  749. package/Rendering/prePassRenderer.js +0 -2
  750. package/Rendering/prePassRenderer.js.map +1 -1
  751. package/Rendering/prePassRenderer.pure.js +2 -0
  752. package/Rendering/prePassRenderer.pure.js.map +1 -1
  753. package/Rendering/reflectiveShadowMap.pure.d.ts +1 -1
  754. package/Rendering/reflectiveShadowMap.pure.js +151 -130
  755. package/Rendering/reflectiveShadowMap.pure.js.map +1 -1
  756. package/Rendering/thinDepthPeelingRenderer.d.ts +0 -1
  757. package/Rendering/thinDepthPeelingRenderer.js +0 -1
  758. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  759. package/Shaders/ShadersInclude/gaussianSplatting.js +1 -0
  760. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  761. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +35 -5
  762. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  763. package/Shaders/gaussianSplatting.fragment.js +17 -1
  764. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  765. package/Shaders/gaussianSplatting.vertex.js +1 -1
  766. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  767. package/Shaders/gaussianSplattingDepth.vertex.js +1 -1
  768. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  769. package/Shaders/picking.fragment.js +39 -3
  770. package/Shaders/picking.fragment.js.map +1 -1
  771. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +3 -1
  772. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  773. package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
  774. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  775. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +39 -7
  776. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  777. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +4 -3
  778. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  779. package/ShadersWGSL/gaussianSplatting.fragment.js +14 -1
  780. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
  781. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
  782. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  783. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  784. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  785. package/ShadersWGSL/lightingVolume.compute.js +2 -2
  786. package/ShadersWGSL/lightingVolume.compute.js.map +1 -1
  787. package/ShadersWGSL/picking.fragment.js +22 -1
  788. package/ShadersWGSL/picking.fragment.js.map +1 -1
  789. package/XR/features/Layers/WebXRCompositionLayer.d.ts +3 -2
  790. package/XR/features/Layers/WebXRCompositionLayer.js +2 -2
  791. package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
  792. package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +59 -0
  793. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +120 -0
  794. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -0
  795. package/XR/features/Layers/WebXRWebGPUProjectionLayer.d.ts +25 -0
  796. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js +69 -0
  797. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js.map +1 -0
  798. package/XR/features/WebXRLayers.pure.d.ts +8 -0
  799. package/XR/features/WebXRLayers.pure.js +43 -6
  800. package/XR/features/WebXRLayers.pure.js.map +1 -1
  801. package/XR/native/nativeXRRenderTarget.d.ts +2 -2
  802. package/XR/native/nativeXRRenderTarget.js +2 -2
  803. package/XR/native/nativeXRRenderTarget.js.map +1 -1
  804. package/XR/webXRExperienceHelper.js +10 -1
  805. package/XR/webXRExperienceHelper.js.map +1 -1
  806. package/XR/webXRGraphicsBinding.d.ts +90 -0
  807. package/XR/webXRGraphicsBinding.js +85 -0
  808. package/XR/webXRGraphicsBinding.js.map +1 -0
  809. package/XR/webXRLayerRenderTargetTexture.d.ts +24 -0
  810. package/XR/webXRLayerRenderTargetTexture.js +30 -0
  811. package/XR/webXRLayerRenderTargetTexture.js.map +1 -0
  812. package/XR/webXRManagedOutputCanvas.d.ts +14 -0
  813. package/XR/webXRManagedOutputCanvas.js +24 -5
  814. package/XR/webXRManagedOutputCanvas.js.map +1 -1
  815. package/XR/webXRRenderTargetTextureProvider.d.ts +25 -4
  816. package/XR/webXRRenderTargetTextureProvider.js +33 -35
  817. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  818. package/XR/webXRSessionManager.d.ts +11 -0
  819. package/XR/webXRSessionManager.js +37 -0
  820. package/XR/webXRSessionManager.js.map +1 -1
  821. package/XR/webXRTypes.d.ts +9 -6
  822. package/XR/webXRTypes.js.map +1 -1
  823. package/XR/webXRWebGLLayer.d.ts +2 -2
  824. package/XR/webXRWebGLLayer.js +2 -2
  825. package/XR/webXRWebGLLayer.js.map +1 -1
  826. package/XR/webXRWebGLRenderTargetTextureProvider.d.ts +12 -0
  827. package/XR/webXRWebGLRenderTargetTextureProvider.js +58 -0
  828. package/XR/webXRWebGLRenderTargetTextureProvider.js.map +1 -0
  829. package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +69 -0
  830. package/XR/webXRWebGPURenderTargetTextureProvider.js +148 -0
  831. package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -0
  832. package/index.d.ts +1 -0
  833. package/index.js +1 -0
  834. package/index.js.map +1 -1
  835. package/node.js +878 -845
  836. package/node.js.map +1 -1
  837. package/package.json +8 -14
  838. package/scene.pure.d.ts +12 -0
  839. package/scene.pure.js +36 -0
  840. package/scene.pure.js.map +1 -1
  841. package/tslib.es6.js +304 -150
@@ -1,5 +1,5 @@
1
1
  /** This file must only contain pure code and pure imports */
2
- import { __decorate } from "../tslib.es6.js";
2
+ import { __esDecorate, __runInitializers } from "../tslib.es6.js";
3
3
  import { serialize } from "../Misc/decorators.js";
4
4
  import { Tools } from "../Misc/tools.pure.js";
5
5
  import { Observable } from "../Misc/observable.pure.js";
@@ -18,1789 +18,1883 @@ import { GetClass } from "../Misc/typeStore.js";
18
18
  /**
19
19
  * Base class for the main features of a material in Babylon.js
20
20
  */
21
- export class Material {
22
- /**
23
- * Tells the engine to draw geometry using vertex pulling instead of index drawing. This will automatically
24
- * set the vertex buffers as storage buffers and make them accessible to the vertex shader (WebGPU only).
25
- */
26
- get useVertexPulling() {
27
- return this._useVertexPulling;
28
- }
29
- set useVertexPulling(value) {
30
- if (this._useVertexPulling === value) {
31
- return;
32
- }
33
- this._useVertexPulling = value;
34
- this.markAsDirty(Material.MiscDirtyFlag);
35
- }
36
- /**
37
- * Indicates that the material is disposed
38
- */
39
- get isDisposed() {
40
- return this._isDisposed;
41
- }
42
- /** @internal */
43
- get _supportGlowLayer() {
44
- return false;
45
- }
46
- /** @internal */
47
- set _glowModeEnabled(value) {
48
- // Do nothing here
49
- }
50
- /**
51
- * Gets the shader language used in this material.
52
- */
53
- get shaderLanguage() {
54
- return this._shaderLanguage;
55
- }
56
- /**
57
- * If the material can be rendered to several textures with MRT extension
58
- */
59
- get canRenderToMRT() {
60
- // By default, shaders are not compatible with MRTs
61
- // Base classes should override that if their shader supports MRT
62
- return false;
63
- }
64
- /**
65
- * Sets the alpha value of the material
66
- */
67
- set alpha(value) {
68
- if (this._alpha === value) {
69
- return;
70
- }
71
- const oldValue = this._alpha;
72
- this._alpha = value;
73
- // Only call dirty when there is a state change (no alpha / alpha)
74
- if (oldValue === 1 || value === 1) {
75
- this.markAsDirty(Material.MiscDirtyFlag + Material.PrePassDirtyFlag);
76
- }
77
- }
78
- /**
79
- * Gets the alpha value of the material
80
- */
81
- get alpha() {
82
- return this._alpha;
83
- }
84
- /**
85
- * Sets the culling state (true to enable culling, false to disable)
86
- */
87
- set backFaceCulling(value) {
88
- if (this._backFaceCulling === value) {
89
- return;
90
- }
91
- this._backFaceCulling = value;
92
- this.markAsDirty(Material.TextureDirtyFlag);
93
- }
94
- /**
95
- * Gets the culling state
96
- */
97
- get backFaceCulling() {
98
- return this._backFaceCulling;
99
- }
100
- /**
101
- * Sets the texture repetition breaking mode.
102
- * Use one of the undefined* values to break visible texture tiling patterns.
103
- * Ordered by cost: NONE (1 fetch), NOISE_BLEND (3), HEX_TILING (3), TILE_RANDOMIZATION (4), VORONOI_BOMBING (9).
104
- * Not supported on WebGL1 — the mode will be forced to NONE.
105
- * @see https://iquilezles.org/articles/texturerepetition/
106
- * @see https://jcgt.org/published/0011/03/05/
107
- */
108
- set textureRepetitionMode(value) {
109
- const clamped = Math.max(0, Math.min(value | 0, 4));
110
- if (this._textureRepetitionMode === clamped) {
111
- return;
112
- }
113
- this._textureRepetitionMode = clamped;
114
- this.markAsDirty(Material.TextureDirtyFlag);
115
- }
116
- /**
117
- * Gets the texture repetition breaking mode.
118
- * @see https://iquilezles.org/articles/texturerepetition/
119
- */
120
- get textureRepetitionMode() {
121
- return this._textureRepetitionMode;
122
- }
123
- /**
124
- * Sets the type of faces that should be culled (true for back faces, false for front faces)
125
- */
126
- set cullBackFaces(value) {
127
- if (this._cullBackFaces === value) {
128
- return;
129
- }
130
- this._cullBackFaces = value;
131
- this.markAsDirty(Material.TextureDirtyFlag);
132
- }
133
- /**
134
- * Gets the type of faces that should be culled
135
- */
136
- get cullBackFaces() {
137
- return this._cullBackFaces;
138
- }
139
- /**
140
- * Block the dirty-mechanism for this specific material
141
- * When set to false after being true the material will be marked as dirty.
142
- */
143
- get blockDirtyMechanism() {
144
- return this._blockDirtyMechanism;
145
- }
146
- set blockDirtyMechanism(value) {
147
- if (this._blockDirtyMechanism === value) {
148
- return;
149
- }
150
- this._blockDirtyMechanism = value;
151
- if (!value) {
152
- this.markDirty();
153
- }
154
- }
155
- /**
156
- * This allows you to modify the material without marking it as dirty after every change.
157
- * This function should be used if you need to make more than one dirty-enabling change to the material - adding a texture, setting a new fill mode and so on.
158
- * The callback will pass the material as an argument, so you can make your changes to it.
159
- * @param callback the callback to be executed that will update the material
160
- */
161
- atomicMaterialsUpdate(callback) {
162
- this.blockDirtyMechanism = true;
163
- try {
164
- callback(this);
165
- }
166
- finally {
167
- this.blockDirtyMechanism = false;
168
- }
169
- }
170
- /**
171
- * Gets a boolean indicating that current material needs to register RTT
172
- */
173
- get hasRenderTargetTextures() {
174
- this._eventInfo.hasRenderTargetTextures = false;
175
- this._callbackPluginEventHasRenderTargetTextures(this._eventInfo);
176
- return this._eventInfo.hasRenderTargetTextures;
177
- }
178
- /**
179
- * Called during a dispose event
180
- */
181
- set onDispose(callback) {
182
- if (this._onDisposeObserver) {
183
- this.onDisposeObservable.remove(this._onDisposeObserver);
184
- }
185
- this._onDisposeObserver = this.onDisposeObservable.add(callback);
186
- }
187
- /**
188
- * An event triggered when the material is bound
189
- */
190
- get onBindObservable() {
191
- if (!this._onBindObservable) {
192
- this._onBindObservable = new Observable();
193
- }
194
- return this._onBindObservable;
195
- }
196
- /**
197
- * Called during a bind event
198
- */
199
- set onBind(callback) {
200
- if (this._onBindObserver) {
201
- this.onBindObservable.remove(this._onBindObserver);
202
- }
203
- this._onBindObserver = this.onBindObservable.add(callback);
204
- }
205
- /**
206
- * An event triggered when the material is unbound
207
- */
208
- get onUnBindObservable() {
209
- if (!this._onUnBindObservable) {
210
- this._onUnBindObservable = new Observable();
211
- }
212
- return this._onUnBindObservable;
213
- }
214
- /**
215
- * An event triggered when the effect is (re)created
216
- */
217
- get onEffectCreatedObservable() {
218
- if (!this._onEffectCreatedObservable) {
219
- this._onEffectCreatedObservable = new Observable();
220
- }
221
- return this._onEffectCreatedObservable;
222
- }
223
- /**
224
- * Sets the value of the alpha mode.
225
- *
226
- * | Value | Type | Description |
227
- * | --- | --- | --- |
228
- * | 0 | ALPHA_DISABLE | |
229
- * | 1 | ALPHA_ADD | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + DEST, ALPHA=DEST_ALPHA |
230
- * | 2 | ALPHA_COMBINE | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + (1 - SRC_ALPHA) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
231
- * | 3 | ALPHA_SUBTRACT | Defines that alpha blending is COLOR=(1 - SRC) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
232
- * | 4 | ALPHA_MULTIPLY | Defines that alpha blending is COLOR=DEST * SRC, ALPHA=SRC_ALPHA + DEST_ALPHA |
233
- * | 5 | ALPHA_MAXIMIZED | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + (1 - SRC) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
234
- * | 6 | ALPHA_ONEONE | Defines that alpha blending is COLOR=SRC + DEST, ALPHA=DEST_ALPHA |
235
- * | 7 | ALPHA_PREMULTIPLIED | Defines that alpha blending is COLOR=SRC + (1 - SRC_ALPHA) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
236
- * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | Defines that alpha blending is COLOR=SRC + (1 - SRC_ALPHA) * DEST, ALPHA=SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
237
- * | 9 | ALPHA_INTERPOLATE | Defines that alpha blending is COLOR=CST * SRC + (1 - CST) * DEST, ALPHA=CST_ALPHA * SRC + (1 - CST_ALPHA) * DEST_ALPHA |
238
- * | 10 | ALPHA_SCREENMODE | Defines that alpha blending is COLOR=SRC + (1 - SRC) * DEST, ALPHA=SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
239
- * | 11 | ALPHA_ONEONE_ONEONE | Defines that alpha blending is COLOR=SRC + DST, ALPHA=SRC_ALPHA + DEST_ALPHA |
240
- * | 12 | ALPHA_ALPHATOCOLOR | Defines that alpha blending is COLOR=DEST_ALPHA * SRC + DST, ALPHA=0 |
241
- * | 13 | ALPHA_REVERSEONEMINUS | Defines that alpha blending is COLOR=(1 - DEST) * SRC + (1 - SRC) * DEST, ALPHA=(1 - DEST_ALPHA) * SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
242
- * | 14 | ALPHA_SRC_DSTONEMINUSSRCALPHA | Defines that alpha blending is ALPHA=SRC + (1 - SRC ALPHA) * DEST, ALPHA=SRC_ALPHA + (1 - SRC ALPHA) * DEST_ALPHA |
243
- * | 15 | ALPHA_ONEONE_ONEZERO | Defines that alpha blending is COLOR=SRC + DST, ALPHA=SRC_ALPHA |
244
- * | 16 | ALPHA_EXCLUSION | Defines that alpha blending is COLOR=(1 - DEST) * SRC + (1 - SRC) * DEST, ALPHA=DEST_ALPHA |
245
- * | 17 | ALPHA_LAYER_ACCUMULATE | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + (1 - SRC ALPHA) * DEST, ALPHA=SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
246
- * | 18 | ALPHA_MIN | Defines that alpha blending is COLOR=MIN(SRC, DEST), ALPHA=MIN(SRC_ALPHA, DEST_ALPHA) |
247
- * | 19 | ALPHA_MAX | Defines that alpha blending is COLOR=MAX(SRC, DEST), ALPHA=MAX(SRC_ALPHA, DEST_ALPHA) |
248
- * | 20 | ALPHA_DUAL_SRC0_ADD_SRC1xDST | Defines that alpha blending uses dual source blending and is COLOR=SRC + SRC1 * DEST, ALPHA=DST_ALPHA |
249
- *
250
- */
251
- set alphaMode(value) {
252
- if (this._alphaMode[0] === value) {
253
- return;
254
- }
255
- this._alphaMode[0] = value;
256
- this.markAsDirty(Material.TextureDirtyFlag);
257
- }
258
- /**
259
- * Gets the value of the alpha mode
260
- */
261
- get alphaMode() {
262
- return this._alphaMode[0];
263
- }
264
- /**
265
- * Gets the list of alpha modes (length greater than 1 for multi-targets)
266
- */
267
- get alphaModes() {
268
- return this._alphaMode;
269
- }
270
- /**
271
- * Sets the value of the alpha mode for a specific target index.
272
- * @param value The alpha mode value to set.
273
- * @param targetIndex The index of the target to set the alpha mode for. Defaults to 0.
274
- */
275
- setAlphaMode(value, targetIndex = 0) {
276
- if (this._alphaMode[targetIndex] === value) {
277
- return;
278
- }
279
- this._alphaMode[targetIndex] = value;
280
- this.markAsDirty(Material.TextureDirtyFlag);
281
- }
282
- /**
283
- * Sets the need depth pre-pass value
284
- */
285
- set needDepthPrePass(value) {
286
- if (this._needDepthPrePass === value) {
287
- return;
288
- }
289
- this._needDepthPrePass = value;
290
- if (this._needDepthPrePass) {
291
- this.checkReadyOnEveryCall = true;
292
- }
293
- }
294
- /**
295
- * Gets the depth pre-pass value
296
- */
297
- get needDepthPrePass() {
298
- return this._needDepthPrePass;
299
- }
300
- /**
301
- * Can this material render to prepass
302
- */
303
- get isPrePassCapable() {
304
- return false;
305
- }
306
- /**
307
- * Sets the state for enabling fog
308
- */
309
- set fogEnabled(value) {
310
- if (this._fogEnabled === value) {
311
- return;
312
- }
313
- this._fogEnabled = value;
314
- this.markAsDirty(Material.MiscDirtyFlag);
315
- }
316
- /**
317
- * Gets the value of the fog enabled state
318
- */
319
- get fogEnabled() {
320
- return this._fogEnabled;
321
- }
322
- get wireframe() {
323
- switch (this._fillMode) {
324
- case Material.WireFrameFillMode:
325
- case Material.LineListDrawMode:
326
- case Material.LineLoopDrawMode:
327
- case Material.LineStripDrawMode:
21
+ let Material = (() => {
22
+ var _a;
23
+ let _instanceExtraInitializers = [];
24
+ let _id_decorators;
25
+ let _id_initializers = [];
26
+ let _id_extraInitializers = [];
27
+ let _uniqueId_decorators;
28
+ let _uniqueId_initializers = [];
29
+ let _uniqueId_extraInitializers = [];
30
+ let _name_decorators;
31
+ let _name_initializers = [];
32
+ let _name_extraInitializers = [];
33
+ let _metadata_decorators;
34
+ let _metadata_initializers = [];
35
+ let _metadata_extraInitializers = [];
36
+ let _checkReadyOnEveryCall_decorators;
37
+ let _checkReadyOnEveryCall_initializers = [];
38
+ let _checkReadyOnEveryCall_extraInitializers = [];
39
+ let _checkReadyOnlyOnce_decorators;
40
+ let _checkReadyOnlyOnce_initializers = [];
41
+ let _checkReadyOnlyOnce_extraInitializers = [];
42
+ let _state_decorators;
43
+ let _state_initializers = [];
44
+ let _state_extraInitializers = [];
45
+ let __alpha_decorators;
46
+ let __alpha_initializers = [];
47
+ let __alpha_extraInitializers = [];
48
+ let __backFaceCulling_decorators;
49
+ let __backFaceCulling_initializers = [];
50
+ let __backFaceCulling_extraInitializers = [];
51
+ let __textureRepetitionMode_decorators;
52
+ let __textureRepetitionMode_initializers = [];
53
+ let __textureRepetitionMode_extraInitializers = [];
54
+ let _textureRepetitionHexTilingParams_decorators;
55
+ let _textureRepetitionHexTilingParams_initializers = [];
56
+ let _textureRepetitionHexTilingParams_extraInitializers = [];
57
+ let __cullBackFaces_decorators;
58
+ let __cullBackFaces_initializers = [];
59
+ let __cullBackFaces_extraInitializers = [];
60
+ let _sideOrientation_decorators;
61
+ let _sideOrientation_initializers = [];
62
+ let _sideOrientation_extraInitializers = [];
63
+ let __alphaMode_decorators;
64
+ let __alphaMode_initializers = [];
65
+ let __alphaMode_extraInitializers = [];
66
+ let __needDepthPrePass_decorators;
67
+ let __needDepthPrePass_initializers = [];
68
+ let __needDepthPrePass_extraInitializers = [];
69
+ let _disableDepthWrite_decorators;
70
+ let _disableDepthWrite_initializers = [];
71
+ let _disableDepthWrite_extraInitializers = [];
72
+ let _disableColorWrite_decorators;
73
+ let _disableColorWrite_initializers = [];
74
+ let _disableColorWrite_extraInitializers = [];
75
+ let _forceDepthWrite_decorators;
76
+ let _forceDepthWrite_initializers = [];
77
+ let _forceDepthWrite_extraInitializers = [];
78
+ let _depthFunction_decorators;
79
+ let _depthFunction_initializers = [];
80
+ let _depthFunction_extraInitializers = [];
81
+ let _separateCullingPass_decorators;
82
+ let _separateCullingPass_initializers = [];
83
+ let _separateCullingPass_extraInitializers = [];
84
+ let __fogEnabled_decorators;
85
+ let __fogEnabled_initializers = [];
86
+ let __fogEnabled_extraInitializers = [];
87
+ let _pointSize_decorators;
88
+ let _pointSize_initializers = [];
89
+ let _pointSize_extraInitializers = [];
90
+ let _zOffset_decorators;
91
+ let _zOffset_initializers = [];
92
+ let _zOffset_extraInitializers = [];
93
+ let _zOffsetUnits_decorators;
94
+ let _zOffsetUnits_initializers = [];
95
+ let _zOffsetUnits_extraInitializers = [];
96
+ let _get_pointsCloud_decorators;
97
+ let _get_fillMode_decorators;
98
+ let _get_useLogarithmicDepth_decorators;
99
+ let __isVertexOutputInvariant_decorators;
100
+ let __isVertexOutputInvariant_initializers = [];
101
+ let __isVertexOutputInvariant_extraInitializers = [];
102
+ let _get_transparencyMode_decorators;
103
+ return _a = class Material {
104
+ /**
105
+ * Tells the engine to draw geometry using vertex pulling instead of index drawing. This will automatically
106
+ * set the vertex buffers as storage buffers and make them accessible to the vertex shader (WebGPU only).
107
+ */
108
+ get useVertexPulling() {
109
+ return this._useVertexPulling;
110
+ }
111
+ set useVertexPulling(value) {
112
+ if (this._useVertexPulling === value) {
113
+ return;
114
+ }
115
+ this._useVertexPulling = value;
116
+ this.markAsDirty(_a.MiscDirtyFlag);
117
+ }
118
+ /**
119
+ * Indicates that the material is disposed
120
+ */
121
+ get isDisposed() {
122
+ return this._isDisposed;
123
+ }
124
+ /** @internal */
125
+ get _supportGlowLayer() {
126
+ return false;
127
+ }
128
+ /** @internal */
129
+ set _glowModeEnabled(value) {
130
+ // Do nothing here
131
+ }
132
+ /**
133
+ * Gets the shader language used in this material.
134
+ */
135
+ get shaderLanguage() {
136
+ return this._shaderLanguage;
137
+ }
138
+ /**
139
+ * If the material can be rendered to several textures with MRT extension
140
+ */
141
+ get canRenderToMRT() {
142
+ // By default, shaders are not compatible with MRTs
143
+ // Base classes should override that if their shader supports MRT
144
+ return false;
145
+ }
146
+ /**
147
+ * Sets the alpha value of the material
148
+ */
149
+ set alpha(value) {
150
+ if (this._alpha === value) {
151
+ return;
152
+ }
153
+ const oldValue = this._alpha;
154
+ this._alpha = value;
155
+ // Only call dirty when there is a state change (no alpha / alpha)
156
+ if (oldValue === 1 || value === 1) {
157
+ this.markAsDirty(_a.MiscDirtyFlag + _a.PrePassDirtyFlag);
158
+ }
159
+ }
160
+ /**
161
+ * Gets the alpha value of the material
162
+ */
163
+ get alpha() {
164
+ return this._alpha;
165
+ }
166
+ /**
167
+ * Sets the culling state (true to enable culling, false to disable)
168
+ */
169
+ set backFaceCulling(value) {
170
+ if (this._backFaceCulling === value) {
171
+ return;
172
+ }
173
+ this._backFaceCulling = value;
174
+ this.markAsDirty(_a.TextureDirtyFlag);
175
+ }
176
+ /**
177
+ * Gets the culling state
178
+ */
179
+ get backFaceCulling() {
180
+ return this._backFaceCulling;
181
+ }
182
+ /**
183
+ * Sets the texture repetition breaking mode.
184
+ * Use one of the undefined* values to break visible texture tiling patterns.
185
+ * Ordered by cost: NONE (1 fetch), NOISE_BLEND (3), HEX_TILING (3), TILE_RANDOMIZATION (4), VORONOI_BOMBING (9).
186
+ * Not supported on WebGL1 — the mode will be forced to NONE.
187
+ * @see https://iquilezles.org/articles/texturerepetition/
188
+ * @see https://jcgt.org/published/0011/03/05/
189
+ */
190
+ set textureRepetitionMode(value) {
191
+ const clamped = Math.max(0, Math.min(value | 0, 4));
192
+ if (this._textureRepetitionMode === clamped) {
193
+ return;
194
+ }
195
+ this._textureRepetitionMode = clamped;
196
+ this.markAsDirty(_a.TextureDirtyFlag);
197
+ }
198
+ /**
199
+ * Gets the texture repetition breaking mode.
200
+ * @see https://iquilezles.org/articles/texturerepetition/
201
+ */
202
+ get textureRepetitionMode() {
203
+ return this._textureRepetitionMode;
204
+ }
205
+ /**
206
+ * Sets the type of faces that should be culled (true for back faces, false for front faces)
207
+ */
208
+ set cullBackFaces(value) {
209
+ if (this._cullBackFaces === value) {
210
+ return;
211
+ }
212
+ this._cullBackFaces = value;
213
+ this.markAsDirty(_a.TextureDirtyFlag);
214
+ }
215
+ /**
216
+ * Gets the type of faces that should be culled
217
+ */
218
+ get cullBackFaces() {
219
+ return this._cullBackFaces;
220
+ }
221
+ /**
222
+ * Block the dirty-mechanism for this specific material
223
+ * When set to false after being true the material will be marked as dirty.
224
+ */
225
+ get blockDirtyMechanism() {
226
+ return this._blockDirtyMechanism;
227
+ }
228
+ set blockDirtyMechanism(value) {
229
+ if (this._blockDirtyMechanism === value) {
230
+ return;
231
+ }
232
+ this._blockDirtyMechanism = value;
233
+ if (!value) {
234
+ this.markDirty();
235
+ }
236
+ }
237
+ /**
238
+ * This allows you to modify the material without marking it as dirty after every change.
239
+ * This function should be used if you need to make more than one dirty-enabling change to the material - adding a texture, setting a new fill mode and so on.
240
+ * The callback will pass the material as an argument, so you can make your changes to it.
241
+ * @param callback the callback to be executed that will update the material
242
+ */
243
+ atomicMaterialsUpdate(callback) {
244
+ this.blockDirtyMechanism = true;
245
+ try {
246
+ callback(this);
247
+ }
248
+ finally {
249
+ this.blockDirtyMechanism = false;
250
+ }
251
+ }
252
+ /**
253
+ * Gets a boolean indicating that current material needs to register RTT
254
+ */
255
+ get hasRenderTargetTextures() {
256
+ this._eventInfo.hasRenderTargetTextures = false;
257
+ this._callbackPluginEventHasRenderTargetTextures(this._eventInfo);
258
+ return this._eventInfo.hasRenderTargetTextures;
259
+ }
260
+ /**
261
+ * Called during a dispose event
262
+ */
263
+ set onDispose(callback) {
264
+ if (this._onDisposeObserver) {
265
+ this.onDisposeObservable.remove(this._onDisposeObserver);
266
+ }
267
+ this._onDisposeObserver = this.onDisposeObservable.add(callback);
268
+ }
269
+ /**
270
+ * An event triggered when the material is bound
271
+ */
272
+ get onBindObservable() {
273
+ if (!this._onBindObservable) {
274
+ this._onBindObservable = new Observable();
275
+ }
276
+ return this._onBindObservable;
277
+ }
278
+ /**
279
+ * Called during a bind event
280
+ */
281
+ set onBind(callback) {
282
+ if (this._onBindObserver) {
283
+ this.onBindObservable.remove(this._onBindObserver);
284
+ }
285
+ this._onBindObserver = this.onBindObservable.add(callback);
286
+ }
287
+ /**
288
+ * An event triggered when the material is unbound
289
+ */
290
+ get onUnBindObservable() {
291
+ if (!this._onUnBindObservable) {
292
+ this._onUnBindObservable = new Observable();
293
+ }
294
+ return this._onUnBindObservable;
295
+ }
296
+ /**
297
+ * An event triggered when the effect is (re)created
298
+ */
299
+ get onEffectCreatedObservable() {
300
+ if (!this._onEffectCreatedObservable) {
301
+ this._onEffectCreatedObservable = new Observable();
302
+ }
303
+ return this._onEffectCreatedObservable;
304
+ }
305
+ /**
306
+ * Sets the value of the alpha mode.
307
+ *
308
+ * | Value | Type | Description |
309
+ * | --- | --- | --- |
310
+ * | 0 | ALPHA_DISABLE | |
311
+ * | 1 | ALPHA_ADD | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + DEST, ALPHA=DEST_ALPHA |
312
+ * | 2 | ALPHA_COMBINE | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + (1 - SRC_ALPHA) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
313
+ * | 3 | ALPHA_SUBTRACT | Defines that alpha blending is COLOR=(1 - SRC) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
314
+ * | 4 | ALPHA_MULTIPLY | Defines that alpha blending is COLOR=DEST * SRC, ALPHA=SRC_ALPHA + DEST_ALPHA |
315
+ * | 5 | ALPHA_MAXIMIZED | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + (1 - SRC) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
316
+ * | 6 | ALPHA_ONEONE | Defines that alpha blending is COLOR=SRC + DEST, ALPHA=DEST_ALPHA |
317
+ * | 7 | ALPHA_PREMULTIPLIED | Defines that alpha blending is COLOR=SRC + (1 - SRC_ALPHA) * DEST, ALPHA=SRC_ALPHA + DEST_ALPHA |
318
+ * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | Defines that alpha blending is COLOR=SRC + (1 - SRC_ALPHA) * DEST, ALPHA=SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
319
+ * | 9 | ALPHA_INTERPOLATE | Defines that alpha blending is COLOR=CST * SRC + (1 - CST) * DEST, ALPHA=CST_ALPHA * SRC + (1 - CST_ALPHA) * DEST_ALPHA |
320
+ * | 10 | ALPHA_SCREENMODE | Defines that alpha blending is COLOR=SRC + (1 - SRC) * DEST, ALPHA=SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
321
+ * | 11 | ALPHA_ONEONE_ONEONE | Defines that alpha blending is COLOR=SRC + DST, ALPHA=SRC_ALPHA + DEST_ALPHA |
322
+ * | 12 | ALPHA_ALPHATOCOLOR | Defines that alpha blending is COLOR=DEST_ALPHA * SRC + DST, ALPHA=0 |
323
+ * | 13 | ALPHA_REVERSEONEMINUS | Defines that alpha blending is COLOR=(1 - DEST) * SRC + (1 - SRC) * DEST, ALPHA=(1 - DEST_ALPHA) * SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
324
+ * | 14 | ALPHA_SRC_DSTONEMINUSSRCALPHA | Defines that alpha blending is ALPHA=SRC + (1 - SRC ALPHA) * DEST, ALPHA=SRC_ALPHA + (1 - SRC ALPHA) * DEST_ALPHA |
325
+ * | 15 | ALPHA_ONEONE_ONEZERO | Defines that alpha blending is COLOR=SRC + DST, ALPHA=SRC_ALPHA |
326
+ * | 16 | ALPHA_EXCLUSION | Defines that alpha blending is COLOR=(1 - DEST) * SRC + (1 - SRC) * DEST, ALPHA=DEST_ALPHA |
327
+ * | 17 | ALPHA_LAYER_ACCUMULATE | Defines that alpha blending is COLOR=SRC_ALPHA * SRC + (1 - SRC ALPHA) * DEST, ALPHA=SRC_ALPHA + (1 - SRC_ALPHA) * DEST_ALPHA |
328
+ * | 18 | ALPHA_MIN | Defines that alpha blending is COLOR=MIN(SRC, DEST), ALPHA=MIN(SRC_ALPHA, DEST_ALPHA) |
329
+ * | 19 | ALPHA_MAX | Defines that alpha blending is COLOR=MAX(SRC, DEST), ALPHA=MAX(SRC_ALPHA, DEST_ALPHA) |
330
+ * | 20 | ALPHA_DUAL_SRC0_ADD_SRC1xDST | Defines that alpha blending uses dual source blending and is COLOR=SRC + SRC1 * DEST, ALPHA=DST_ALPHA |
331
+ *
332
+ */
333
+ set alphaMode(value) {
334
+ if (this._alphaMode[0] === value) {
335
+ return;
336
+ }
337
+ this._alphaMode[0] = value;
338
+ this.markAsDirty(_a.TextureDirtyFlag);
339
+ }
340
+ /**
341
+ * Gets the value of the alpha mode
342
+ */
343
+ get alphaMode() {
344
+ return this._alphaMode[0];
345
+ }
346
+ /**
347
+ * Gets the list of alpha modes (length greater than 1 for multi-targets)
348
+ */
349
+ get alphaModes() {
350
+ return this._alphaMode;
351
+ }
352
+ /**
353
+ * Sets the value of the alpha mode for a specific target index.
354
+ * @param value The alpha mode value to set.
355
+ * @param targetIndex The index of the target to set the alpha mode for. Defaults to 0.
356
+ */
357
+ setAlphaMode(value, targetIndex = 0) {
358
+ if (this._alphaMode[targetIndex] === value) {
359
+ return;
360
+ }
361
+ this._alphaMode[targetIndex] = value;
362
+ this.markAsDirty(_a.TextureDirtyFlag);
363
+ }
364
+ /**
365
+ * Sets the need depth pre-pass value
366
+ */
367
+ set needDepthPrePass(value) {
368
+ if (this._needDepthPrePass === value) {
369
+ return;
370
+ }
371
+ this._needDepthPrePass = value;
372
+ if (this._needDepthPrePass) {
373
+ this.checkReadyOnEveryCall = true;
374
+ }
375
+ }
376
+ /**
377
+ * Gets the depth pre-pass value
378
+ */
379
+ get needDepthPrePass() {
380
+ return this._needDepthPrePass;
381
+ }
382
+ /**
383
+ * Can this material render to prepass
384
+ */
385
+ get isPrePassCapable() {
386
+ return false;
387
+ }
388
+ /**
389
+ * Sets the state for enabling fog
390
+ */
391
+ set fogEnabled(value) {
392
+ if (this._fogEnabled === value) {
393
+ return;
394
+ }
395
+ this._fogEnabled = value;
396
+ this.markAsDirty(_a.MiscDirtyFlag);
397
+ }
398
+ /**
399
+ * Gets the value of the fog enabled state
400
+ */
401
+ get fogEnabled() {
402
+ return this._fogEnabled;
403
+ }
404
+ get wireframe() {
405
+ switch (this._fillMode) {
406
+ case _a.WireFrameFillMode:
407
+ case _a.LineListDrawMode:
408
+ case _a.LineLoopDrawMode:
409
+ case _a.LineStripDrawMode:
410
+ return true;
411
+ }
412
+ return this._scene.forceWireframe;
413
+ }
414
+ /**
415
+ * Sets the state of wireframe mode
416
+ */
417
+ set wireframe(value) {
418
+ this.fillMode = value ? _a.WireFrameFillMode : _a.TriangleFillMode;
419
+ }
420
+ /**
421
+ * Gets the value specifying if point clouds are enabled
422
+ */
423
+ get pointsCloud() {
424
+ switch (this._fillMode) {
425
+ case _a.PointFillMode:
426
+ case _a.PointListDrawMode:
427
+ return true;
428
+ }
429
+ return this._scene.forcePointsCloud;
430
+ }
431
+ /**
432
+ * Sets the state of point cloud mode
433
+ */
434
+ set pointsCloud(value) {
435
+ this.fillMode = value ? _a.PointFillMode : _a.TriangleFillMode;
436
+ }
437
+ /**
438
+ * Gets the material fill mode
439
+ */
440
+ get fillMode() {
441
+ return this._fillMode;
442
+ }
443
+ /**
444
+ * Sets the material fill mode
445
+ */
446
+ set fillMode(value) {
447
+ if (this._fillMode === value) {
448
+ return;
449
+ }
450
+ this._fillMode = value;
451
+ this.markAsDirty(_a.MiscDirtyFlag);
452
+ }
453
+ /**
454
+ * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
455
+ * You can try switching to logarithmic depth.
456
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/logarithmicDepthBuffer
457
+ */
458
+ get useLogarithmicDepth() {
459
+ return this._useLogarithmicDepth;
460
+ }
461
+ set useLogarithmicDepth(value) {
462
+ const fragmentDepthSupported = this.getScene().getEngine().getCaps().fragmentDepthSupported;
463
+ if (value && !fragmentDepthSupported) {
464
+ Logger.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it.");
465
+ }
466
+ this._useLogarithmicDepth = value && fragmentDepthSupported;
467
+ this._markAllSubMeshesAsMiscDirty();
468
+ }
469
+ /**
470
+ * Gets or sets the vertex output invariant state
471
+ * Setting this property to true will force the shader compiler to disable some optimization to make sure the vertex output is always calculated
472
+ * the same way across different compilation units.
473
+ * You may need to enable this option if you are seeing some depth artifacts when using a depth pre-pass, for e.g.
474
+ * Note that this may have an impact on performance, so leave this option disabled if not needed.
475
+ */
476
+ get isVertexOutputInvariant() {
477
+ return this._isVertexOutputInvariant;
478
+ }
479
+ set isVertexOutputInvariant(value) {
480
+ if (this._isVertexOutputInvariant === value) {
481
+ return;
482
+ }
483
+ this._isVertexOutputInvariant = value;
484
+ this._markAllSubMeshesAsMiscDirty();
485
+ }
486
+ /** @internal */
487
+ _getDrawWrapper() {
488
+ return this._drawWrapper;
489
+ }
490
+ /**
491
+ * @internal
492
+ */
493
+ _setDrawWrapper(drawWrapper) {
494
+ this._drawWrapper = drawWrapper;
495
+ }
496
+ /**
497
+ * Creates a material instance
498
+ * @param name defines the name of the material
499
+ * @param scene defines the scene to reference
500
+ * @param doNotAdd specifies if the material should be added to the scene
501
+ * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
502
+ */
503
+ constructor(name, scene, doNotAdd, forceGLSL = false) {
504
+ /**
505
+ * Custom callback helping to override the default shader used in the material.
506
+ */
507
+ this.customShaderNameResolve = __runInitializers(this, _instanceExtraInitializers);
508
+ /**
509
+ * Custom shadow depth material to use for shadow rendering instead of the in-built one
510
+ */
511
+ this.shadowDepthWrapper = null;
512
+ /**
513
+ * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
514
+ * This means that the material can keep using a previous shader while a new one is being compiled.
515
+ * This is mostly used when shader parallel compilation is supported (true by default)
516
+ */
517
+ this.allowShaderHotSwapping = true;
518
+ /** Shader language used by the material */
519
+ this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;
520
+ this._forceGLSL = false;
521
+ this._useVertexPulling = false;
522
+ this._isDisposed = false;
523
+ /**
524
+ * The ID of the material
525
+ */
526
+ this.id = __runInitializers(this, _id_initializers, void 0);
527
+ /**
528
+ * Gets or sets the unique id of the material
529
+ */
530
+ this.uniqueId = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _uniqueId_initializers, void 0));
531
+ /** @internal */
532
+ this._loadedUniqueId = __runInitializers(this, _uniqueId_extraInitializers);
533
+ /**
534
+ * The name of the material
535
+ */
536
+ this.name = __runInitializers(this, _name_initializers, void 0);
537
+ /**
538
+ * Gets or sets user defined metadata
539
+ */
540
+ this.metadata = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _metadata_initializers, null));
541
+ /** @internal */
542
+ this._internalMetadata = __runInitializers(this, _metadata_extraInitializers);
543
+ /**
544
+ * For internal use only. Please do not use.
545
+ */
546
+ this.reservedDataStore = null;
547
+ /**
548
+ * Specifies if the ready state should be checked on each call
549
+ */
550
+ this.checkReadyOnEveryCall = __runInitializers(this, _checkReadyOnEveryCall_initializers, false);
551
+ /**
552
+ * Specifies if the ready state should be checked once
553
+ */
554
+ this.checkReadyOnlyOnce = (__runInitializers(this, _checkReadyOnEveryCall_extraInitializers), __runInitializers(this, _checkReadyOnlyOnce_initializers, false));
555
+ /**
556
+ * The state of the material
557
+ */
558
+ this.state = (__runInitializers(this, _checkReadyOnlyOnce_extraInitializers), __runInitializers(this, _state_initializers, ""));
559
+ /**
560
+ * The alpha value of the material
561
+ */
562
+ this._alpha = (__runInitializers(this, _state_extraInitializers), __runInitializers(this, __alpha_initializers, 1.0));
563
+ /**
564
+ * List of inspectable custom properties (used by the Inspector)
565
+ * @see https://doc.babylonjs.com/toolsAndResources/inspector#extensibility
566
+ */
567
+ this.inspectableCustomProperties = __runInitializers(this, __alpha_extraInitializers);
568
+ /**
569
+ * Specifies if back face culling is enabled
570
+ */
571
+ this._backFaceCulling = __runInitializers(this, __backFaceCulling_initializers, true);
572
+ this._textureRepetitionMode = (__runInitializers(this, __backFaceCulling_extraInitializers), __runInitializers(this, __textureRepetitionMode_initializers, 0));
573
+ /**
574
+ * Parameters for the hex tiling texture repetition mode (TEXTURE_REPETITION_HEX_TILING).
575
+ * x = rotation strength (0..1, default 1.0) — how much each hex tile is rotated.
576
+ * y = fall-off contrast (0..1, default 0.6) — how much luminance affects blending weight at tile borders.
577
+ * z = exponent (1..20, default 7.0) — controls the sharpness of weight falloff between tiles.
578
+ * w = contrast (0..1, default 0.5) — boost blending contrast via Gain3 (0.5 = neutral, >0.5 = higher contrast).
579
+ * @see https://jcgt.org/published/0011/03/05/
580
+ */
581
+ this.textureRepetitionHexTilingParams = (__runInitializers(this, __textureRepetitionMode_extraInitializers), __runInitializers(this, _textureRepetitionHexTilingParams_initializers, [1.0, 0.6, 7.0, 0.5]));
582
+ /**
583
+ * Specifies if back or front faces should be culled (when culling is enabled)
584
+ */
585
+ this._cullBackFaces = (__runInitializers(this, _textureRepetitionHexTilingParams_extraInitializers), __runInitializers(this, __cullBackFaces_initializers, true));
586
+ this._blockDirtyMechanism = (__runInitializers(this, __cullBackFaces_extraInitializers), false);
587
+ /**
588
+ * Stores the value for side orientation
589
+ */
590
+ this.sideOrientation = __runInitializers(this, _sideOrientation_initializers, null);
591
+ /**
592
+ * Callback triggered when the material is compiled
593
+ */
594
+ this.onCompiled = (__runInitializers(this, _sideOrientation_extraInitializers), null);
595
+ /**
596
+ * Callback triggered when an error occurs
597
+ */
598
+ this.onError = null;
599
+ /**
600
+ * Callback triggered to get the render target textures
601
+ */
602
+ this.getRenderTargetTextures = null;
603
+ /**
604
+ * Specifies if the material should be serialized
605
+ */
606
+ this.doNotSerialize = false;
607
+ /**
608
+ * @internal
609
+ */
610
+ this._storeEffectOnSubMeshes = false;
611
+ /**
612
+ * Stores the animations for the material
613
+ */
614
+ this.animations = null;
615
+ /**
616
+ * An event triggered when the material is disposed
617
+ */
618
+ this.onDisposeObservable = new Observable();
619
+ /**
620
+ * An observer which watches for dispose events
621
+ */
622
+ this._onDisposeObserver = null;
623
+ this._onUnBindObservable = null;
624
+ /**
625
+ * An observer which watches for bind events
626
+ */
627
+ this._onBindObserver = null;
628
+ /**
629
+ * Stores the value of the alpha mode
630
+ */
631
+ this._alphaMode = __runInitializers(this, __alphaMode_initializers, [2]);
632
+ /**
633
+ * Stores the state of the need depth pre-pass value
634
+ */
635
+ this._needDepthPrePass = (__runInitializers(this, __alphaMode_extraInitializers), __runInitializers(this, __needDepthPrePass_initializers, false));
636
+ /**
637
+ * Specifies if depth writing should be disabled
638
+ */
639
+ this.disableDepthWrite = (__runInitializers(this, __needDepthPrePass_extraInitializers), __runInitializers(this, _disableDepthWrite_initializers, false));
640
+ /**
641
+ * Specifies if color writing should be disabled
642
+ */
643
+ this.disableColorWrite = (__runInitializers(this, _disableDepthWrite_extraInitializers), __runInitializers(this, _disableColorWrite_initializers, false));
644
+ /**
645
+ * Specifies if depth writing should be forced
646
+ */
647
+ this.forceDepthWrite = (__runInitializers(this, _disableColorWrite_extraInitializers), __runInitializers(this, _forceDepthWrite_initializers, false));
648
+ /**
649
+ * Specifies the depth function that should be used. 0 means the default engine function
650
+ */
651
+ this.depthFunction = (__runInitializers(this, _forceDepthWrite_extraInitializers), __runInitializers(this, _depthFunction_initializers, 0));
652
+ /**
653
+ * Specifies if there should be a separate pass for culling
654
+ */
655
+ this.separateCullingPass = (__runInitializers(this, _depthFunction_extraInitializers), __runInitializers(this, _separateCullingPass_initializers, false));
656
+ /**
657
+ * Stores the state specifying if fog should be enabled
658
+ */
659
+ this._fogEnabled = (__runInitializers(this, _separateCullingPass_extraInitializers), __runInitializers(this, __fogEnabled_initializers, true));
660
+ /**
661
+ * Stores the size of points
662
+ */
663
+ this.pointSize = (__runInitializers(this, __fogEnabled_extraInitializers), __runInitializers(this, _pointSize_initializers, 1.0));
664
+ /**
665
+ * Stores the z offset Factor value
666
+ */
667
+ this.zOffset = (__runInitializers(this, _pointSize_extraInitializers), __runInitializers(this, _zOffset_initializers, 0));
668
+ /**
669
+ * Stores the z offset Units value
670
+ */
671
+ this.zOffsetUnits = (__runInitializers(this, _zOffset_extraInitializers), __runInitializers(this, _zOffsetUnits_initializers, 0));
672
+ /**
673
+ * Gets or sets the active clipplane 1
674
+ */
675
+ this.clipPlane = __runInitializers(this, _zOffsetUnits_extraInitializers);
676
+ /**
677
+ * Gives access to the stencil properties of the material
678
+ */
679
+ this.stencil = new MaterialStencilState();
680
+ this._isVertexOutputInvariant = __runInitializers(this, __isVertexOutputInvariant_initializers, _a.ForceVertexOutputInvariant);
681
+ /**
682
+ * @internal
683
+ * Stores the effects for the material
684
+ */
685
+ this._materialContext = __runInitializers(this, __isVertexOutputInvariant_extraInitializers);
686
+ /**
687
+ * Specifies if uniform buffers should be used
688
+ */
689
+ this._useUBO = false;
690
+ /**
691
+ * Stores the fill mode state
692
+ */
693
+ this._fillMode = _a.TriangleFillMode;
694
+ /**
695
+ * Specifies if the depth write state should be cached
696
+ */
697
+ this._cachedDepthWriteState = false;
698
+ /**
699
+ * Specifies if the color write state should be cached
700
+ */
701
+ this._cachedColorWriteState = false;
702
+ /**
703
+ * Specifies if the depth function state should be cached
704
+ */
705
+ this._cachedDepthFunctionState = 0;
706
+ /** @internal */
707
+ this._indexInSceneMaterialArray = -1;
708
+ /** @internal */
709
+ this.meshMap = null;
710
+ /** @internal */
711
+ this._parentContainer = null;
712
+ /** @internal */
713
+ this._uniformBufferLayoutBuilt = false;
714
+ this._eventInfo = {}; // will be initialized before each event notification
715
+ /** @internal */
716
+ this._callbackPluginEventGeneric = () => void 0;
717
+ /** @internal */
718
+ this._callbackPluginEventIsReadyForSubMesh = () => void 0;
719
+ /** @internal */
720
+ this._callbackPluginEventPrepareDefines = () => void 0;
721
+ /** @internal */
722
+ this._callbackPluginEventPrepareDefinesBeforeAttributes = () => void 0;
723
+ /** @internal */
724
+ this._callbackPluginEventHardBindForSubMesh = () => void 0;
725
+ /** @internal */
726
+ this._callbackPluginEventBindForSubMesh = () => void 0;
727
+ /** @internal */
728
+ this._callbackPluginEventHasRenderTargetTextures = () => void 0;
729
+ /** @internal */
730
+ this._callbackPluginEventFillRenderTargetTextures = () => void 0;
731
+ /**
732
+ * The transparency mode of the material.
733
+ */
734
+ this._transparencyMode = null;
735
+ this.name = name;
736
+ const setScene = scene || EngineStore.LastCreatedScene;
737
+ if (!setScene) {
738
+ return;
739
+ }
740
+ this._scene = setScene;
741
+ this._dirtyCallbacks = {};
742
+ this._forceGLSL = forceGLSL;
743
+ this._dirtyCallbacks[1] = this._markAllSubMeshesAsTexturesDirty.bind(this);
744
+ this._dirtyCallbacks[2] = this._markAllSubMeshesAsLightsDirty.bind(this);
745
+ this._dirtyCallbacks[4] = this._markAllSubMeshesAsFresnelDirty.bind(this);
746
+ this._dirtyCallbacks[8] = this._markAllSubMeshesAsAttributesDirty.bind(this);
747
+ this._dirtyCallbacks[16] = this._markAllSubMeshesAsMiscDirty.bind(this);
748
+ this._dirtyCallbacks[32] = this._markAllSubMeshesAsPrePassDirty.bind(this);
749
+ this._dirtyCallbacks[127] = this._markAllSubMeshesAsAllDirty.bind(this);
750
+ this.id = name || Tools.RandomId();
751
+ this.uniqueId = this._scene.getUniqueId();
752
+ this._materialContext = this._scene.getEngine().createMaterialContext();
753
+ this._drawWrapper = new DrawWrapper(this._scene.getEngine(), false);
754
+ this._drawWrapper.materialContext = this._materialContext;
755
+ this._uniformBuffer = new UniformBuffer(this._scene.getEngine(), undefined, undefined, name);
756
+ this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
757
+ this._createUniformBuffer();
758
+ if (!doNotAdd) {
759
+ this._scene.addMaterial(this);
760
+ }
761
+ if (this._scene.useMaterialMeshMap) {
762
+ this.meshMap = {};
763
+ }
764
+ _a.OnEventObservable.notifyObservers(this, 1 /* MaterialPluginEvent.Created */);
765
+ }
766
+ /** @internal */
767
+ _createUniformBuffer() {
768
+ const engine = this.getScene().getEngine();
769
+ this._uniformBuffer?.dispose();
770
+ if (engine.isWebGPU && !this._forceGLSL) {
771
+ // Switch main UBO to non UBO to connect to leftovers UBO in webgpu
772
+ this._uniformBuffer = new UniformBuffer(engine, undefined, undefined, this.name, true);
773
+ this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;
774
+ }
775
+ else {
776
+ this._uniformBuffer = new UniformBuffer(this._scene.getEngine(), undefined, undefined, this.name);
777
+ }
778
+ this._uniformBufferLayoutBuilt = false;
779
+ }
780
+ /**
781
+ * Returns a string representation of the current material
782
+ * @param fullDetails defines a boolean indicating which levels of logging is desired
783
+ * @returns a string with material information
784
+ */
785
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
786
+ toString(fullDetails) {
787
+ const ret = "Name: " + this.name;
788
+ return ret;
789
+ }
790
+ /**
791
+ * Gets the class name of the material
792
+ * @returns a string with the class name of the material
793
+ */
794
+ getClassName() {
795
+ return "Material";
796
+ }
797
+ /** @internal */
798
+ get _isMaterial() {
328
799
  return true;
329
- }
330
- return this._scene.forceWireframe;
331
- }
332
- /**
333
- * Sets the state of wireframe mode
334
- */
335
- set wireframe(value) {
336
- this.fillMode = value ? Material.WireFrameFillMode : Material.TriangleFillMode;
337
- }
338
- /**
339
- * Gets the value specifying if point clouds are enabled
340
- */
341
- get pointsCloud() {
342
- switch (this._fillMode) {
343
- case Material.PointFillMode:
344
- case Material.PointListDrawMode:
800
+ }
801
+ /**
802
+ * Specifies if updates for the material been locked
803
+ */
804
+ get isFrozen() {
805
+ return this.checkReadyOnlyOnce;
806
+ }
807
+ /**
808
+ * Locks updates for the material.
809
+ *
810
+ * Note: while a material is frozen, the scene can still rebind it at least
811
+ * once per camera render (and again whenever another material was bound in
812
+ * between). What can be skipped while the frozen material stays cached are
813
+ * per-mesh updates performed during a rebind.
814
+ *
815
+ * This includes per-mesh morph target influences. If the same frozen
816
+ * material is shared across several meshes that each have different
817
+ * per-mesh morph influences, only the mesh that triggers the rebind updates
818
+ * those values. Other meshes rendered afterward with the same cached frozen
819
+ * material may reuse stale influences and render with the wrong values.
820
+ *
821
+ * For that scenario either keep the material unfrozen, clone the material
822
+ * per mesh and freeze each clone, or `unfreeze()` before changing
823
+ * influences and `freeze()` again afterwards.
824
+ */
825
+ freeze() {
826
+ this.markDirty();
827
+ this.checkReadyOnlyOnce = true;
828
+ }
829
+ /**
830
+ * Unlocks updates for the material
831
+ */
832
+ unfreeze() {
833
+ this.markDirty();
834
+ this.checkReadyOnlyOnce = false;
835
+ }
836
+ /**
837
+ * Specifies if the material is ready to be used
838
+ * @param mesh defines the mesh to check
839
+ * @param useInstances specifies if instances should be used
840
+ * @returns a boolean indicating if the material is ready to be used
841
+ */
842
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
843
+ isReady(mesh, useInstances) {
345
844
  return true;
346
- }
347
- return this._scene.forcePointsCloud;
348
- }
349
- /**
350
- * Sets the state of point cloud mode
351
- */
352
- set pointsCloud(value) {
353
- this.fillMode = value ? Material.PointFillMode : Material.TriangleFillMode;
354
- }
355
- /**
356
- * Gets the material fill mode
357
- */
358
- get fillMode() {
359
- return this._fillMode;
360
- }
361
- /**
362
- * Sets the material fill mode
363
- */
364
- set fillMode(value) {
365
- if (this._fillMode === value) {
366
- return;
367
- }
368
- this._fillMode = value;
369
- this.markAsDirty(Material.MiscDirtyFlag);
370
- }
371
- /**
372
- * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
373
- * You can try switching to logarithmic depth.
374
- * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/logarithmicDepthBuffer
375
- */
376
- get useLogarithmicDepth() {
377
- return this._useLogarithmicDepth;
378
- }
379
- set useLogarithmicDepth(value) {
380
- const fragmentDepthSupported = this.getScene().getEngine().getCaps().fragmentDepthSupported;
381
- if (value && !fragmentDepthSupported) {
382
- Logger.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it.");
383
- }
384
- this._useLogarithmicDepth = value && fragmentDepthSupported;
385
- this._markAllSubMeshesAsMiscDirty();
386
- }
387
- /**
388
- * Gets or sets the vertex output invariant state
389
- * Setting this property to true will force the shader compiler to disable some optimization to make sure the vertex output is always calculated
390
- * the same way across different compilation units.
391
- * You may need to enable this option if you are seeing some depth artifacts when using a depth pre-pass, for e.g.
392
- * Note that this may have an impact on performance, so leave this option disabled if not needed.
393
- */
394
- get isVertexOutputInvariant() {
395
- return this._isVertexOutputInvariant;
396
- }
397
- set isVertexOutputInvariant(value) {
398
- if (this._isVertexOutputInvariant === value) {
399
- return;
400
- }
401
- this._isVertexOutputInvariant = value;
402
- this._markAllSubMeshesAsMiscDirty();
403
- }
404
- /** @internal */
405
- _getDrawWrapper() {
406
- return this._drawWrapper;
407
- }
408
- /**
409
- * @internal
410
- */
411
- _setDrawWrapper(drawWrapper) {
412
- this._drawWrapper = drawWrapper;
413
- }
414
- /**
415
- * Creates a material instance
416
- * @param name defines the name of the material
417
- * @param scene defines the scene to reference
418
- * @param doNotAdd specifies if the material should be added to the scene
419
- * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
420
- */
421
- constructor(name, scene, doNotAdd, forceGLSL = false) {
422
- /**
423
- * Custom shadow depth material to use for shadow rendering instead of the in-built one
424
- */
425
- this.shadowDepthWrapper = null;
426
- /**
427
- * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
428
- * This means that the material can keep using a previous shader while a new one is being compiled.
429
- * This is mostly used when shader parallel compilation is supported (true by default)
430
- */
431
- this.allowShaderHotSwapping = true;
432
- /** Shader language used by the material */
433
- this._shaderLanguage = 0 /* ShaderLanguage.GLSL */;
434
- this._forceGLSL = false;
435
- this._useVertexPulling = false;
436
- this._isDisposed = false;
437
- /**
438
- * Gets or sets user defined metadata
439
- */
440
- this.metadata = null;
441
- /**
442
- * For internal use only. Please do not use.
443
- */
444
- this.reservedDataStore = null;
445
- /**
446
- * Specifies if the ready state should be checked on each call
447
- */
448
- this.checkReadyOnEveryCall = false;
449
- /**
450
- * Specifies if the ready state should be checked once
451
- */
452
- this.checkReadyOnlyOnce = false;
453
- /**
454
- * The state of the material
455
- */
456
- this.state = "";
457
- /**
458
- * The alpha value of the material
459
- */
460
- this._alpha = 1.0;
461
- /**
462
- * Specifies if back face culling is enabled
463
- */
464
- this._backFaceCulling = true;
465
- this._textureRepetitionMode = 0;
845
+ }
846
+ /**
847
+ * Specifies that the submesh is ready to be used
848
+ * @param mesh defines the mesh to check
849
+ * @param subMesh defines which submesh to check
850
+ * @param useInstances specifies that instances should be used
851
+ * @returns a boolean indicating that the submesh is ready or not
852
+ */
853
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
854
+ isReadyForSubMesh(mesh, subMesh, useInstances) {
855
+ const defines = subMesh.materialDefines;
856
+ if (!defines) {
857
+ return false;
858
+ }
859
+ this._eventInfo.isReadyForSubMesh = true;
860
+ this._eventInfo.defines = defines;
861
+ this._callbackPluginEventIsReadyForSubMesh(this._eventInfo);
862
+ return this._eventInfo.isReadyForSubMesh;
863
+ }
864
+ /**
865
+ * Returns the material effect
866
+ * @returns the effect associated with the material
867
+ */
868
+ getEffect() {
869
+ return this._drawWrapper.effect;
870
+ }
871
+ /**
872
+ * Returns the current scene
873
+ * @returns a Scene
874
+ */
875
+ getScene() {
876
+ return this._scene;
877
+ }
878
+ /** @internal */
879
+ _getEffectiveOrientation(mesh) {
880
+ return this.sideOrientation !== null ? this.sideOrientation : mesh.sideOrientation;
881
+ }
882
+ /**
883
+ * Gets the current transparency mode.
884
+ */
885
+ get transparencyMode() {
886
+ return this._transparencyMode;
887
+ }
888
+ /**
889
+ * Sets the transparency mode of the material.
890
+ *
891
+ * | Value | Type | Description |
892
+ * | ----- | ----------------------------------- | ----------- |
893
+ * | 0 | OPAQUE | |
894
+ * | 1 | ALPHATEST | |
895
+ * | 2 | ALPHABLEND | |
896
+ * | 3 | ALPHATESTANDBLEND | |
897
+ *
898
+ */
899
+ set transparencyMode(value) {
900
+ if (this._transparencyMode === value) {
901
+ return;
902
+ }
903
+ this._transparencyMode = value;
904
+ this._markAllSubMeshesAsTexturesAndMiscDirty();
905
+ }
906
+ get _hasTransparencyMode() {
907
+ return this._transparencyMode != null;
908
+ }
909
+ get _transparencyModeIsBlend() {
910
+ return this._transparencyMode === _a.MATERIAL_ALPHABLEND || this._transparencyMode === _a.MATERIAL_ALPHATESTANDBLEND;
911
+ }
912
+ get _transparencyModeIsTest() {
913
+ return this._transparencyMode === _a.MATERIAL_ALPHATEST || this._transparencyMode === _a.MATERIAL_ALPHATESTANDBLEND;
914
+ }
915
+ /**
916
+ * Returns true if alpha blending should be disabled.
917
+ */
918
+ get _disableAlphaBlending() {
919
+ return this._transparencyMode === _a.MATERIAL_OPAQUE || this._transparencyMode === _a.MATERIAL_ALPHATEST;
920
+ }
921
+ /**
922
+ * Specifies whether or not this material should be rendered in alpha blend mode.
923
+ * @returns a boolean specifying if alpha blending is needed
924
+ * @deprecated Please use needAlphaBlendingForMesh instead
925
+ */
926
+ needAlphaBlending() {
927
+ if (this._hasTransparencyMode) {
928
+ return this._transparencyModeIsBlend;
929
+ }
930
+ if (this._disableAlphaBlending) {
931
+ return false;
932
+ }
933
+ return this.alpha < 1.0;
934
+ }
935
+ /**
936
+ * Specifies if the mesh will require alpha blending
937
+ * @param mesh defines the mesh to check
938
+ * @returns a boolean specifying if alpha blending is needed for the mesh
939
+ */
940
+ needAlphaBlendingForMesh(mesh) {
941
+ if (this._hasTransparencyMode) {
942
+ return this._transparencyModeIsBlend;
943
+ }
944
+ if (mesh.visibility < 1.0) {
945
+ return true;
946
+ }
947
+ if (this._disableAlphaBlending) {
948
+ return false;
949
+ }
950
+ return mesh.hasVertexAlpha || this.needAlphaBlending();
951
+ }
952
+ /**
953
+ * Specifies whether or not this material should be rendered in alpha test mode.
954
+ * @returns a boolean specifying if an alpha test is needed.
955
+ * @deprecated Please use needAlphaTestingForMesh instead
956
+ */
957
+ needAlphaTesting() {
958
+ if (this._hasTransparencyMode) {
959
+ return this._transparencyModeIsTest;
960
+ }
961
+ return false;
962
+ }
963
+ /**
964
+ * Specifies if material alpha testing should be turned on for the mesh
965
+ * @param mesh defines the mesh to check
966
+ * @returns a boolean specifying if alpha testing should be turned on for the mesh
967
+ */
968
+ needAlphaTestingForMesh(mesh) {
969
+ if (this._hasTransparencyMode) {
970
+ return this._transparencyModeIsTest;
971
+ }
972
+ return !this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting();
973
+ }
974
+ /**
975
+ * Gets the texture used for the alpha test
976
+ * @returns the texture to use for alpha testing
977
+ */
978
+ getAlphaTestTexture() {
979
+ return null;
980
+ }
981
+ /**
982
+ * Marks the material to indicate that it needs to be re-calculated
983
+ * @param forceMaterialDirty - Forces the material to be marked as dirty for all components (same as this.markAsDirty(Material.AllDirtyFlag)). You should use this flag if the material is frozen and you want to force a recompilation.
984
+ */
985
+ markDirty(forceMaterialDirty = false) {
986
+ const meshes = this.getScene().meshes;
987
+ for (const mesh of meshes) {
988
+ if (!mesh.subMeshes) {
989
+ continue;
990
+ }
991
+ for (const subMesh of mesh.subMeshes) {
992
+ if (subMesh.getMaterial() !== this) {
993
+ continue;
994
+ }
995
+ for (const drawWrapper of subMesh._drawWrappers) {
996
+ if (!drawWrapper) {
997
+ continue;
998
+ }
999
+ if (this._materialContext === drawWrapper.materialContext) {
1000
+ drawWrapper._wasPreviouslyReady = false;
1001
+ drawWrapper._wasPreviouslyUsingInstances = null;
1002
+ drawWrapper._forceRebindOnNextCall = forceMaterialDirty;
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+ if (forceMaterialDirty) {
1008
+ this.markAsDirty(_a.AllDirtyFlag);
1009
+ }
1010
+ }
1011
+ /**
1012
+ * @internal
1013
+ */
1014
+ _preBind(effect, overrideOrientation = null) {
1015
+ const engine = this._scene.getEngine();
1016
+ const orientation = overrideOrientation == null ? this.sideOrientation : overrideOrientation;
1017
+ const reverse = orientation === _a.ClockWiseSideOrientation;
1018
+ const effectiveDrawWrapper = effect ? effect : this._getDrawWrapper();
1019
+ if (IsWrapper(effectiveDrawWrapper) && effectiveDrawWrapper.materialContext) {
1020
+ effectiveDrawWrapper.materialContext.useVertexPulling = this.useVertexPulling;
1021
+ }
1022
+ engine.enableEffect(effectiveDrawWrapper);
1023
+ engine.setState(this.backFaceCulling, this.zOffset, false, reverse, this._scene._mirroredCameraPosition ? !this.cullBackFaces : this.cullBackFaces, this.stencil, this.zOffsetUnits);
1024
+ return reverse;
1025
+ }
1026
+ /**
1027
+ * Binds the material to the mesh
1028
+ * @param world defines the world transformation matrix
1029
+ * @param mesh defines the mesh to bind the material to
1030
+ */
1031
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1032
+ bind(world, mesh) { }
1033
+ /**
1034
+ * Initializes the uniform buffer layout for the shader.
1035
+ */
1036
+ buildUniformLayout() {
1037
+ const ubo = this._uniformBuffer;
1038
+ this._eventInfo.ubo = ubo;
1039
+ this._callbackPluginEventGeneric(8 /* MaterialPluginEvent.PrepareUniformBuffer */, this._eventInfo);
1040
+ ubo.create();
1041
+ this._uniformBufferLayoutBuilt = true;
1042
+ }
1043
+ /**
1044
+ * Binds the submesh to the material
1045
+ * @param world defines the world transformation matrix
1046
+ * @param mesh defines the mesh containing the submesh
1047
+ * @param subMesh defines the submesh to bind the material to
1048
+ */
1049
+ bindForSubMesh(world, mesh, subMesh) {
1050
+ const drawWrapper = subMesh._drawWrapper;
1051
+ this._eventInfo.subMesh = subMesh;
1052
+ this._callbackPluginEventBindForSubMesh(this._eventInfo);
1053
+ drawWrapper._forceRebindOnNextCall = false;
1054
+ }
1055
+ /**
1056
+ * Binds the world matrix to the material
1057
+ * @param world defines the world transformation matrix
1058
+ */
1059
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1060
+ bindOnlyWorldMatrix(world) { }
1061
+ /**
1062
+ * Binds the view matrix to the effect
1063
+ * @param effect defines the effect to bind the view matrix to
1064
+ */
1065
+ bindView(effect) {
1066
+ if (!this._useUBO) {
1067
+ effect.setMatrix("view", this.getScene().getViewMatrix());
1068
+ }
1069
+ else {
1070
+ this._needToBindSceneUbo = true;
1071
+ }
1072
+ }
1073
+ /**
1074
+ * Binds the view projection and projection matrices to the effect
1075
+ * @param effect defines the effect to bind the view projection and projection matrices to
1076
+ */
1077
+ bindViewProjection(effect) {
1078
+ if (!this._useUBO) {
1079
+ effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
1080
+ effect.setMatrix("projection", this.getScene().getProjectionMatrix());
1081
+ effect.setMatrix("inverseProjection", this.getScene().getInverseProjectionMatrix());
1082
+ }
1083
+ else {
1084
+ this._needToBindSceneUbo = true;
1085
+ }
1086
+ }
1087
+ /**
1088
+ * Binds the view matrix to the effect
1089
+ * @param effect defines the effect to bind the view matrix to
1090
+ * @param variableName name of the shader variable that will hold the eye position
1091
+ */
1092
+ bindEyePosition(effect, variableName) {
1093
+ if (!this._useUBO) {
1094
+ this._scene.bindEyePosition(effect, variableName);
1095
+ }
1096
+ else {
1097
+ this._needToBindSceneUbo = true;
1098
+ }
1099
+ }
1100
+ /**
1101
+ * Processes to execute after binding the material to a mesh
1102
+ * @param mesh defines the rendered mesh
1103
+ * @param effect defines the effect used to bind the material
1104
+ * @param _subMesh defines the subMesh that the material has been bound for
1105
+ */
1106
+ _afterBind(mesh, effect = null, _subMesh) {
1107
+ this._scene._cachedMaterial = this;
1108
+ if (this._needToBindSceneUbo) {
1109
+ if (effect) {
1110
+ this._needToBindSceneUbo = false;
1111
+ BindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
1112
+ this._scene.finalizeSceneUbo();
1113
+ }
1114
+ }
1115
+ if (mesh) {
1116
+ this._scene._cachedVisibility = mesh.visibility;
1117
+ }
1118
+ else {
1119
+ this._scene._cachedVisibility = 1;
1120
+ }
1121
+ if (this._onBindObservable && mesh) {
1122
+ this._onBindObservable.notifyObservers(mesh);
1123
+ }
1124
+ if (this.disableDepthWrite) {
1125
+ const engine = this._scene.getEngine();
1126
+ this._cachedDepthWriteState = engine.getDepthWrite();
1127
+ engine.setDepthWrite(false);
1128
+ }
1129
+ if (this.disableColorWrite) {
1130
+ const engine = this._scene.getEngine();
1131
+ this._cachedColorWriteState = engine.getColorWrite();
1132
+ engine.setColorWrite(false);
1133
+ }
1134
+ if (this.depthFunction !== 0) {
1135
+ const engine = this._scene.getEngine();
1136
+ this._cachedDepthFunctionState = engine.getDepthFunction() || 0;
1137
+ engine.setDepthFunction(this.depthFunction);
1138
+ }
1139
+ }
1140
+ /**
1141
+ * Unbinds the material from the mesh
1142
+ */
1143
+ unbind() {
1144
+ this._scene.getSceneUniformBuffer().unbindEffect();
1145
+ if (this._onUnBindObservable) {
1146
+ this._onUnBindObservable.notifyObservers(this);
1147
+ }
1148
+ if (this.depthFunction !== 0) {
1149
+ const engine = this._scene.getEngine();
1150
+ engine.setDepthFunction(this._cachedDepthFunctionState);
1151
+ }
1152
+ if (this.disableDepthWrite) {
1153
+ const engine = this._scene.getEngine();
1154
+ engine.setDepthWrite(this._cachedDepthWriteState);
1155
+ }
1156
+ if (this.disableColorWrite) {
1157
+ const engine = this._scene.getEngine();
1158
+ engine.setColorWrite(this._cachedColorWriteState);
1159
+ }
1160
+ }
1161
+ /**
1162
+ * Returns the animatable textures.
1163
+ * @returns - Array of animatable textures.
1164
+ */
1165
+ getAnimatables() {
1166
+ this._eventInfo.animatables = [];
1167
+ this._callbackPluginEventGeneric(256 /* MaterialPluginEvent.GetAnimatables */, this._eventInfo);
1168
+ return this._eventInfo.animatables;
1169
+ }
1170
+ /**
1171
+ * Gets the active textures from the material
1172
+ * @returns an array of textures
1173
+ */
1174
+ getActiveTextures() {
1175
+ this._eventInfo.activeTextures = [];
1176
+ this._callbackPluginEventGeneric(512 /* MaterialPluginEvent.GetActiveTextures */, this._eventInfo);
1177
+ return this._eventInfo.activeTextures;
1178
+ }
1179
+ /**
1180
+ * Specifies if the material uses a texture
1181
+ * @param texture defines the texture to check against the material
1182
+ * @returns a boolean specifying if the material uses the texture
1183
+ */
1184
+ hasTexture(texture) {
1185
+ this._eventInfo.hasTexture = false;
1186
+ this._eventInfo.texture = texture;
1187
+ this._callbackPluginEventGeneric(1024 /* MaterialPluginEvent.HasTexture */, this._eventInfo);
1188
+ return this._eventInfo.hasTexture;
1189
+ }
1190
+ /**
1191
+ * Makes a duplicate of the material, and gives it a new name
1192
+ * @param name defines the new name for the duplicated material
1193
+ * @returns the cloned material
1194
+ */
1195
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1196
+ clone(name) {
1197
+ return null;
1198
+ }
1199
+ _clonePlugins(targetMaterial, rootUrl) {
1200
+ const serializationObject = {};
1201
+ // Create plugins in targetMaterial in case they don't exist
1202
+ this._serializePlugins(serializationObject);
1203
+ _a._ParsePlugins(serializationObject, targetMaterial, this._scene, rootUrl);
1204
+ // Copy the properties of the current plugins to the cloned material's plugins
1205
+ if (this.pluginManager) {
1206
+ for (const plugin of this.pluginManager._plugins) {
1207
+ const targetPlugin = targetMaterial.pluginManager.getPlugin(plugin.name);
1208
+ if (targetPlugin) {
1209
+ plugin.copyTo(targetPlugin);
1210
+ }
1211
+ }
1212
+ }
1213
+ }
1214
+ /**
1215
+ * Gets the meshes bound to the material
1216
+ * @returns an array of meshes bound to the material
1217
+ */
1218
+ getBindedMeshes() {
1219
+ if (this.meshMap) {
1220
+ const result = [];
1221
+ for (const meshId in this.meshMap) {
1222
+ const mesh = this.meshMap[meshId];
1223
+ if (mesh) {
1224
+ result.push(mesh);
1225
+ }
1226
+ }
1227
+ return result;
1228
+ }
1229
+ else {
1230
+ const meshes = this._scene.meshes;
1231
+ return meshes.filter((mesh) => mesh.material === this);
1232
+ }
1233
+ }
1234
+ /**
1235
+ * Force shader compilation
1236
+ * @param mesh defines the mesh associated with this material
1237
+ * @param onCompiled defines a function to execute once the material is compiled
1238
+ * @param options defines the options to configure the compilation
1239
+ * @param onError defines a function to execute if the material fails compiling
1240
+ */
1241
+ forceCompilation(mesh, onCompiled, options, onError) {
1242
+ const localOptions = {
1243
+ clipPlane: false,
1244
+ useInstances: false,
1245
+ ...options,
1246
+ };
1247
+ const scene = this.getScene();
1248
+ const currentHotSwapingState = this.allowShaderHotSwapping;
1249
+ this.allowShaderHotSwapping = false; // Turned off to let us evaluate the real compilation state
1250
+ const checkReady = () => {
1251
+ if (!this._scene || !this._scene.getEngine()) {
1252
+ return;
1253
+ }
1254
+ const clipPlaneState = scene.clipPlane;
1255
+ if (localOptions.clipPlane) {
1256
+ scene.clipPlane = new Plane(0, 0, 0, 1);
1257
+ }
1258
+ if (this._storeEffectOnSubMeshes) {
1259
+ let allDone = true, lastError = null;
1260
+ if (mesh.subMeshes) {
1261
+ const tempSubMesh = new SubMesh(0, 0, 0, 0, 0, mesh, undefined, false, false);
1262
+ if (tempSubMesh.materialDefines) {
1263
+ tempSubMesh.materialDefines._renderId = -1;
1264
+ }
1265
+ if (!this.isReadyForSubMesh(mesh, tempSubMesh, localOptions.useInstances)) {
1266
+ if (tempSubMesh.effect && tempSubMesh.effect.getCompilationError() && tempSubMesh.effect.allFallbacksProcessed()) {
1267
+ lastError = tempSubMesh.effect.getCompilationError();
1268
+ }
1269
+ else {
1270
+ allDone = false;
1271
+ setTimeout(checkReady, 16);
1272
+ }
1273
+ }
1274
+ }
1275
+ if (allDone) {
1276
+ this.allowShaderHotSwapping = currentHotSwapingState;
1277
+ if (lastError) {
1278
+ if (onError) {
1279
+ onError(lastError);
1280
+ }
1281
+ }
1282
+ if (onCompiled) {
1283
+ onCompiled(this);
1284
+ }
1285
+ }
1286
+ }
1287
+ else {
1288
+ if (this.isReady()) {
1289
+ this.allowShaderHotSwapping = currentHotSwapingState;
1290
+ if (onCompiled) {
1291
+ onCompiled(this);
1292
+ }
1293
+ }
1294
+ else {
1295
+ setTimeout(checkReady, 16);
1296
+ }
1297
+ }
1298
+ if (localOptions.clipPlane) {
1299
+ scene.clipPlane = clipPlaneState;
1300
+ }
1301
+ };
1302
+ checkReady();
1303
+ }
1304
+ /**
1305
+ * Force shader compilation
1306
+ * @param mesh defines the mesh that will use this material
1307
+ * @param options defines additional options for compiling the shaders
1308
+ * @returns a promise that resolves when the compilation completes
1309
+ */
1310
+ async forceCompilationAsync(mesh, options) {
1311
+ return await new Promise((resolve, reject) => {
1312
+ this.forceCompilation(mesh, () => {
1313
+ resolve();
1314
+ }, options, (reason) => {
1315
+ // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
1316
+ reject(reason);
1317
+ });
1318
+ });
1319
+ }
1320
+ /**
1321
+ * Marks a define in the material to indicate that it needs to be re-computed
1322
+ * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
1323
+ */
1324
+ markAsDirty(flag) {
1325
+ if (this.getScene().blockMaterialDirtyMechanism || this._blockDirtyMechanism) {
1326
+ return;
1327
+ }
1328
+ _a._DirtyCallbackArray.length = 0;
1329
+ if (flag & _a.ImageProcessingDirtyFlag) {
1330
+ _a._DirtyCallbackArray.push(_a._ImageProcessingDirtyCallBack);
1331
+ }
1332
+ if (flag & _a.TextureDirtyFlag) {
1333
+ _a._DirtyCallbackArray.push(_a._TextureDirtyCallBack);
1334
+ }
1335
+ if (flag & _a.LightDirtyFlag) {
1336
+ _a._DirtyCallbackArray.push(_a._LightsDirtyCallBack);
1337
+ }
1338
+ if (flag & _a.FresnelDirtyFlag) {
1339
+ _a._DirtyCallbackArray.push(_a._FresnelDirtyCallBack);
1340
+ }
1341
+ if (flag & _a.AttributesDirtyFlag) {
1342
+ _a._DirtyCallbackArray.push(_a._AttributeDirtyCallBack);
1343
+ }
1344
+ if (flag & _a.MiscDirtyFlag) {
1345
+ _a._DirtyCallbackArray.push(_a._MiscDirtyCallBack);
1346
+ }
1347
+ if (flag & _a.PrePassDirtyFlag) {
1348
+ _a._DirtyCallbackArray.push(_a._PrePassDirtyCallBack);
1349
+ }
1350
+ if (_a._DirtyCallbackArray.length) {
1351
+ this._markAllSubMeshesAsDirty(_a._RunDirtyCallBacks);
1352
+ }
1353
+ this.getScene().resetCachedMaterial();
1354
+ }
1355
+ /**
1356
+ * Resets the draw wrappers cache for all submeshes that are using this material
1357
+ */
1358
+ resetDrawCache() {
1359
+ const meshes = this.getScene().meshes;
1360
+ for (const mesh of meshes) {
1361
+ if (!mesh.subMeshes) {
1362
+ continue;
1363
+ }
1364
+ for (const subMesh of mesh.subMeshes) {
1365
+ if (subMesh.getMaterial() !== this) {
1366
+ continue;
1367
+ }
1368
+ subMesh.resetDrawCache();
1369
+ }
1370
+ }
1371
+ }
1372
+ /**
1373
+ * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
1374
+ * @param func defines a function which checks material defines against the submeshes
1375
+ */
1376
+ _markAllSubMeshesAsDirty(func) {
1377
+ const scene = this.getScene();
1378
+ if (scene.blockMaterialDirtyMechanism || this._blockDirtyMechanism) {
1379
+ return;
1380
+ }
1381
+ const meshes = scene.meshes;
1382
+ for (const mesh of meshes) {
1383
+ if (!mesh.subMeshes) {
1384
+ continue;
1385
+ }
1386
+ for (const subMesh of mesh.subMeshes) {
1387
+ // We want to skip the submeshes which are not using this material or which have not yet rendered at least once
1388
+ const material = subMesh.getMaterial() || (scene._hasDefaultMaterial ? scene.defaultMaterial : null);
1389
+ if (material !== this) {
1390
+ continue;
1391
+ }
1392
+ for (const drawWrapper of subMesh._drawWrappers) {
1393
+ if (!drawWrapper || !drawWrapper.defines || !drawWrapper.defines.markAllAsDirty) {
1394
+ continue;
1395
+ }
1396
+ if (this._materialContext === drawWrapper.materialContext) {
1397
+ func(drawWrapper.defines);
1398
+ }
1399
+ }
1400
+ }
1401
+ }
1402
+ }
1403
+ /**
1404
+ * Indicates that the scene should check if the rendering now needs a prepass
1405
+ */
1406
+ _markScenePrePassDirty() {
1407
+ if (this.getScene().blockMaterialDirtyMechanism || this._blockDirtyMechanism) {
1408
+ return;
1409
+ }
1410
+ const prePassRenderer = this.getScene().enablePrePassRenderer();
1411
+ if (prePassRenderer) {
1412
+ prePassRenderer.markAsDirty();
1413
+ }
1414
+ }
1415
+ /**
1416
+ * Indicates that we need to re-calculated for all submeshes
1417
+ */
1418
+ _markAllSubMeshesAsAllDirty() {
1419
+ this._markAllSubMeshesAsDirty(_a._AllDirtyCallBack);
1420
+ }
1421
+ /**
1422
+ * Indicates that image processing needs to be re-calculated for all submeshes
1423
+ */
1424
+ _markAllSubMeshesAsImageProcessingDirty() {
1425
+ this._markAllSubMeshesAsDirty(_a._ImageProcessingDirtyCallBack);
1426
+ }
1427
+ /**
1428
+ * Indicates that textures need to be re-calculated for all submeshes
1429
+ */
1430
+ _markAllSubMeshesAsTexturesDirty() {
1431
+ this._markAllSubMeshesAsDirty(_a._TextureDirtyCallBack);
1432
+ }
1433
+ /**
1434
+ * Indicates that fresnel needs to be re-calculated for all submeshes
1435
+ */
1436
+ _markAllSubMeshesAsFresnelDirty() {
1437
+ this._markAllSubMeshesAsDirty(_a._FresnelDirtyCallBack);
1438
+ }
1439
+ /**
1440
+ * Indicates that fresnel and misc need to be re-calculated for all submeshes
1441
+ */
1442
+ _markAllSubMeshesAsFresnelAndMiscDirty() {
1443
+ this._markAllSubMeshesAsDirty(_a._FresnelAndMiscDirtyCallBack);
1444
+ }
1445
+ /**
1446
+ * Indicates that lights need to be re-calculated for all submeshes
1447
+ */
1448
+ _markAllSubMeshesAsLightsDirty() {
1449
+ this._markAllSubMeshesAsDirty(_a._LightsDirtyCallBack);
1450
+ }
1451
+ /**
1452
+ * Indicates that attributes need to be re-calculated for all submeshes
1453
+ */
1454
+ _markAllSubMeshesAsAttributesDirty() {
1455
+ this._markAllSubMeshesAsDirty(_a._AttributeDirtyCallBack);
1456
+ }
1457
+ /**
1458
+ * Indicates that misc needs to be re-calculated for all submeshes
1459
+ */
1460
+ _markAllSubMeshesAsMiscDirty() {
1461
+ this._markAllSubMeshesAsDirty(_a._MiscDirtyCallBack);
1462
+ }
1463
+ /**
1464
+ * Indicates that prepass needs to be re-calculated for all submeshes
1465
+ */
1466
+ _markAllSubMeshesAsPrePassDirty() {
1467
+ this._markAllSubMeshesAsDirty(_a._PrePassDirtyCallBack);
1468
+ }
1469
+ /**
1470
+ * Indicates that textures and misc need to be re-calculated for all submeshes
1471
+ */
1472
+ _markAllSubMeshesAsTexturesAndMiscDirty() {
1473
+ this._markAllSubMeshesAsDirty(_a._TextureAndMiscDirtyCallBack);
1474
+ }
1475
+ _checkScenePerformancePriority() {
1476
+ if (this._scene.performancePriority !== 0 /* ScenePerformancePriority.BackwardCompatible */) {
1477
+ this.checkReadyOnlyOnce = true;
1478
+ // re-set the flag when the perf priority changes
1479
+ const observer = this._scene.onScenePerformancePriorityChangedObservable.addOnce(() => {
1480
+ this.checkReadyOnlyOnce = false;
1481
+ });
1482
+ // if this material is disposed before the scene is disposed, cleanup the observer
1483
+ this.onDisposeObservable.add(() => {
1484
+ this._scene.onScenePerformancePriorityChangedObservable.remove(observer);
1485
+ });
1486
+ }
1487
+ }
1488
+ /**
1489
+ * Sets the required values to the prepass renderer.
1490
+ * @param prePassRenderer defines the prepass renderer to setup.
1491
+ * @returns true if the pre pass is needed.
1492
+ */
1493
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1494
+ setPrePassRenderer(prePassRenderer) {
1495
+ // Do Nothing by default
1496
+ return false;
1497
+ }
1498
+ /**
1499
+ * Disposes the material
1500
+ * @param _forceDisposeEffect kept for backward compat. We reference count the effect now.
1501
+ * @param forceDisposeTextures specifies if textures should be forcefully disposed
1502
+ * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
1503
+ */
1504
+ dispose(_forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
1505
+ const scene = this.getScene();
1506
+ // Animations
1507
+ scene.stopAnimation(this);
1508
+ scene.freeProcessedMaterials();
1509
+ // Remove from scene
1510
+ scene.removeMaterial(this);
1511
+ this._eventInfo.forceDisposeTextures = forceDisposeTextures;
1512
+ this._callbackPluginEventGeneric(2 /* MaterialPluginEvent.Disposed */, this._eventInfo);
1513
+ if (this._parentContainer) {
1514
+ const index = this._parentContainer.materials.indexOf(this);
1515
+ if (index > -1) {
1516
+ this._parentContainer.materials.splice(index, 1);
1517
+ }
1518
+ this._parentContainer = null;
1519
+ }
1520
+ if (notBoundToMesh !== true) {
1521
+ // Remove from meshes
1522
+ if (this.meshMap) {
1523
+ for (const meshId in this.meshMap) {
1524
+ const mesh = this.meshMap[meshId];
1525
+ this._disposeMeshResources(mesh);
1526
+ }
1527
+ }
1528
+ else {
1529
+ const meshes = scene.meshes;
1530
+ for (const mesh of meshes) {
1531
+ this._disposeMeshResources(mesh);
1532
+ }
1533
+ }
1534
+ }
1535
+ this._uniformBuffer.dispose();
1536
+ // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
1537
+ if (this._drawWrapper.effect) {
1538
+ if (!this._storeEffectOnSubMeshes) {
1539
+ this._drawWrapper.effect.dispose();
1540
+ }
1541
+ this._drawWrapper.effect = null;
1542
+ }
1543
+ this.metadata = null;
1544
+ // Callback
1545
+ this.onDisposeObservable.notifyObservers(this);
1546
+ this.onDisposeObservable.clear();
1547
+ if (this._onBindObservable) {
1548
+ this._onBindObservable.clear();
1549
+ }
1550
+ if (this._onUnBindObservable) {
1551
+ this._onUnBindObservable.clear();
1552
+ }
1553
+ if (this._onEffectCreatedObservable) {
1554
+ this._onEffectCreatedObservable.clear();
1555
+ }
1556
+ if (this._eventInfo) {
1557
+ this._eventInfo = {};
1558
+ }
1559
+ this._isDisposed = true;
1560
+ }
1561
+ _disposeMeshResources(mesh) {
1562
+ if (!mesh) {
1563
+ return;
1564
+ }
1565
+ const geometry = mesh.geometry;
1566
+ const materialForRenderPass = mesh._internalAbstractMeshDataInfo._materialForRenderPass;
1567
+ if (this._storeEffectOnSubMeshes) {
1568
+ if (mesh.subMeshes && materialForRenderPass) {
1569
+ for (const subMesh of mesh.subMeshes) {
1570
+ const drawWrappers = subMesh._drawWrappers;
1571
+ for (let renderPassIndex = 0; renderPassIndex < drawWrappers.length; renderPassIndex++) {
1572
+ const effect = drawWrappers[renderPassIndex]?.effect;
1573
+ if (!effect) {
1574
+ continue;
1575
+ }
1576
+ const material = materialForRenderPass[renderPassIndex];
1577
+ if (material === this) {
1578
+ geometry?._releaseVertexArrayObject(effect);
1579
+ subMesh._removeDrawWrapper(renderPassIndex, true, true);
1580
+ }
1581
+ }
1582
+ }
1583
+ }
1584
+ }
1585
+ else {
1586
+ geometry?._releaseVertexArrayObject(this._drawWrapper.effect);
1587
+ }
1588
+ if (mesh.material === this && !mesh.sourceMesh) {
1589
+ mesh.material = null;
1590
+ }
1591
+ }
1592
+ /**
1593
+ * Serializes this material
1594
+ * @returns the serialized material object
1595
+ */
1596
+ serialize() {
1597
+ const serializationObject = SerializationHelper.Serialize(this);
1598
+ serializationObject.stencil = this.stencil.serialize();
1599
+ serializationObject.uniqueId = this.uniqueId;
1600
+ SerializationHelper.AppendSerializedAnimations(this, serializationObject);
1601
+ this._serializePlugins(serializationObject);
1602
+ return serializationObject;
1603
+ }
1604
+ _serializePlugins(serializationObject) {
1605
+ serializationObject.plugins = {};
1606
+ if (this.pluginManager) {
1607
+ for (const plugin of this.pluginManager._plugins) {
1608
+ if (!plugin.doNotSerialize) {
1609
+ serializationObject.plugins[plugin.getClassName()] = plugin.serialize();
1610
+ }
1611
+ }
1612
+ }
1613
+ }
1614
+ /**
1615
+ * Parses the alpha mode from the material data to parse
1616
+ * @param parsedMaterial defines the material data to parse
1617
+ * @param material defines the material to update
1618
+ */
1619
+ static ParseAlphaMode(parsedMaterial, material) {
1620
+ if (parsedMaterial._alphaMode !== undefined) {
1621
+ material._alphaMode = Array.isArray(parsedMaterial._alphaMode) ? parsedMaterial._alphaMode : [parsedMaterial._alphaMode];
1622
+ }
1623
+ else if (parsedMaterial.alphaMode !== undefined) {
1624
+ material._alphaMode = Array.isArray(parsedMaterial.alphaMode) ? parsedMaterial.alphaMode : [parsedMaterial.alphaMode];
1625
+ }
1626
+ else {
1627
+ material._alphaMode = [2];
1628
+ }
1629
+ }
1630
+ /**
1631
+ * Creates a material from parsed material data
1632
+ * @param parsedMaterial defines parsed material data
1633
+ * @param scene defines the hosting scene
1634
+ * @param rootUrl defines the root URL to use to load textures
1635
+ * @returns a new material
1636
+ */
1637
+ static Parse(parsedMaterial, scene, rootUrl) {
1638
+ if (!parsedMaterial.customType) {
1639
+ parsedMaterial.customType = "BABYLON.StandardMaterial";
1640
+ }
1641
+ else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
1642
+ parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
1643
+ if (!BABYLON.LegacyPBRMaterial) {
1644
+ Logger.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
1645
+ return null;
1646
+ }
1647
+ }
1648
+ const materialType = Tools.Instantiate(parsedMaterial.customType);
1649
+ const material = materialType.Parse(parsedMaterial, scene, rootUrl);
1650
+ material._loadedUniqueId = parsedMaterial.uniqueId;
1651
+ _a.ParseAlphaMode(parsedMaterial, material);
1652
+ _a._ParseAnimations(parsedMaterial, material);
1653
+ return material;
1654
+ }
1655
+ static _ParseAnimations(parsedMaterial, material) {
1656
+ if (parsedMaterial.animations) {
1657
+ for (let animationIndex = 0; animationIndex < parsedMaterial.animations.length; animationIndex++) {
1658
+ const parsedAnimation = parsedMaterial.animations[animationIndex];
1659
+ const internalClass = GetClass("BABYLON.Animation");
1660
+ if (internalClass) {
1661
+ if (!material.animations) {
1662
+ material.animations = [];
1663
+ }
1664
+ material.animations.push(internalClass.Parse(parsedAnimation));
1665
+ }
1666
+ }
1667
+ }
1668
+ }
1669
+ static _ParsePlugins(serializationObject, material, scene, rootUrl) {
1670
+ if (!serializationObject.plugins) {
1671
+ return;
1672
+ }
1673
+ for (const pluginClassName in serializationObject.plugins) {
1674
+ const pluginData = serializationObject.plugins[pluginClassName];
1675
+ let plugin = material.pluginManager?.getPlugin(pluginData.name);
1676
+ if (!plugin) {
1677
+ const pluginClassType = Tools.Instantiate("BABYLON." + pluginClassName);
1678
+ if (pluginClassType) {
1679
+ plugin = new pluginClassType(material);
1680
+ }
1681
+ }
1682
+ plugin?.parse(pluginData, scene, rootUrl);
1683
+ }
1684
+ }
1685
+ },
1686
+ (() => {
1687
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
1688
+ _id_decorators = [serialize()];
1689
+ _uniqueId_decorators = [serialize()];
1690
+ _name_decorators = [serialize()];
1691
+ _metadata_decorators = [serialize()];
1692
+ _checkReadyOnEveryCall_decorators = [serialize()];
1693
+ _checkReadyOnlyOnce_decorators = [serialize()];
1694
+ _state_decorators = [serialize()];
1695
+ __alpha_decorators = [serialize("alpha")];
1696
+ __backFaceCulling_decorators = [serialize("backFaceCulling")];
1697
+ __textureRepetitionMode_decorators = [serialize("textureRepetitionMode")];
1698
+ _textureRepetitionHexTilingParams_decorators = [serialize("textureRepetitionHexTilingParams")];
1699
+ __cullBackFaces_decorators = [serialize("cullBackFaces")];
1700
+ _sideOrientation_decorators = [serialize()];
1701
+ __alphaMode_decorators = [serialize()];
1702
+ __needDepthPrePass_decorators = [serialize()];
1703
+ _disableDepthWrite_decorators = [serialize()];
1704
+ _disableColorWrite_decorators = [serialize()];
1705
+ _forceDepthWrite_decorators = [serialize()];
1706
+ _depthFunction_decorators = [serialize()];
1707
+ _separateCullingPass_decorators = [serialize()];
1708
+ __fogEnabled_decorators = [serialize("fogEnabled")];
1709
+ _pointSize_decorators = [serialize()];
1710
+ _zOffset_decorators = [serialize()];
1711
+ _zOffsetUnits_decorators = [serialize()];
1712
+ _get_pointsCloud_decorators = [serialize()];
1713
+ _get_fillMode_decorators = [serialize()];
1714
+ _get_useLogarithmicDepth_decorators = [serialize()];
1715
+ __isVertexOutputInvariant_decorators = [serialize()];
1716
+ _get_transparencyMode_decorators = [serialize()];
1717
+ __esDecorate(_a, null, _get_pointsCloud_decorators, { kind: "getter", name: "pointsCloud", static: false, private: false, access: { has: obj => "pointsCloud" in obj, get: obj => obj.pointsCloud }, metadata: _metadata }, null, _instanceExtraInitializers);
1718
+ __esDecorate(_a, null, _get_fillMode_decorators, { kind: "getter", name: "fillMode", static: false, private: false, access: { has: obj => "fillMode" in obj, get: obj => obj.fillMode }, metadata: _metadata }, null, _instanceExtraInitializers);
1719
+ __esDecorate(_a, null, _get_useLogarithmicDepth_decorators, { kind: "getter", name: "useLogarithmicDepth", static: false, private: false, access: { has: obj => "useLogarithmicDepth" in obj, get: obj => obj.useLogarithmicDepth }, metadata: _metadata }, null, _instanceExtraInitializers);
1720
+ __esDecorate(_a, null, _get_transparencyMode_decorators, { kind: "getter", name: "transparencyMode", static: false, private: false, access: { has: obj => "transparencyMode" in obj, get: obj => obj.transparencyMode }, metadata: _metadata }, null, _instanceExtraInitializers);
1721
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
1722
+ __esDecorate(null, null, _uniqueId_decorators, { kind: "field", name: "uniqueId", static: false, private: false, access: { has: obj => "uniqueId" in obj, get: obj => obj.uniqueId, set: (obj, value) => { obj.uniqueId = value; } }, metadata: _metadata }, _uniqueId_initializers, _uniqueId_extraInitializers);
1723
+ __esDecorate(null, null, _name_decorators, { kind: "field", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
1724
+ __esDecorate(null, null, _metadata_decorators, { kind: "field", name: "metadata", static: false, private: false, access: { has: obj => "metadata" in obj, get: obj => obj.metadata, set: (obj, value) => { obj.metadata = value; } }, metadata: _metadata }, _metadata_initializers, _metadata_extraInitializers);
1725
+ __esDecorate(null, null, _checkReadyOnEveryCall_decorators, { kind: "field", name: "checkReadyOnEveryCall", static: false, private: false, access: { has: obj => "checkReadyOnEveryCall" in obj, get: obj => obj.checkReadyOnEveryCall, set: (obj, value) => { obj.checkReadyOnEveryCall = value; } }, metadata: _metadata }, _checkReadyOnEveryCall_initializers, _checkReadyOnEveryCall_extraInitializers);
1726
+ __esDecorate(null, null, _checkReadyOnlyOnce_decorators, { kind: "field", name: "checkReadyOnlyOnce", static: false, private: false, access: { has: obj => "checkReadyOnlyOnce" in obj, get: obj => obj.checkReadyOnlyOnce, set: (obj, value) => { obj.checkReadyOnlyOnce = value; } }, metadata: _metadata }, _checkReadyOnlyOnce_initializers, _checkReadyOnlyOnce_extraInitializers);
1727
+ __esDecorate(null, null, _state_decorators, { kind: "field", name: "state", static: false, private: false, access: { has: obj => "state" in obj, get: obj => obj.state, set: (obj, value) => { obj.state = value; } }, metadata: _metadata }, _state_initializers, _state_extraInitializers);
1728
+ __esDecorate(null, null, __alpha_decorators, { kind: "field", name: "_alpha", static: false, private: false, access: { has: obj => "_alpha" in obj, get: obj => obj._alpha, set: (obj, value) => { obj._alpha = value; } }, metadata: _metadata }, __alpha_initializers, __alpha_extraInitializers);
1729
+ __esDecorate(null, null, __backFaceCulling_decorators, { kind: "field", name: "_backFaceCulling", static: false, private: false, access: { has: obj => "_backFaceCulling" in obj, get: obj => obj._backFaceCulling, set: (obj, value) => { obj._backFaceCulling = value; } }, metadata: _metadata }, __backFaceCulling_initializers, __backFaceCulling_extraInitializers);
1730
+ __esDecorate(null, null, __textureRepetitionMode_decorators, { kind: "field", name: "_textureRepetitionMode", static: false, private: false, access: { has: obj => "_textureRepetitionMode" in obj, get: obj => obj._textureRepetitionMode, set: (obj, value) => { obj._textureRepetitionMode = value; } }, metadata: _metadata }, __textureRepetitionMode_initializers, __textureRepetitionMode_extraInitializers);
1731
+ __esDecorate(null, null, _textureRepetitionHexTilingParams_decorators, { kind: "field", name: "textureRepetitionHexTilingParams", static: false, private: false, access: { has: obj => "textureRepetitionHexTilingParams" in obj, get: obj => obj.textureRepetitionHexTilingParams, set: (obj, value) => { obj.textureRepetitionHexTilingParams = value; } }, metadata: _metadata }, _textureRepetitionHexTilingParams_initializers, _textureRepetitionHexTilingParams_extraInitializers);
1732
+ __esDecorate(null, null, __cullBackFaces_decorators, { kind: "field", name: "_cullBackFaces", static: false, private: false, access: { has: obj => "_cullBackFaces" in obj, get: obj => obj._cullBackFaces, set: (obj, value) => { obj._cullBackFaces = value; } }, metadata: _metadata }, __cullBackFaces_initializers, __cullBackFaces_extraInitializers);
1733
+ __esDecorate(null, null, _sideOrientation_decorators, { kind: "field", name: "sideOrientation", static: false, private: false, access: { has: obj => "sideOrientation" in obj, get: obj => obj.sideOrientation, set: (obj, value) => { obj.sideOrientation = value; } }, metadata: _metadata }, _sideOrientation_initializers, _sideOrientation_extraInitializers);
1734
+ __esDecorate(null, null, __alphaMode_decorators, { kind: "field", name: "_alphaMode", static: false, private: false, access: { has: obj => "_alphaMode" in obj, get: obj => obj._alphaMode, set: (obj, value) => { obj._alphaMode = value; } }, metadata: _metadata }, __alphaMode_initializers, __alphaMode_extraInitializers);
1735
+ __esDecorate(null, null, __needDepthPrePass_decorators, { kind: "field", name: "_needDepthPrePass", static: false, private: false, access: { has: obj => "_needDepthPrePass" in obj, get: obj => obj._needDepthPrePass, set: (obj, value) => { obj._needDepthPrePass = value; } }, metadata: _metadata }, __needDepthPrePass_initializers, __needDepthPrePass_extraInitializers);
1736
+ __esDecorate(null, null, _disableDepthWrite_decorators, { kind: "field", name: "disableDepthWrite", static: false, private: false, access: { has: obj => "disableDepthWrite" in obj, get: obj => obj.disableDepthWrite, set: (obj, value) => { obj.disableDepthWrite = value; } }, metadata: _metadata }, _disableDepthWrite_initializers, _disableDepthWrite_extraInitializers);
1737
+ __esDecorate(null, null, _disableColorWrite_decorators, { kind: "field", name: "disableColorWrite", static: false, private: false, access: { has: obj => "disableColorWrite" in obj, get: obj => obj.disableColorWrite, set: (obj, value) => { obj.disableColorWrite = value; } }, metadata: _metadata }, _disableColorWrite_initializers, _disableColorWrite_extraInitializers);
1738
+ __esDecorate(null, null, _forceDepthWrite_decorators, { kind: "field", name: "forceDepthWrite", static: false, private: false, access: { has: obj => "forceDepthWrite" in obj, get: obj => obj.forceDepthWrite, set: (obj, value) => { obj.forceDepthWrite = value; } }, metadata: _metadata }, _forceDepthWrite_initializers, _forceDepthWrite_extraInitializers);
1739
+ __esDecorate(null, null, _depthFunction_decorators, { kind: "field", name: "depthFunction", static: false, private: false, access: { has: obj => "depthFunction" in obj, get: obj => obj.depthFunction, set: (obj, value) => { obj.depthFunction = value; } }, metadata: _metadata }, _depthFunction_initializers, _depthFunction_extraInitializers);
1740
+ __esDecorate(null, null, _separateCullingPass_decorators, { kind: "field", name: "separateCullingPass", static: false, private: false, access: { has: obj => "separateCullingPass" in obj, get: obj => obj.separateCullingPass, set: (obj, value) => { obj.separateCullingPass = value; } }, metadata: _metadata }, _separateCullingPass_initializers, _separateCullingPass_extraInitializers);
1741
+ __esDecorate(null, null, __fogEnabled_decorators, { kind: "field", name: "_fogEnabled", static: false, private: false, access: { has: obj => "_fogEnabled" in obj, get: obj => obj._fogEnabled, set: (obj, value) => { obj._fogEnabled = value; } }, metadata: _metadata }, __fogEnabled_initializers, __fogEnabled_extraInitializers);
1742
+ __esDecorate(null, null, _pointSize_decorators, { kind: "field", name: "pointSize", static: false, private: false, access: { has: obj => "pointSize" in obj, get: obj => obj.pointSize, set: (obj, value) => { obj.pointSize = value; } }, metadata: _metadata }, _pointSize_initializers, _pointSize_extraInitializers);
1743
+ __esDecorate(null, null, _zOffset_decorators, { kind: "field", name: "zOffset", static: false, private: false, access: { has: obj => "zOffset" in obj, get: obj => obj.zOffset, set: (obj, value) => { obj.zOffset = value; } }, metadata: _metadata }, _zOffset_initializers, _zOffset_extraInitializers);
1744
+ __esDecorate(null, null, _zOffsetUnits_decorators, { kind: "field", name: "zOffsetUnits", static: false, private: false, access: { has: obj => "zOffsetUnits" in obj, get: obj => obj.zOffsetUnits, set: (obj, value) => { obj.zOffsetUnits = value; } }, metadata: _metadata }, _zOffsetUnits_initializers, _zOffsetUnits_extraInitializers);
1745
+ __esDecorate(null, null, __isVertexOutputInvariant_decorators, { kind: "field", name: "_isVertexOutputInvariant", static: false, private: false, access: { has: obj => "_isVertexOutputInvariant" in obj, get: obj => obj._isVertexOutputInvariant, set: (obj, value) => { obj._isVertexOutputInvariant = value; } }, metadata: _metadata }, __isVertexOutputInvariant_initializers, __isVertexOutputInvariant_extraInitializers);
1746
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1747
+ })(),
466
1748
  /**
467
- * Parameters for the hex tiling texture repetition mode (TEXTURE_REPETITION_HEX_TILING).
468
- * x = rotation strength (0..1, default 1.0) — how much each hex tile is rotated.
469
- * y = fall-off contrast (0..1, default 0.6) — how much luminance affects blending weight at tile borders.
470
- * z = exponent (1..20, default 7.0) — controls the sharpness of weight falloff between tiles.
471
- * w = contrast (0..1, default 0.5) — boost blending contrast via Gain3 (0.5 = neutral, &gt;0.5 = higher contrast).
472
- * @see https://jcgt.org/published/0011/03/05/
1749
+ * Returns the triangle fill mode
473
1750
  */
474
- this.textureRepetitionHexTilingParams = [1.0, 0.6, 7.0, 0.5];
1751
+ _a.TriangleFillMode = 0,
475
1752
  /**
476
- * Specifies if back or front faces should be culled (when culling is enabled)
1753
+ * Returns the wireframe mode
477
1754
  */
478
- this._cullBackFaces = true;
479
- this._blockDirtyMechanism = false;
1755
+ _a.WireFrameFillMode = 1,
480
1756
  /**
481
- * Stores the value for side orientation
1757
+ * Returns the point fill mode
482
1758
  */
483
- this.sideOrientation = null;
1759
+ _a.PointFillMode = 2,
484
1760
  /**
485
- * Callback triggered when the material is compiled
1761
+ * Returns the point list draw mode
486
1762
  */
487
- this.onCompiled = null;
1763
+ _a.PointListDrawMode = 3,
488
1764
  /**
489
- * Callback triggered when an error occurs
1765
+ * Returns the line list draw mode
490
1766
  */
491
- this.onError = null;
1767
+ _a.LineListDrawMode = 4,
492
1768
  /**
493
- * Callback triggered to get the render target textures
1769
+ * Returns the line loop draw mode
494
1770
  */
495
- this.getRenderTargetTextures = null;
1771
+ _a.LineLoopDrawMode = 5,
496
1772
  /**
497
- * Specifies if the material should be serialized
1773
+ * Returns the line strip draw mode
498
1774
  */
499
- this.doNotSerialize = false;
1775
+ _a.LineStripDrawMode = 6,
500
1776
  /**
501
- * @internal
1777
+ * Returns the triangle strip draw mode
502
1778
  */
503
- this._storeEffectOnSubMeshes = false;
1779
+ _a.TriangleStripDrawMode = 7,
504
1780
  /**
505
- * Stores the animations for the material
1781
+ * Returns the triangle fan draw mode
506
1782
  */
507
- this.animations = null;
1783
+ _a.TriangleFanDrawMode = 8,
508
1784
  /**
509
- * An event triggered when the material is disposed
1785
+ * Stores the clock-wise side orientation
510
1786
  */
511
- this.onDisposeObservable = new Observable();
1787
+ _a.ClockWiseSideOrientation = 0,
512
1788
  /**
513
- * An observer which watches for dispose events
1789
+ * Stores the counter clock-wise side orientation
514
1790
  */
515
- this._onDisposeObserver = null;
516
- this._onUnBindObservable = null;
1791
+ _a.CounterClockWiseSideOrientation = 1,
517
1792
  /**
518
- * An observer which watches for bind events
1793
+ * The dirty image processing flag value
519
1794
  */
520
- this._onBindObserver = null;
1795
+ _a.ImageProcessingDirtyFlag = 64,
521
1796
  /**
522
- * Stores the value of the alpha mode
1797
+ * The dirty texture flag value
523
1798
  */
524
- this._alphaMode = [2];
1799
+ _a.TextureDirtyFlag = 1,
525
1800
  /**
526
- * Stores the state of the need depth pre-pass value
1801
+ * The dirty light flag value
527
1802
  */
528
- this._needDepthPrePass = false;
1803
+ _a.LightDirtyFlag = 2,
529
1804
  /**
530
- * Specifies if depth writing should be disabled
1805
+ * The dirty fresnel flag value
531
1806
  */
532
- this.disableDepthWrite = false;
1807
+ _a.FresnelDirtyFlag = 4,
533
1808
  /**
534
- * Specifies if color writing should be disabled
1809
+ * The dirty attribute flag value
535
1810
  */
536
- this.disableColorWrite = false;
1811
+ _a.AttributesDirtyFlag = 8,
537
1812
  /**
538
- * Specifies if depth writing should be forced
1813
+ * The dirty misc flag value
539
1814
  */
540
- this.forceDepthWrite = false;
1815
+ _a.MiscDirtyFlag = 16,
541
1816
  /**
542
- * Specifies the depth function that should be used. 0 means the default engine function
1817
+ * The dirty prepass flag value
543
1818
  */
544
- this.depthFunction = 0;
1819
+ _a.PrePassDirtyFlag = 32,
545
1820
  /**
546
- * Specifies if there should be a separate pass for culling
1821
+ * The all dirty flag value
547
1822
  */
548
- this.separateCullingPass = false;
1823
+ _a.AllDirtyFlag = 127,
549
1824
  /**
550
- * Stores the state specifying if fog should be enabled
1825
+ * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
551
1826
  */
552
- this._fogEnabled = true;
1827
+ _a.MATERIAL_OPAQUE = 0,
553
1828
  /**
554
- * Stores the size of points
1829
+ * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
555
1830
  */
556
- this.pointSize = 1.0;
1831
+ _a.MATERIAL_ALPHATEST = 1,
557
1832
  /**
558
- * Stores the z offset Factor value
1833
+ * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
559
1834
  */
560
- this.zOffset = 0;
1835
+ _a.MATERIAL_ALPHABLEND = 2,
561
1836
  /**
562
- * Stores the z offset Units value
1837
+ * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
1838
+ * They are also discarded below the alpha cutoff threshold to improve performances.
563
1839
  */
564
- this.zOffsetUnits = 0;
1840
+ _a.MATERIAL_ALPHATESTANDBLEND = 3,
565
1841
  /**
566
- * Gives access to the stencil properties of the material
1842
+ * The Whiteout method is used to blend normals.
1843
+ * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
567
1844
  */
568
- this.stencil = new MaterialStencilState();
569
- this._isVertexOutputInvariant = Material.ForceVertexOutputInvariant;
1845
+ _a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0,
570
1846
  /**
571
- * Specifies if uniform buffers should be used
1847
+ * The Reoriented Normal Mapping method is used to blend normals.
1848
+ * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
572
1849
  */
573
- this._useUBO = false;
1850
+ _a.MATERIAL_NORMALBLENDMETHOD_RNM = 1,
574
1851
  /**
575
- * Stores the fill mode state
1852
+ * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
576
1853
  */
577
- this._fillMode = Material.TriangleFillMode;
1854
+ _a.LIGHTFALLOFF_PHYSICAL = 0,
578
1855
  /**
579
- * Specifies if the depth write state should be cached
1856
+ * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
1857
+ * to enhance interoperability with other engines.
580
1858
  */
581
- this._cachedDepthWriteState = false;
1859
+ _a.LIGHTFALLOFF_GLTF = 1,
582
1860
  /**
583
- * Specifies if the color write state should be cached
1861
+ * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
1862
+ * to enhance interoperability with other materials.
584
1863
  */
585
- this._cachedColorWriteState = false;
1864
+ _a.LIGHTFALLOFF_STANDARD = 2,
586
1865
  /**
587
- * Specifies if the depth function state should be cached
1866
+ * Event observable which raises global events common to all materials (like MaterialPluginEvent.Created)
588
1867
  */
589
- this._cachedDepthFunctionState = 0;
590
- /** @internal */
591
- this._indexInSceneMaterialArray = -1;
592
- /** @internal */
593
- this.meshMap = null;
594
- /** @internal */
595
- this._parentContainer = null;
596
- /** @internal */
597
- this._uniformBufferLayoutBuilt = false;
598
- this._eventInfo = {}; // will be initialized before each event notification
599
- /** @internal */
600
- this._callbackPluginEventGeneric = () => void 0;
601
- /** @internal */
602
- this._callbackPluginEventIsReadyForSubMesh = () => void 0;
603
- /** @internal */
604
- this._callbackPluginEventPrepareDefines = () => void 0;
605
- /** @internal */
606
- this._callbackPluginEventPrepareDefinesBeforeAttributes = () => void 0;
607
- /** @internal */
608
- this._callbackPluginEventHardBindForSubMesh = () => void 0;
609
- /** @internal */
610
- this._callbackPluginEventBindForSubMesh = () => void 0;
611
- /** @internal */
612
- this._callbackPluginEventHasRenderTargetTextures = () => void 0;
613
- /** @internal */
614
- this._callbackPluginEventFillRenderTargetTextures = () => void 0;
1868
+ _a.OnEventObservable = new Observable(),
615
1869
  /**
616
- * The transparency mode of the material.
1870
+ * If true, all materials will have their vertex output set to invariant (see the vertexOutputInvariant property).
617
1871
  */
618
- this._transparencyMode = null;
619
- this.name = name;
620
- const setScene = scene || EngineStore.LastCreatedScene;
621
- if (!setScene) {
622
- return;
623
- }
624
- this._scene = setScene;
625
- this._dirtyCallbacks = {};
626
- this._forceGLSL = forceGLSL;
627
- this._dirtyCallbacks[1] = this._markAllSubMeshesAsTexturesDirty.bind(this);
628
- this._dirtyCallbacks[2] = this._markAllSubMeshesAsLightsDirty.bind(this);
629
- this._dirtyCallbacks[4] = this._markAllSubMeshesAsFresnelDirty.bind(this);
630
- this._dirtyCallbacks[8] = this._markAllSubMeshesAsAttributesDirty.bind(this);
631
- this._dirtyCallbacks[16] = this._markAllSubMeshesAsMiscDirty.bind(this);
632
- this._dirtyCallbacks[32] = this._markAllSubMeshesAsPrePassDirty.bind(this);
633
- this._dirtyCallbacks[127] = this._markAllSubMeshesAsAllDirty.bind(this);
634
- this.id = name || Tools.RandomId();
635
- this.uniqueId = this._scene.getUniqueId();
636
- this._materialContext = this._scene.getEngine().createMaterialContext();
637
- this._drawWrapper = new DrawWrapper(this._scene.getEngine(), false);
638
- this._drawWrapper.materialContext = this._materialContext;
639
- this._uniformBuffer = new UniformBuffer(this._scene.getEngine(), undefined, undefined, name);
640
- this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
641
- this._createUniformBuffer();
642
- if (!doNotAdd) {
643
- this._scene.addMaterial(this);
644
- }
645
- if (this._scene.useMaterialMeshMap) {
646
- this.meshMap = {};
647
- }
648
- Material.OnEventObservable.notifyObservers(this, 1 /* MaterialPluginEvent.Created */);
649
- }
650
- /** @internal */
651
- _createUniformBuffer() {
652
- const engine = this.getScene().getEngine();
653
- this._uniformBuffer?.dispose();
654
- if (engine.isWebGPU && !this._forceGLSL) {
655
- // Switch main UBO to non UBO to connect to leftovers UBO in webgpu
656
- this._uniformBuffer = new UniformBuffer(engine, undefined, undefined, this.name, true);
657
- this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;
658
- }
659
- else {
660
- this._uniformBuffer = new UniformBuffer(this._scene.getEngine(), undefined, undefined, this.name);
661
- }
662
- this._uniformBufferLayoutBuilt = false;
663
- }
664
- /**
665
- * Returns a string representation of the current material
666
- * @param fullDetails defines a boolean indicating which levels of logging is desired
667
- * @returns a string with material information
668
- */
669
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
670
- toString(fullDetails) {
671
- const ret = "Name: " + this.name;
672
- return ret;
673
- }
674
- /**
675
- * Gets the class name of the material
676
- * @returns a string with the class name of the material
677
- */
678
- getClassName() {
679
- return "Material";
680
- }
681
- /** @internal */
682
- get _isMaterial() {
683
- return true;
684
- }
685
- /**
686
- * Specifies if updates for the material been locked
687
- */
688
- get isFrozen() {
689
- return this.checkReadyOnlyOnce;
690
- }
691
- /**
692
- * Locks updates for the material.
693
- *
694
- * Note: while a material is frozen, the scene can still rebind it at least
695
- * once per camera render (and again whenever another material was bound in
696
- * between). What can be skipped while the frozen material stays cached are
697
- * per-mesh updates performed during a rebind.
698
- *
699
- * This includes per-mesh morph target influences. If the same frozen
700
- * material is shared across several meshes that each have different
701
- * per-mesh morph influences, only the mesh that triggers the rebind updates
702
- * those values. Other meshes rendered afterward with the same cached frozen
703
- * material may reuse stale influences and render with the wrong values.
704
- *
705
- * For that scenario either keep the material unfrozen, clone the material
706
- * per mesh and freeze each clone, or `unfreeze()` before changing
707
- * influences and `freeze()` again afterwards.
708
- */
709
- freeze() {
710
- this.markDirty();
711
- this.checkReadyOnlyOnce = true;
712
- }
713
- /**
714
- * Unlocks updates for the material
715
- */
716
- unfreeze() {
717
- this.markDirty();
718
- this.checkReadyOnlyOnce = false;
719
- }
720
- /**
721
- * Specifies if the material is ready to be used
722
- * @param mesh defines the mesh to check
723
- * @param useInstances specifies if instances should be used
724
- * @returns a boolean indicating if the material is ready to be used
725
- */
726
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
727
- isReady(mesh, useInstances) {
728
- return true;
729
- }
730
- /**
731
- * Specifies that the submesh is ready to be used
732
- * @param mesh defines the mesh to check
733
- * @param subMesh defines which submesh to check
734
- * @param useInstances specifies that instances should be used
735
- * @returns a boolean indicating that the submesh is ready or not
736
- */
737
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
738
- isReadyForSubMesh(mesh, subMesh, useInstances) {
739
- const defines = subMesh.materialDefines;
740
- if (!defines) {
741
- return false;
742
- }
743
- this._eventInfo.isReadyForSubMesh = true;
744
- this._eventInfo.defines = defines;
745
- this._callbackPluginEventIsReadyForSubMesh(this._eventInfo);
746
- return this._eventInfo.isReadyForSubMesh;
747
- }
748
- /**
749
- * Returns the material effect
750
- * @returns the effect associated with the material
751
- */
752
- getEffect() {
753
- return this._drawWrapper.effect;
754
- }
755
- /**
756
- * Returns the current scene
757
- * @returns a Scene
758
- */
759
- getScene() {
760
- return this._scene;
761
- }
762
- /** @internal */
763
- _getEffectiveOrientation(mesh) {
764
- return this.sideOrientation !== null ? this.sideOrientation : mesh.sideOrientation;
765
- }
766
- /**
767
- * Gets the current transparency mode.
768
- */
769
- get transparencyMode() {
770
- return this._transparencyMode;
771
- }
772
- /**
773
- * Sets the transparency mode of the material.
774
- *
775
- * | Value | Type | Description |
776
- * | ----- | ----------------------------------- | ----------- |
777
- * | 0 | OPAQUE | |
778
- * | 1 | ALPHATEST | |
779
- * | 2 | ALPHABLEND | |
780
- * | 3 | ALPHATESTANDBLEND | |
781
- *
782
- */
783
- set transparencyMode(value) {
784
- if (this._transparencyMode === value) {
785
- return;
786
- }
787
- this._transparencyMode = value;
788
- this._markAllSubMeshesAsTexturesAndMiscDirty();
789
- }
790
- get _hasTransparencyMode() {
791
- return this._transparencyMode != null;
792
- }
793
- get _transparencyModeIsBlend() {
794
- return this._transparencyMode === Material.MATERIAL_ALPHABLEND || this._transparencyMode === Material.MATERIAL_ALPHATESTANDBLEND;
795
- }
796
- get _transparencyModeIsTest() {
797
- return this._transparencyMode === Material.MATERIAL_ALPHATEST || this._transparencyMode === Material.MATERIAL_ALPHATESTANDBLEND;
798
- }
799
- /**
800
- * Returns true if alpha blending should be disabled.
801
- */
802
- get _disableAlphaBlending() {
803
- return this._transparencyMode === Material.MATERIAL_OPAQUE || this._transparencyMode === Material.MATERIAL_ALPHATEST;
804
- }
805
- /**
806
- * Specifies whether or not this material should be rendered in alpha blend mode.
807
- * @returns a boolean specifying if alpha blending is needed
808
- * @deprecated Please use needAlphaBlendingForMesh instead
809
- */
810
- needAlphaBlending() {
811
- if (this._hasTransparencyMode) {
812
- return this._transparencyModeIsBlend;
813
- }
814
- if (this._disableAlphaBlending) {
815
- return false;
816
- }
817
- return this.alpha < 1.0;
818
- }
819
- /**
820
- * Specifies if the mesh will require alpha blending
821
- * @param mesh defines the mesh to check
822
- * @returns a boolean specifying if alpha blending is needed for the mesh
823
- */
824
- needAlphaBlendingForMesh(mesh) {
825
- if (this._hasTransparencyMode) {
826
- return this._transparencyModeIsBlend;
827
- }
828
- if (mesh.visibility < 1.0) {
829
- return true;
830
- }
831
- if (this._disableAlphaBlending) {
832
- return false;
833
- }
834
- return mesh.hasVertexAlpha || this.needAlphaBlending();
835
- }
836
- /**
837
- * Specifies whether or not this material should be rendered in alpha test mode.
838
- * @returns a boolean specifying if an alpha test is needed.
839
- * @deprecated Please use needAlphaTestingForMesh instead
840
- */
841
- needAlphaTesting() {
842
- if (this._hasTransparencyMode) {
843
- return this._transparencyModeIsTest;
844
- }
845
- return false;
846
- }
847
- /**
848
- * Specifies if material alpha testing should be turned on for the mesh
849
- * @param mesh defines the mesh to check
850
- * @returns a boolean specifying if alpha testing should be turned on for the mesh
851
- */
852
- needAlphaTestingForMesh(mesh) {
853
- if (this._hasTransparencyMode) {
854
- return this._transparencyModeIsTest;
855
- }
856
- return !this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting();
857
- }
858
- /**
859
- * Gets the texture used for the alpha test
860
- * @returns the texture to use for alpha testing
861
- */
862
- getAlphaTestTexture() {
863
- return null;
864
- }
865
- /**
866
- * Marks the material to indicate that it needs to be re-calculated
867
- * @param forceMaterialDirty - Forces the material to be marked as dirty for all components (same as this.markAsDirty(Material.AllDirtyFlag)). You should use this flag if the material is frozen and you want to force a recompilation.
868
- */
869
- markDirty(forceMaterialDirty = false) {
870
- const meshes = this.getScene().meshes;
871
- for (const mesh of meshes) {
872
- if (!mesh.subMeshes) {
873
- continue;
874
- }
875
- for (const subMesh of mesh.subMeshes) {
876
- if (subMesh.getMaterial() !== this) {
877
- continue;
878
- }
879
- for (const drawWrapper of subMesh._drawWrappers) {
880
- if (!drawWrapper) {
881
- continue;
882
- }
883
- if (this._materialContext === drawWrapper.materialContext) {
884
- drawWrapper._wasPreviouslyReady = false;
885
- drawWrapper._wasPreviouslyUsingInstances = null;
886
- drawWrapper._forceRebindOnNextCall = forceMaterialDirty;
887
- }
888
- }
889
- }
890
- }
891
- if (forceMaterialDirty) {
892
- this.markAsDirty(Material.AllDirtyFlag);
893
- }
894
- }
895
- /**
896
- * @internal
897
- */
898
- _preBind(effect, overrideOrientation = null) {
899
- const engine = this._scene.getEngine();
900
- const orientation = overrideOrientation == null ? this.sideOrientation : overrideOrientation;
901
- const reverse = orientation === Material.ClockWiseSideOrientation;
902
- const effectiveDrawWrapper = effect ? effect : this._getDrawWrapper();
903
- if (IsWrapper(effectiveDrawWrapper) && effectiveDrawWrapper.materialContext) {
904
- effectiveDrawWrapper.materialContext.useVertexPulling = this.useVertexPulling;
905
- }
906
- engine.enableEffect(effectiveDrawWrapper);
907
- engine.setState(this.backFaceCulling, this.zOffset, false, reverse, this._scene._mirroredCameraPosition ? !this.cullBackFaces : this.cullBackFaces, this.stencil, this.zOffsetUnits);
908
- return reverse;
909
- }
910
- /**
911
- * Binds the material to the mesh
912
- * @param world defines the world transformation matrix
913
- * @param mesh defines the mesh to bind the material to
914
- */
915
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
916
- bind(world, mesh) { }
917
- /**
918
- * Initializes the uniform buffer layout for the shader.
919
- */
920
- buildUniformLayout() {
921
- const ubo = this._uniformBuffer;
922
- this._eventInfo.ubo = ubo;
923
- this._callbackPluginEventGeneric(8 /* MaterialPluginEvent.PrepareUniformBuffer */, this._eventInfo);
924
- ubo.create();
925
- this._uniformBufferLayoutBuilt = true;
926
- }
927
- /**
928
- * Binds the submesh to the material
929
- * @param world defines the world transformation matrix
930
- * @param mesh defines the mesh containing the submesh
931
- * @param subMesh defines the submesh to bind the material to
932
- */
933
- bindForSubMesh(world, mesh, subMesh) {
934
- const drawWrapper = subMesh._drawWrapper;
935
- this._eventInfo.subMesh = subMesh;
936
- this._callbackPluginEventBindForSubMesh(this._eventInfo);
937
- drawWrapper._forceRebindOnNextCall = false;
938
- }
939
- /**
940
- * Binds the world matrix to the material
941
- * @param world defines the world transformation matrix
942
- */
943
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
944
- bindOnlyWorldMatrix(world) { }
945
- /**
946
- * Binds the view matrix to the effect
947
- * @param effect defines the effect to bind the view matrix to
948
- */
949
- bindView(effect) {
950
- if (!this._useUBO) {
951
- effect.setMatrix("view", this.getScene().getViewMatrix());
952
- }
953
- else {
954
- this._needToBindSceneUbo = true;
955
- }
956
- }
957
- /**
958
- * Binds the view projection and projection matrices to the effect
959
- * @param effect defines the effect to bind the view projection and projection matrices to
960
- */
961
- bindViewProjection(effect) {
962
- if (!this._useUBO) {
963
- effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
964
- effect.setMatrix("projection", this.getScene().getProjectionMatrix());
965
- effect.setMatrix("inverseProjection", this.getScene().getInverseProjectionMatrix());
966
- }
967
- else {
968
- this._needToBindSceneUbo = true;
969
- }
970
- }
971
- /**
972
- * Binds the view matrix to the effect
973
- * @param effect defines the effect to bind the view matrix to
974
- * @param variableName name of the shader variable that will hold the eye position
975
- */
976
- bindEyePosition(effect, variableName) {
977
- if (!this._useUBO) {
978
- this._scene.bindEyePosition(effect, variableName);
979
- }
980
- else {
981
- this._needToBindSceneUbo = true;
982
- }
983
- }
984
- /**
985
- * Processes to execute after binding the material to a mesh
986
- * @param mesh defines the rendered mesh
987
- * @param effect defines the effect used to bind the material
988
- * @param _subMesh defines the subMesh that the material has been bound for
989
- */
990
- _afterBind(mesh, effect = null, _subMesh) {
991
- this._scene._cachedMaterial = this;
992
- if (this._needToBindSceneUbo) {
993
- if (effect) {
994
- this._needToBindSceneUbo = false;
995
- BindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
996
- this._scene.finalizeSceneUbo();
997
- }
998
- }
999
- if (mesh) {
1000
- this._scene._cachedVisibility = mesh.visibility;
1001
- }
1002
- else {
1003
- this._scene._cachedVisibility = 1;
1004
- }
1005
- if (this._onBindObservable && mesh) {
1006
- this._onBindObservable.notifyObservers(mesh);
1007
- }
1008
- if (this.disableDepthWrite) {
1009
- const engine = this._scene.getEngine();
1010
- this._cachedDepthWriteState = engine.getDepthWrite();
1011
- engine.setDepthWrite(false);
1012
- }
1013
- if (this.disableColorWrite) {
1014
- const engine = this._scene.getEngine();
1015
- this._cachedColorWriteState = engine.getColorWrite();
1016
- engine.setColorWrite(false);
1017
- }
1018
- if (this.depthFunction !== 0) {
1019
- const engine = this._scene.getEngine();
1020
- this._cachedDepthFunctionState = engine.getDepthFunction() || 0;
1021
- engine.setDepthFunction(this.depthFunction);
1022
- }
1023
- }
1024
- /**
1025
- * Unbinds the material from the mesh
1026
- */
1027
- unbind() {
1028
- this._scene.getSceneUniformBuffer().unbindEffect();
1029
- if (this._onUnBindObservable) {
1030
- this._onUnBindObservable.notifyObservers(this);
1031
- }
1032
- if (this.depthFunction !== 0) {
1033
- const engine = this._scene.getEngine();
1034
- engine.setDepthFunction(this._cachedDepthFunctionState);
1035
- }
1036
- if (this.disableDepthWrite) {
1037
- const engine = this._scene.getEngine();
1038
- engine.setDepthWrite(this._cachedDepthWriteState);
1039
- }
1040
- if (this.disableColorWrite) {
1041
- const engine = this._scene.getEngine();
1042
- engine.setColorWrite(this._cachedColorWriteState);
1043
- }
1044
- }
1045
- /**
1046
- * Returns the animatable textures.
1047
- * @returns - Array of animatable textures.
1048
- */
1049
- getAnimatables() {
1050
- this._eventInfo.animatables = [];
1051
- this._callbackPluginEventGeneric(256 /* MaterialPluginEvent.GetAnimatables */, this._eventInfo);
1052
- return this._eventInfo.animatables;
1053
- }
1054
- /**
1055
- * Gets the active textures from the material
1056
- * @returns an array of textures
1057
- */
1058
- getActiveTextures() {
1059
- this._eventInfo.activeTextures = [];
1060
- this._callbackPluginEventGeneric(512 /* MaterialPluginEvent.GetActiveTextures */, this._eventInfo);
1061
- return this._eventInfo.activeTextures;
1062
- }
1063
- /**
1064
- * Specifies if the material uses a texture
1065
- * @param texture defines the texture to check against the material
1066
- * @returns a boolean specifying if the material uses the texture
1067
- */
1068
- hasTexture(texture) {
1069
- this._eventInfo.hasTexture = false;
1070
- this._eventInfo.texture = texture;
1071
- this._callbackPluginEventGeneric(1024 /* MaterialPluginEvent.HasTexture */, this._eventInfo);
1072
- return this._eventInfo.hasTexture;
1073
- }
1074
- /**
1075
- * Makes a duplicate of the material, and gives it a new name
1076
- * @param name defines the new name for the duplicated material
1077
- * @returns the cloned material
1078
- */
1079
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1080
- clone(name) {
1081
- return null;
1082
- }
1083
- _clonePlugins(targetMaterial, rootUrl) {
1084
- const serializationObject = {};
1085
- // Create plugins in targetMaterial in case they don't exist
1086
- this._serializePlugins(serializationObject);
1087
- Material._ParsePlugins(serializationObject, targetMaterial, this._scene, rootUrl);
1088
- // Copy the properties of the current plugins to the cloned material's plugins
1089
- if (this.pluginManager) {
1090
- for (const plugin of this.pluginManager._plugins) {
1091
- const targetPlugin = targetMaterial.pluginManager.getPlugin(plugin.name);
1092
- if (targetPlugin) {
1093
- plugin.copyTo(targetPlugin);
1094
- }
1095
- }
1096
- }
1097
- }
1098
- /**
1099
- * Gets the meshes bound to the material
1100
- * @returns an array of meshes bound to the material
1101
- */
1102
- getBindedMeshes() {
1103
- if (this.meshMap) {
1104
- const result = [];
1105
- for (const meshId in this.meshMap) {
1106
- const mesh = this.meshMap[meshId];
1107
- if (mesh) {
1108
- result.push(mesh);
1109
- }
1110
- }
1111
- return result;
1112
- }
1113
- else {
1114
- const meshes = this._scene.meshes;
1115
- return meshes.filter((mesh) => mesh.material === this);
1116
- }
1117
- }
1118
- /**
1119
- * Force shader compilation
1120
- * @param mesh defines the mesh associated with this material
1121
- * @param onCompiled defines a function to execute once the material is compiled
1122
- * @param options defines the options to configure the compilation
1123
- * @param onError defines a function to execute if the material fails compiling
1124
- */
1125
- forceCompilation(mesh, onCompiled, options, onError) {
1126
- const localOptions = {
1127
- clipPlane: false,
1128
- useInstances: false,
1129
- ...options,
1130
- };
1131
- const scene = this.getScene();
1132
- const currentHotSwapingState = this.allowShaderHotSwapping;
1133
- this.allowShaderHotSwapping = false; // Turned off to let us evaluate the real compilation state
1134
- const checkReady = () => {
1135
- if (!this._scene || !this._scene.getEngine()) {
1136
- return;
1137
- }
1138
- const clipPlaneState = scene.clipPlane;
1139
- if (localOptions.clipPlane) {
1140
- scene.clipPlane = new Plane(0, 0, 0, 1);
1141
- }
1142
- if (this._storeEffectOnSubMeshes) {
1143
- let allDone = true, lastError = null;
1144
- if (mesh.subMeshes) {
1145
- const tempSubMesh = new SubMesh(0, 0, 0, 0, 0, mesh, undefined, false, false);
1146
- if (tempSubMesh.materialDefines) {
1147
- tempSubMesh.materialDefines._renderId = -1;
1148
- }
1149
- if (!this.isReadyForSubMesh(mesh, tempSubMesh, localOptions.useInstances)) {
1150
- if (tempSubMesh.effect && tempSubMesh.effect.getCompilationError() && tempSubMesh.effect.allFallbacksProcessed()) {
1151
- lastError = tempSubMesh.effect.getCompilationError();
1152
- }
1153
- else {
1154
- allDone = false;
1155
- setTimeout(checkReady, 16);
1156
- }
1157
- }
1158
- }
1159
- if (allDone) {
1160
- this.allowShaderHotSwapping = currentHotSwapingState;
1161
- if (lastError) {
1162
- if (onError) {
1163
- onError(lastError);
1164
- }
1165
- }
1166
- if (onCompiled) {
1167
- onCompiled(this);
1168
- }
1169
- }
1170
- }
1171
- else {
1172
- if (this.isReady()) {
1173
- this.allowShaderHotSwapping = currentHotSwapingState;
1174
- if (onCompiled) {
1175
- onCompiled(this);
1176
- }
1177
- }
1178
- else {
1179
- setTimeout(checkReady, 16);
1180
- }
1181
- }
1182
- if (localOptions.clipPlane) {
1183
- scene.clipPlane = clipPlaneState;
1184
- }
1185
- };
1186
- checkReady();
1187
- }
1188
- /**
1189
- * Force shader compilation
1190
- * @param mesh defines the mesh that will use this material
1191
- * @param options defines additional options for compiling the shaders
1192
- * @returns a promise that resolves when the compilation completes
1193
- */
1194
- async forceCompilationAsync(mesh, options) {
1195
- return await new Promise((resolve, reject) => {
1196
- this.forceCompilation(mesh, () => {
1197
- resolve();
1198
- }, options, (reason) => {
1199
- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
1200
- reject(reason);
1201
- });
1202
- });
1203
- }
1204
- /**
1205
- * Marks a define in the material to indicate that it needs to be re-computed
1206
- * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
1207
- */
1208
- markAsDirty(flag) {
1209
- if (this.getScene().blockMaterialDirtyMechanism || this._blockDirtyMechanism) {
1210
- return;
1211
- }
1212
- Material._DirtyCallbackArray.length = 0;
1213
- if (flag & Material.ImageProcessingDirtyFlag) {
1214
- Material._DirtyCallbackArray.push(Material._ImageProcessingDirtyCallBack);
1215
- }
1216
- if (flag & Material.TextureDirtyFlag) {
1217
- Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
1218
- }
1219
- if (flag & Material.LightDirtyFlag) {
1220
- Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
1221
- }
1222
- if (flag & Material.FresnelDirtyFlag) {
1223
- Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
1224
- }
1225
- if (flag & Material.AttributesDirtyFlag) {
1226
- Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
1227
- }
1228
- if (flag & Material.MiscDirtyFlag) {
1229
- Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
1230
- }
1231
- if (flag & Material.PrePassDirtyFlag) {
1232
- Material._DirtyCallbackArray.push(Material._PrePassDirtyCallBack);
1233
- }
1234
- if (Material._DirtyCallbackArray.length) {
1235
- this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
1236
- }
1237
- this.getScene().resetCachedMaterial();
1238
- }
1239
- /**
1240
- * Resets the draw wrappers cache for all submeshes that are using this material
1241
- */
1242
- resetDrawCache() {
1243
- const meshes = this.getScene().meshes;
1244
- for (const mesh of meshes) {
1245
- if (!mesh.subMeshes) {
1246
- continue;
1247
- }
1248
- for (const subMesh of mesh.subMeshes) {
1249
- if (subMesh.getMaterial() !== this) {
1250
- continue;
1251
- }
1252
- subMesh.resetDrawCache();
1253
- }
1254
- }
1255
- }
1256
- /**
1257
- * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
1258
- * @param func defines a function which checks material defines against the submeshes
1259
- */
1260
- _markAllSubMeshesAsDirty(func) {
1261
- const scene = this.getScene();
1262
- if (scene.blockMaterialDirtyMechanism || this._blockDirtyMechanism) {
1263
- return;
1264
- }
1265
- const meshes = scene.meshes;
1266
- for (const mesh of meshes) {
1267
- if (!mesh.subMeshes) {
1268
- continue;
1269
- }
1270
- for (const subMesh of mesh.subMeshes) {
1271
- // We want to skip the submeshes which are not using this material or which have not yet rendered at least once
1272
- const material = subMesh.getMaterial() || (scene._hasDefaultMaterial ? scene.defaultMaterial : null);
1273
- if (material !== this) {
1274
- continue;
1275
- }
1276
- for (const drawWrapper of subMesh._drawWrappers) {
1277
- if (!drawWrapper || !drawWrapper.defines || !drawWrapper.defines.markAllAsDirty) {
1278
- continue;
1279
- }
1280
- if (this._materialContext === drawWrapper.materialContext) {
1281
- func(drawWrapper.defines);
1282
- }
1283
- }
1284
- }
1285
- }
1286
- }
1287
- /**
1288
- * Indicates that the scene should check if the rendering now needs a prepass
1289
- */
1290
- _markScenePrePassDirty() {
1291
- if (this.getScene().blockMaterialDirtyMechanism || this._blockDirtyMechanism) {
1292
- return;
1293
- }
1294
- const prePassRenderer = this.getScene().enablePrePassRenderer();
1295
- if (prePassRenderer) {
1296
- prePassRenderer.markAsDirty();
1297
- }
1298
- }
1299
- /**
1300
- * Indicates that we need to re-calculated for all submeshes
1301
- */
1302
- _markAllSubMeshesAsAllDirty() {
1303
- this._markAllSubMeshesAsDirty(Material._AllDirtyCallBack);
1304
- }
1305
- /**
1306
- * Indicates that image processing needs to be re-calculated for all submeshes
1307
- */
1308
- _markAllSubMeshesAsImageProcessingDirty() {
1309
- this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
1310
- }
1311
- /**
1312
- * Indicates that textures need to be re-calculated for all submeshes
1313
- */
1314
- _markAllSubMeshesAsTexturesDirty() {
1315
- this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
1316
- }
1317
- /**
1318
- * Indicates that fresnel needs to be re-calculated for all submeshes
1319
- */
1320
- _markAllSubMeshesAsFresnelDirty() {
1321
- this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
1322
- }
1323
- /**
1324
- * Indicates that fresnel and misc need to be re-calculated for all submeshes
1325
- */
1326
- _markAllSubMeshesAsFresnelAndMiscDirty() {
1327
- this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
1328
- }
1329
- /**
1330
- * Indicates that lights need to be re-calculated for all submeshes
1331
- */
1332
- _markAllSubMeshesAsLightsDirty() {
1333
- this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
1334
- }
1335
- /**
1336
- * Indicates that attributes need to be re-calculated for all submeshes
1337
- */
1338
- _markAllSubMeshesAsAttributesDirty() {
1339
- this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
1340
- }
1341
- /**
1342
- * Indicates that misc needs to be re-calculated for all submeshes
1343
- */
1344
- _markAllSubMeshesAsMiscDirty() {
1345
- this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
1346
- }
1347
- /**
1348
- * Indicates that prepass needs to be re-calculated for all submeshes
1349
- */
1350
- _markAllSubMeshesAsPrePassDirty() {
1351
- this._markAllSubMeshesAsDirty(Material._PrePassDirtyCallBack);
1352
- }
1353
- /**
1354
- * Indicates that textures and misc need to be re-calculated for all submeshes
1355
- */
1356
- _markAllSubMeshesAsTexturesAndMiscDirty() {
1357
- this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
1358
- }
1359
- _checkScenePerformancePriority() {
1360
- if (this._scene.performancePriority !== 0 /* ScenePerformancePriority.BackwardCompatible */) {
1361
- this.checkReadyOnlyOnce = true;
1362
- // re-set the flag when the perf priority changes
1363
- const observer = this._scene.onScenePerformancePriorityChangedObservable.addOnce(() => {
1364
- this.checkReadyOnlyOnce = false;
1365
- });
1366
- // if this material is disposed before the scene is disposed, cleanup the observer
1367
- this.onDisposeObservable.add(() => {
1368
- this._scene.onScenePerformancePriorityChangedObservable.remove(observer);
1369
- });
1370
- }
1371
- }
1372
- /**
1373
- * Sets the required values to the prepass renderer.
1374
- * @param prePassRenderer defines the prepass renderer to setup.
1375
- * @returns true if the pre pass is needed.
1376
- */
1377
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1378
- setPrePassRenderer(prePassRenderer) {
1379
- // Do Nothing by default
1380
- return false;
1381
- }
1382
- /**
1383
- * Disposes the material
1384
- * @param _forceDisposeEffect kept for backward compat. We reference count the effect now.
1385
- * @param forceDisposeTextures specifies if textures should be forcefully disposed
1386
- * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
1387
- */
1388
- dispose(_forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
1389
- const scene = this.getScene();
1390
- // Animations
1391
- scene.stopAnimation(this);
1392
- scene.freeProcessedMaterials();
1393
- // Remove from scene
1394
- scene.removeMaterial(this);
1395
- this._eventInfo.forceDisposeTextures = forceDisposeTextures;
1396
- this._callbackPluginEventGeneric(2 /* MaterialPluginEvent.Disposed */, this._eventInfo);
1397
- if (this._parentContainer) {
1398
- const index = this._parentContainer.materials.indexOf(this);
1399
- if (index > -1) {
1400
- this._parentContainer.materials.splice(index, 1);
1401
- }
1402
- this._parentContainer = null;
1403
- }
1404
- if (notBoundToMesh !== true) {
1405
- // Remove from meshes
1406
- if (this.meshMap) {
1407
- for (const meshId in this.meshMap) {
1408
- const mesh = this.meshMap[meshId];
1409
- this._disposeMeshResources(mesh);
1410
- }
1411
- }
1412
- else {
1413
- const meshes = scene.meshes;
1414
- for (const mesh of meshes) {
1415
- this._disposeMeshResources(mesh);
1416
- }
1417
- }
1418
- }
1419
- this._uniformBuffer.dispose();
1420
- // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
1421
- if (this._drawWrapper.effect) {
1422
- if (!this._storeEffectOnSubMeshes) {
1423
- this._drawWrapper.effect.dispose();
1424
- }
1425
- this._drawWrapper.effect = null;
1426
- }
1427
- this.metadata = null;
1428
- // Callback
1429
- this.onDisposeObservable.notifyObservers(this);
1430
- this.onDisposeObservable.clear();
1431
- if (this._onBindObservable) {
1432
- this._onBindObservable.clear();
1433
- }
1434
- if (this._onUnBindObservable) {
1435
- this._onUnBindObservable.clear();
1436
- }
1437
- if (this._onEffectCreatedObservable) {
1438
- this._onEffectCreatedObservable.clear();
1439
- }
1440
- if (this._eventInfo) {
1441
- this._eventInfo = {};
1442
- }
1443
- this._isDisposed = true;
1444
- }
1445
- _disposeMeshResources(mesh) {
1446
- if (!mesh) {
1447
- return;
1448
- }
1449
- const geometry = mesh.geometry;
1450
- const materialForRenderPass = mesh._internalAbstractMeshDataInfo._materialForRenderPass;
1451
- if (this._storeEffectOnSubMeshes) {
1452
- if (mesh.subMeshes && materialForRenderPass) {
1453
- for (const subMesh of mesh.subMeshes) {
1454
- const drawWrappers = subMesh._drawWrappers;
1455
- for (let renderPassIndex = 0; renderPassIndex < drawWrappers.length; renderPassIndex++) {
1456
- const effect = drawWrappers[renderPassIndex]?.effect;
1457
- if (!effect) {
1458
- continue;
1459
- }
1460
- const material = materialForRenderPass[renderPassIndex];
1461
- if (material === this) {
1462
- geometry?._releaseVertexArrayObject(effect);
1463
- subMesh._removeDrawWrapper(renderPassIndex, true, true);
1464
- }
1465
- }
1466
- }
1467
- }
1468
- }
1469
- else {
1470
- geometry?._releaseVertexArrayObject(this._drawWrapper.effect);
1471
- }
1472
- if (mesh.material === this && !mesh.sourceMesh) {
1473
- mesh.material = null;
1474
- }
1475
- }
1476
- /**
1477
- * Serializes this material
1478
- * @returns the serialized material object
1479
- */
1480
- serialize() {
1481
- const serializationObject = SerializationHelper.Serialize(this);
1482
- serializationObject.stencil = this.stencil.serialize();
1483
- serializationObject.uniqueId = this.uniqueId;
1484
- SerializationHelper.AppendSerializedAnimations(this, serializationObject);
1485
- this._serializePlugins(serializationObject);
1486
- return serializationObject;
1487
- }
1488
- _serializePlugins(serializationObject) {
1489
- serializationObject.plugins = {};
1490
- if (this.pluginManager) {
1491
- for (const plugin of this.pluginManager._plugins) {
1492
- if (!plugin.doNotSerialize) {
1493
- serializationObject.plugins[plugin.getClassName()] = plugin.serialize();
1494
- }
1495
- }
1496
- }
1497
- }
1498
- /**
1499
- * Parses the alpha mode from the material data to parse
1500
- * @param parsedMaterial defines the material data to parse
1501
- * @param material defines the material to update
1502
- */
1503
- static ParseAlphaMode(parsedMaterial, material) {
1504
- if (parsedMaterial._alphaMode !== undefined) {
1505
- material._alphaMode = Array.isArray(parsedMaterial._alphaMode) ? parsedMaterial._alphaMode : [parsedMaterial._alphaMode];
1506
- }
1507
- else if (parsedMaterial.alphaMode !== undefined) {
1508
- material._alphaMode = Array.isArray(parsedMaterial.alphaMode) ? parsedMaterial.alphaMode : [parsedMaterial.alphaMode];
1509
- }
1510
- else {
1511
- material._alphaMode = [2];
1512
- }
1513
- }
1514
- /**
1515
- * Creates a material from parsed material data
1516
- * @param parsedMaterial defines parsed material data
1517
- * @param scene defines the hosting scene
1518
- * @param rootUrl defines the root URL to use to load textures
1519
- * @returns a new material
1520
- */
1521
- static Parse(parsedMaterial, scene, rootUrl) {
1522
- if (!parsedMaterial.customType) {
1523
- parsedMaterial.customType = "BABYLON.StandardMaterial";
1524
- }
1525
- else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
1526
- parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
1527
- if (!BABYLON.LegacyPBRMaterial) {
1528
- Logger.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
1529
- return null;
1872
+ _a.ForceVertexOutputInvariant = false,
1873
+ _a._AllDirtyCallBack = (defines) => defines.markAllAsDirty(),
1874
+ _a._ImageProcessingDirtyCallBack = (defines) => defines.markAsImageProcessingDirty(),
1875
+ _a._TextureDirtyCallBack = (defines) => defines.markAsTexturesDirty(),
1876
+ _a._FresnelDirtyCallBack = (defines) => defines.markAsFresnelDirty(),
1877
+ _a._MiscDirtyCallBack = (defines) => defines.markAsMiscDirty(),
1878
+ _a._PrePassDirtyCallBack = (defines) => defines.markAsPrePassDirty(),
1879
+ _a._LightsDirtyCallBack = (defines) => defines.markAsLightDirty(),
1880
+ _a._AttributeDirtyCallBack = (defines) => defines.markAsAttributesDirty(),
1881
+ _a._FresnelAndMiscDirtyCallBack = (defines) => {
1882
+ _a._FresnelDirtyCallBack(defines);
1883
+ _a._MiscDirtyCallBack(defines);
1884
+ },
1885
+ _a._TextureAndMiscDirtyCallBack = (defines) => {
1886
+ _a._TextureDirtyCallBack(defines);
1887
+ _a._MiscDirtyCallBack(defines);
1888
+ },
1889
+ _a._DirtyCallbackArray = [],
1890
+ _a._RunDirtyCallBacks = (defines) => {
1891
+ for (const cb of _a._DirtyCallbackArray) {
1892
+ cb(defines);
1530
1893
  }
1531
- }
1532
- const materialType = Tools.Instantiate(parsedMaterial.customType);
1533
- const material = materialType.Parse(parsedMaterial, scene, rootUrl);
1534
- material._loadedUniqueId = parsedMaterial.uniqueId;
1535
- Material.ParseAlphaMode(parsedMaterial, material);
1536
- Material._ParseAnimations(parsedMaterial, material);
1537
- return material;
1538
- }
1539
- static _ParseAnimations(parsedMaterial, material) {
1540
- if (parsedMaterial.animations) {
1541
- for (let animationIndex = 0; animationIndex < parsedMaterial.animations.length; animationIndex++) {
1542
- const parsedAnimation = parsedMaterial.animations[animationIndex];
1543
- const internalClass = GetClass("BABYLON.Animation");
1544
- if (internalClass) {
1545
- if (!material.animations) {
1546
- material.animations = [];
1547
- }
1548
- material.animations.push(internalClass.Parse(parsedAnimation));
1549
- }
1550
- }
1551
- }
1552
- }
1553
- static _ParsePlugins(serializationObject, material, scene, rootUrl) {
1554
- if (!serializationObject.plugins) {
1555
- return;
1556
- }
1557
- for (const pluginClassName in serializationObject.plugins) {
1558
- const pluginData = serializationObject.plugins[pluginClassName];
1559
- let plugin = material.pluginManager?.getPlugin(pluginData.name);
1560
- if (!plugin) {
1561
- const pluginClassType = Tools.Instantiate("BABYLON." + pluginClassName);
1562
- if (pluginClassType) {
1563
- plugin = new pluginClassType(material);
1564
- }
1565
- }
1566
- plugin?.parse(pluginData, scene, rootUrl);
1567
- }
1568
- }
1569
- }
1570
- /**
1571
- * Returns the triangle fill mode
1572
- */
1573
- Material.TriangleFillMode = 0;
1574
- /**
1575
- * Returns the wireframe mode
1576
- */
1577
- Material.WireFrameFillMode = 1;
1578
- /**
1579
- * Returns the point fill mode
1580
- */
1581
- Material.PointFillMode = 2;
1582
- /**
1583
- * Returns the point list draw mode
1584
- */
1585
- Material.PointListDrawMode = 3;
1586
- /**
1587
- * Returns the line list draw mode
1588
- */
1589
- Material.LineListDrawMode = 4;
1590
- /**
1591
- * Returns the line loop draw mode
1592
- */
1593
- Material.LineLoopDrawMode = 5;
1594
- /**
1595
- * Returns the line strip draw mode
1596
- */
1597
- Material.LineStripDrawMode = 6;
1598
- /**
1599
- * Returns the triangle strip draw mode
1600
- */
1601
- Material.TriangleStripDrawMode = 7;
1602
- /**
1603
- * Returns the triangle fan draw mode
1604
- */
1605
- Material.TriangleFanDrawMode = 8;
1606
- /**
1607
- * Stores the clock-wise side orientation
1608
- */
1609
- Material.ClockWiseSideOrientation = 0;
1610
- /**
1611
- * Stores the counter clock-wise side orientation
1612
- */
1613
- Material.CounterClockWiseSideOrientation = 1;
1614
- /**
1615
- * The dirty image processing flag value
1616
- */
1617
- Material.ImageProcessingDirtyFlag = 64;
1618
- /**
1619
- * The dirty texture flag value
1620
- */
1621
- Material.TextureDirtyFlag = 1;
1622
- /**
1623
- * The dirty light flag value
1624
- */
1625
- Material.LightDirtyFlag = 2;
1626
- /**
1627
- * The dirty fresnel flag value
1628
- */
1629
- Material.FresnelDirtyFlag = 4;
1630
- /**
1631
- * The dirty attribute flag value
1632
- */
1633
- Material.AttributesDirtyFlag = 8;
1634
- /**
1635
- * The dirty misc flag value
1636
- */
1637
- Material.MiscDirtyFlag = 16;
1638
- /**
1639
- * The dirty prepass flag value
1640
- */
1641
- Material.PrePassDirtyFlag = 32;
1642
- /**
1643
- * The all dirty flag value
1644
- */
1645
- Material.AllDirtyFlag = 127;
1646
- /**
1647
- * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
1648
- */
1649
- Material.MATERIAL_OPAQUE = 0;
1650
- /**
1651
- * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
1652
- */
1653
- Material.MATERIAL_ALPHATEST = 1;
1654
- /**
1655
- * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
1656
- */
1657
- Material.MATERIAL_ALPHABLEND = 2;
1658
- /**
1659
- * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
1660
- * They are also discarded below the alpha cutoff threshold to improve performances.
1661
- */
1662
- Material.MATERIAL_ALPHATESTANDBLEND = 3;
1663
- /**
1664
- * The Whiteout method is used to blend normals.
1665
- * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
1666
- */
1667
- Material.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0;
1668
- /**
1669
- * The Reoriented Normal Mapping method is used to blend normals.
1670
- * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
1671
- */
1672
- Material.MATERIAL_NORMALBLENDMETHOD_RNM = 1;
1673
- /**
1674
- * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
1675
- */
1676
- Material.LIGHTFALLOFF_PHYSICAL = 0;
1677
- /**
1678
- * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
1679
- * to enhance interoperability with other engines.
1680
- */
1681
- Material.LIGHTFALLOFF_GLTF = 1;
1682
- /**
1683
- * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
1684
- * to enhance interoperability with other materials.
1685
- */
1686
- Material.LIGHTFALLOFF_STANDARD = 2;
1687
- /**
1688
- * Event observable which raises global events common to all materials (like MaterialPluginEvent.Created)
1689
- */
1690
- Material.OnEventObservable = new Observable();
1691
- /**
1692
- * If true, all materials will have their vertex output set to invariant (see the vertexOutputInvariant property).
1693
- */
1694
- Material.ForceVertexOutputInvariant = false;
1695
- Material._AllDirtyCallBack = (defines) => defines.markAllAsDirty();
1696
- Material._ImageProcessingDirtyCallBack = (defines) => defines.markAsImageProcessingDirty();
1697
- Material._TextureDirtyCallBack = (defines) => defines.markAsTexturesDirty();
1698
- Material._FresnelDirtyCallBack = (defines) => defines.markAsFresnelDirty();
1699
- Material._MiscDirtyCallBack = (defines) => defines.markAsMiscDirty();
1700
- Material._PrePassDirtyCallBack = (defines) => defines.markAsPrePassDirty();
1701
- Material._LightsDirtyCallBack = (defines) => defines.markAsLightDirty();
1702
- Material._AttributeDirtyCallBack = (defines) => defines.markAsAttributesDirty();
1703
- Material._FresnelAndMiscDirtyCallBack = (defines) => {
1704
- Material._FresnelDirtyCallBack(defines);
1705
- Material._MiscDirtyCallBack(defines);
1706
- };
1707
- Material._TextureAndMiscDirtyCallBack = (defines) => {
1708
- Material._TextureDirtyCallBack(defines);
1709
- Material._MiscDirtyCallBack(defines);
1710
- };
1711
- Material._DirtyCallbackArray = [];
1712
- Material._RunDirtyCallBacks = (defines) => {
1713
- for (const cb of Material._DirtyCallbackArray) {
1714
- cb(defines);
1715
- }
1716
- };
1717
- __decorate([
1718
- serialize()
1719
- ], Material.prototype, "id", void 0);
1720
- __decorate([
1721
- serialize()
1722
- ], Material.prototype, "uniqueId", void 0);
1723
- __decorate([
1724
- serialize()
1725
- ], Material.prototype, "name", void 0);
1726
- __decorate([
1727
- serialize()
1728
- ], Material.prototype, "metadata", void 0);
1729
- __decorate([
1730
- serialize()
1731
- ], Material.prototype, "checkReadyOnEveryCall", void 0);
1732
- __decorate([
1733
- serialize()
1734
- ], Material.prototype, "checkReadyOnlyOnce", void 0);
1735
- __decorate([
1736
- serialize()
1737
- ], Material.prototype, "state", void 0);
1738
- __decorate([
1739
- serialize("alpha")
1740
- ], Material.prototype, "_alpha", void 0);
1741
- __decorate([
1742
- serialize("backFaceCulling")
1743
- ], Material.prototype, "_backFaceCulling", void 0);
1744
- __decorate([
1745
- serialize("textureRepetitionMode")
1746
- ], Material.prototype, "_textureRepetitionMode", void 0);
1747
- __decorate([
1748
- serialize("textureRepetitionHexTilingParams")
1749
- ], Material.prototype, "textureRepetitionHexTilingParams", void 0);
1750
- __decorate([
1751
- serialize("cullBackFaces")
1752
- ], Material.prototype, "_cullBackFaces", void 0);
1753
- __decorate([
1754
- serialize()
1755
- ], Material.prototype, "sideOrientation", void 0);
1756
- __decorate([
1757
- serialize()
1758
- ], Material.prototype, "_alphaMode", void 0);
1759
- __decorate([
1760
- serialize()
1761
- ], Material.prototype, "_needDepthPrePass", void 0);
1762
- __decorate([
1763
- serialize()
1764
- ], Material.prototype, "disableDepthWrite", void 0);
1765
- __decorate([
1766
- serialize()
1767
- ], Material.prototype, "disableColorWrite", void 0);
1768
- __decorate([
1769
- serialize()
1770
- ], Material.prototype, "forceDepthWrite", void 0);
1771
- __decorate([
1772
- serialize()
1773
- ], Material.prototype, "depthFunction", void 0);
1774
- __decorate([
1775
- serialize()
1776
- ], Material.prototype, "separateCullingPass", void 0);
1777
- __decorate([
1778
- serialize("fogEnabled")
1779
- ], Material.prototype, "_fogEnabled", void 0);
1780
- __decorate([
1781
- serialize()
1782
- ], Material.prototype, "pointSize", void 0);
1783
- __decorate([
1784
- serialize()
1785
- ], Material.prototype, "zOffset", void 0);
1786
- __decorate([
1787
- serialize()
1788
- ], Material.prototype, "zOffsetUnits", void 0);
1789
- __decorate([
1790
- serialize()
1791
- ], Material.prototype, "pointsCloud", null);
1792
- __decorate([
1793
- serialize()
1794
- ], Material.prototype, "fillMode", null);
1795
- __decorate([
1796
- serialize()
1797
- ], Material.prototype, "useLogarithmicDepth", null);
1798
- __decorate([
1799
- serialize()
1800
- ], Material.prototype, "_isVertexOutputInvariant", void 0);
1801
- __decorate([
1802
- serialize()
1803
- ], Material.prototype, "transparencyMode", null);
1894
+ },
1895
+ _a;
1896
+ })();
1897
+ export { Material };
1804
1898
  // #region GENERATED_SIDE_EFFECT_STUBS — do not edit, regenerate with `npm run generate:side-effect-stubs`
1805
1899
  import { _MissingSideEffectProperty } from "../Misc/devTools.js";
1806
1900
  if (!Object.getOwnPropertyDescriptor(Material.prototype, "pluginManager")) {