@onerjs/core 8.53.5 → 8.53.7

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,6 +1,6 @@
1
1
  /** This file must only contain pure code and pure imports */
2
2
  var _a, _b, _c;
3
- import { __decorate } from "../tslib.es6.js";
3
+ import { __esDecorate, __runInitializers } from "../tslib.es6.js";
4
4
  import { Observable } from "../Misc/observable.pure.js";
5
5
  import { Quaternion, Matrix, Vector3, TmpVectors } from "../Maths/math.vector.pure.js";
6
6
  import { VertexBuffer } from "../Buffers/buffer.pure.js";
@@ -231,2264 +231,2275 @@ class _InternalAbstractMeshDataInfo {
231
231
  /**
232
232
  * Class used to store all common mesh properties
233
233
  */
234
- export class AbstractMesh extends TransformNode {
235
- /**
236
- * No billboard
237
- */
238
- static get BILLBOARDMODE_NONE() {
239
- return TransformNode.BILLBOARDMODE_NONE;
240
- }
241
- /** Billboard on X axis */
242
- static get BILLBOARDMODE_X() {
243
- return TransformNode.BILLBOARDMODE_X;
244
- }
245
- /** Billboard on Y axis */
246
- static get BILLBOARDMODE_Y() {
247
- return TransformNode.BILLBOARDMODE_Y;
248
- }
249
- /** Billboard on Z axis */
250
- static get BILLBOARDMODE_Z() {
251
- return TransformNode.BILLBOARDMODE_Z;
252
- }
253
- /** Billboard on all axes */
254
- static get BILLBOARDMODE_ALL() {
255
- return TransformNode.BILLBOARDMODE_ALL;
256
- }
257
- /** Billboard on using position instead of orientation */
258
- static get BILLBOARDMODE_USE_POSITION() {
259
- return TransformNode.BILLBOARDMODE_USE_POSITION;
260
- }
261
- /**
262
- * Gets the number of facets in the mesh
263
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#what-is-a-mesh-facet
264
- */
265
- get facetNb() {
266
- return this._internalAbstractMeshDataInfo._facetData.facetNb;
267
- }
268
- /**
269
- * Gets or set the number (integer) of subdivisions per axis in the partitioning space
270
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#tweaking-the-partitioning
271
- */
272
- get partitioningSubdivisions() {
273
- return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions;
274
- }
275
- set partitioningSubdivisions(nb) {
276
- this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = nb;
277
- }
278
- /**
279
- * The ratio (float) to apply to the bounding box size to set to the partitioning space.
280
- * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
281
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#tweaking-the-partitioning
282
- */
283
- // eslint-disable-next-line @typescript-eslint/naming-convention
284
- get partitioningBBoxRatio() {
285
- return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio;
286
- }
287
- // eslint-disable-next-line @typescript-eslint/naming-convention
288
- set partitioningBBoxRatio(ratio) {
289
- this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = ratio;
290
- }
291
- /**
292
- * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
293
- * Works only for updatable meshes.
294
- * Doesn't work with multi-materials
295
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#facet-depth-sort
296
- */
297
- get mustDepthSortFacets() {
298
- return this._internalAbstractMeshDataInfo._facetData.facetDepthSort;
299
- }
300
- set mustDepthSortFacets(sort) {
301
- this._internalAbstractMeshDataInfo._facetData.facetDepthSort = sort;
302
- }
303
- /**
304
- * The location (Vector3) where the facet depth sort must be computed from.
305
- * By default, the active camera position.
306
- * Used only when facet depth sort is enabled
307
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#facet-depth-sort
308
- */
309
- get facetDepthSortFrom() {
310
- return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom;
311
- }
312
- set facetDepthSortFrom(location) {
313
- this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = location;
314
- }
315
- /** number of collision detection tries. Change this value if not all collisions are detected and handled properly */
316
- get collisionRetryCount() {
317
- return this._internalAbstractMeshDataInfo._collisionRetryCount;
318
- }
319
- set collisionRetryCount(retryCount) {
320
- this._internalAbstractMeshDataInfo._collisionRetryCount = retryCount;
321
- }
322
- /**
323
- * gets a boolean indicating if facetData is enabled
324
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#what-is-a-mesh-facet
325
- */
326
- get isFacetDataEnabled() {
327
- return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled;
328
- }
329
- /**
330
- * Gets or sets the morph target manager
331
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets
332
- */
333
- get morphTargetManager() {
334
- return this._internalAbstractMeshDataInfo._morphTargetManager;
335
- }
336
- set morphTargetManager(value) {
337
- if (this._internalAbstractMeshDataInfo._morphTargetManager === value) {
338
- return;
339
- }
340
- this._internalAbstractMeshDataInfo._morphTargetManager = value;
341
- this._syncGeometryWithMorphTargetManager();
342
- }
343
- /**
344
- * Gets or sets the baked vertex animation manager
345
- * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/baked_texture_animations
346
- */
347
- get bakedVertexAnimationManager() {
348
- return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager;
349
- }
350
- set bakedVertexAnimationManager(value) {
351
- if (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager === value) {
352
- return;
353
- }
354
- this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = value;
355
- this._markSubMeshesAsAttributesDirty();
356
- }
357
- /** @internal */
358
- _syncGeometryWithMorphTargetManager() { }
359
- /**
360
- * @internal
361
- */
362
- _updateNonUniformScalingState(value) {
363
- if (!super._updateNonUniformScalingState(value)) {
364
- return false;
365
- }
366
- this._markSubMeshesAsMiscDirty();
367
- return true;
368
- }
369
- /** @internal */
370
- get rawBoundingInfo() {
371
- return this._internalAbstractMeshDataInfo._rawBoundingInfo;
372
- }
373
- set rawBoundingInfo(boundingInfo) {
374
- this._internalAbstractMeshDataInfo._rawBoundingInfo = boundingInfo;
375
- }
376
- /** Set a function to call when this mesh collides with another one */
377
- set onCollide(callback) {
378
- if (this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver) {
379
- this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver);
380
- }
381
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(callback);
382
- }
383
- /** Set a function to call when the collision's position changes */
384
- set onCollisionPositionChange(callback) {
385
- if (this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver) {
386
- this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver);
387
- }
388
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
389
- }
390
- /**
391
- * Gets or sets mesh visibility between 0 and 1 (default is 1)
392
- */
393
- get visibility() {
394
- return this._internalAbstractMeshDataInfo._visibility;
395
- }
396
- /**
397
- * Gets or sets mesh visibility between 0 and 1 (default is 1)
398
- */
399
- set visibility(value) {
400
- if (this._internalAbstractMeshDataInfo._visibility === value) {
401
- return;
402
- }
403
- const oldValue = this._internalAbstractMeshDataInfo._visibility;
404
- this._internalAbstractMeshDataInfo._visibility = value;
405
- if ((oldValue === 1 && value !== 1) || (oldValue !== 1 && value === 1)) {
406
- this._markSubMeshesAsDirty((defines) => {
407
- defines.markAsMiscDirty();
408
- defines.markAsPrePassDirty();
409
- });
410
- }
411
- }
412
- /**
413
- * Gets or sets the property which disables the test that is checking that the mesh under the pointer is the same than the previous time we tested for it (default: false).
414
- * Set this property to true if you want thin instances picking to be reported accurately when moving over the mesh.
415
- * Note that setting this property to true will incur some performance penalties when dealing with pointer events for this mesh so use it sparingly.
416
- */
417
- get pointerOverDisableMeshTesting() {
418
- return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting;
419
- }
420
- set pointerOverDisableMeshTesting(disable) {
421
- this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting = disable;
422
- }
423
- /**
424
- * Specifies the rendering group id for this mesh (0 by default)
425
- * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering#rendering-groups
426
- */
427
- get renderingGroupId() {
428
- return this._internalAbstractMeshDataInfo._renderingGroupId;
429
- }
430
- set renderingGroupId(value) {
431
- this._internalAbstractMeshDataInfo._renderingGroupId = value;
432
- }
433
- /**
434
- * Control if the material should be rendered
435
- */
436
- get materialEnabled() {
437
- return this._internalAbstractMeshDataInfo._materialEnabled;
438
- }
439
- set materialEnabled(enabled) {
440
- if (this._internalAbstractMeshDataInfo._materialEnabled === enabled) {
441
- return;
442
- }
443
- this._internalAbstractMeshDataInfo._materialEnabled = enabled;
444
- }
445
- /**
446
- * Control if the camera should render material
447
- */
448
- get doNotRenderMaterialCameraUniqueIds() {
449
- return this._internalAbstractMeshDataInfo._doNotRenderMaterialCameraUniqueIds;
450
- }
451
- set doNotRenderMaterialCameraUniqueIds(ids) {
452
- if (this._internalAbstractMeshDataInfo._doNotRenderMaterialCameraUniqueIds === ids) {
453
- return;
454
- }
455
- this._internalAbstractMeshDataInfo._doNotRenderMaterialCameraUniqueIds = ids;
456
- }
457
- /** Gets or sets current material */
458
- get material() {
459
- return this._internalAbstractMeshDataInfo._material;
460
- }
461
- set material(value) {
462
- this._setMaterial(value);
463
- }
464
- /** @internal */
465
- _setMaterial(value) {
466
- if (this._internalAbstractMeshDataInfo._material === value) {
467
- return;
468
- }
469
- // remove from material mesh map id needed
470
- if (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap) {
471
- this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = undefined;
472
- }
473
- this._internalAbstractMeshDataInfo._material = value;
474
- if (value && value.meshMap) {
475
- value.meshMap[this.uniqueId] = this;
476
- }
477
- if (this.onMaterialChangedObservable.hasObservers()) {
478
- this.onMaterialChangedObservable.notifyObservers(this);
479
- }
480
- if (!this.subMeshes) {
481
- return;
482
- }
483
- this.resetDrawCache(undefined, value == null);
484
- this._unBindEffect();
485
- }
486
- /**
487
- * Gets the material used to render the mesh in a specific render pass
488
- * @param renderPassId render pass id
489
- * @returns material used for the render pass. If no specific material is used for this render pass, undefined is returned (meaning mesh.material is used for this pass)
490
- */
491
- getMaterialForRenderPass(renderPassId) {
492
- return this._internalAbstractMeshDataInfo._materialForRenderPass?.[renderPassId];
493
- }
494
- /**
495
- * Sets the material to be used to render the mesh in a specific render pass
496
- * @param renderPassId render pass id
497
- * @param material material to use for this render pass. If undefined is passed, no specific material will be used for this render pass but the regular material will be used instead (mesh.material)
498
- */
499
- setMaterialForRenderPass(renderPassId, material) {
500
- this.resetDrawCache(renderPassId);
501
- if (!this._internalAbstractMeshDataInfo._materialForRenderPass) {
502
- this._internalAbstractMeshDataInfo._materialForRenderPass = [];
503
- }
504
- const currentMaterial = this._internalAbstractMeshDataInfo._materialForRenderPass[renderPassId];
505
- if (currentMaterial?.meshMap?.[this.uniqueId]) {
506
- currentMaterial.meshMap[this.uniqueId] = undefined;
507
- }
508
- this._internalAbstractMeshDataInfo._materialForRenderPass[renderPassId] = material;
509
- if (material && material.meshMap) {
510
- material.meshMap[this.uniqueId] = this;
511
- }
512
- }
513
- /**
514
- * Gets or sets a boolean indicating that this mesh can receive realtime shadows
515
- * @see https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows
516
- */
517
- get receiveShadows() {
518
- return this._internalAbstractMeshDataInfo._receiveShadows;
519
- }
520
- set receiveShadows(value) {
521
- if (this._internalAbstractMeshDataInfo._receiveShadows === value) {
522
- return;
523
- }
524
- this._internalAbstractMeshDataInfo._receiveShadows = value;
525
- this._markSubMeshesAsLightDirty();
526
- }
527
- /**
528
- * Gets or sets a boolean indicating that if should auto render shadows with lights
529
- */
530
- get doNotRenderShadows() {
531
- return this._internalAbstractMeshDataInfo._doNotRenderShadows;
532
- }
533
- set doNotRenderShadows(value) {
534
- if (this._internalAbstractMeshDataInfo._doNotRenderShadows === value) {
535
- return;
536
- }
537
- this._internalAbstractMeshDataInfo._doNotRenderShadows = value;
538
- }
539
- /**
540
- * Returns a boolean indicating whether the shadow maps for this mesh are isolated.
541
- * Isolated shadow maps can be useful for reducing light bleeding and improving shadow quality
542
- * by ensuring that each shadow map is rendered with its own set of objects, rather than sharing
543
- * a single shadow map with other lights.
544
- */
545
- get isolatedShadowMaps() {
546
- return this._internalAbstractMeshDataInfo._isolatedShadowMaps;
547
- }
548
- set isolatedShadowMaps(value) {
549
- if (this._internalAbstractMeshDataInfo._isolatedShadowMaps === value) {
550
- return;
551
- }
552
- this._internalAbstractMeshDataInfo._isolatedShadowMaps = value;
553
- }
554
- /**
555
- * Retrieves the sizes of the isolated shadow maps.
556
- */
557
- get isolatedShadowMapsSizes() {
558
- return this._internalAbstractMeshDataInfo._isolatedShadowMapsSizes;
559
- }
560
- set isolatedShadowMapsSizes(size) {
561
- if (this._internalAbstractMeshDataInfo._isolatedShadowMapsSizes === size) {
562
- return;
563
- }
564
- this._internalAbstractMeshDataInfo._isolatedShadowMapsSizes = size;
565
- }
566
- /**
567
- * Gets or sets a boolean indicating that this mesh needs to use vertex alpha data to render.
568
- * This property is misnamed and should be `useVertexAlpha`. Note that the mesh will be rendered
569
- * with alpha blending when this flag is set even if vertex alpha data is missing from the geometry.
570
- */
571
- get hasVertexAlpha() {
572
- return this._internalAbstractMeshDataInfo._hasVertexAlpha;
573
- }
574
- set hasVertexAlpha(value) {
575
- if (this._internalAbstractMeshDataInfo._hasVertexAlpha === value) {
576
- return;
577
- }
578
- this._internalAbstractMeshDataInfo._hasVertexAlpha = value;
579
- this._markSubMeshesAsAttributesDirty();
580
- this._markSubMeshesAsMiscDirty();
581
- }
582
- /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
583
- get useVertexColors() {
584
- return this._internalAbstractMeshDataInfo._useVertexColors;
585
- }
586
- set useVertexColors(value) {
587
- if (this._internalAbstractMeshDataInfo._useVertexColors === value) {
588
- return;
589
- }
590
- this._internalAbstractMeshDataInfo._useVertexColors = value;
591
- this._markSubMeshesAsAttributesDirty();
592
- }
593
- /**
594
- * Gets or sets a boolean indicating that bone animations must be computed by the GPU (true by default)
595
- */
596
- get computeBonesUsingShaders() {
597
- return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
598
- }
599
- set computeBonesUsingShaders(value) {
600
- if (this._internalAbstractMeshDataInfo._computeBonesUsingShaders === value) {
601
- return;
602
- }
603
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders = value;
604
- this._markSubMeshesAsAttributesDirty();
605
- }
606
- /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
607
- get numBoneInfluencers() {
608
- return this._internalAbstractMeshDataInfo._numBoneInfluencers;
609
- }
610
- set numBoneInfluencers(value) {
611
- if (this._internalAbstractMeshDataInfo._numBoneInfluencers === value) {
612
- return;
613
- }
614
- this._internalAbstractMeshDataInfo._numBoneInfluencers = value;
615
- this._markSubMeshesAsAttributesDirty();
616
- }
617
- /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
618
- get applyFog() {
619
- return this._internalAbstractMeshDataInfo._applyFog;
620
- }
621
- set applyFog(value) {
622
- if (this._internalAbstractMeshDataInfo._applyFog === value) {
623
- return;
624
- }
625
- this._internalAbstractMeshDataInfo._applyFog = value;
626
- this._markSubMeshesAsMiscDirty();
627
- }
628
- /** When enabled, decompose picking matrices for better precision with large values for mesh position and scling */
629
- get enableDistantPicking() {
630
- return this._internalAbstractMeshDataInfo._enableDistantPicking;
631
- }
632
- set enableDistantPicking(value) {
633
- this._internalAbstractMeshDataInfo._enableDistantPicking = value;
634
- }
635
- /**
636
- * Gets or sets the current layer mask (default is 0x0FFFFFFF)
637
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/layerMasksAndMultiCam
638
- */
639
- get layerMask() {
640
- return this._internalAbstractMeshDataInfo._layerMask;
641
- }
642
- set layerMask(value) {
643
- if (value === this._internalAbstractMeshDataInfo._layerMask) {
644
- return;
645
- }
646
- this._internalAbstractMeshDataInfo._layerMask = value;
647
- this._resyncLightSources();
648
- }
649
- /**
650
- * Gets or sets a collision mask used to mask collisions (default is -1).
651
- * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
652
- */
653
- get collisionMask() {
654
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask;
655
- }
656
- set collisionMask(mask) {
657
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = !isNaN(mask) ? mask : -1;
658
- }
659
- /**
660
- * Gets or sets a collision response flag (default is true).
661
- * when collisionResponse is false, events are still triggered but colliding entity has no response
662
- * This helps creating trigger volume when user wants collision feedback events but not position/velocity
663
- * to respond to the collision.
664
- */
665
- get collisionResponse() {
666
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse;
667
- }
668
- set collisionResponse(response) {
669
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = response;
670
- }
671
- /**
672
- * Gets or sets the current collision group mask (-1 by default).
673
- * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
674
- */
675
- get collisionGroup() {
676
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup;
677
- }
678
- set collisionGroup(mask) {
679
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = !isNaN(mask) ? mask : -1;
680
- }
681
- /**
682
- * Gets or sets current surrounding meshes (null by default).
683
- *
684
- * By default collision detection is tested against every mesh in the scene.
685
- * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
686
- * meshes will be tested for the collision.
687
- *
688
- * Note: if set to an empty array no collision will happen when this mesh is moved.
689
- */
690
- get surroundingMeshes() {
691
- return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes;
692
- }
693
- set surroundingMeshes(meshes) {
694
- this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = meshes;
695
- }
696
- /** Gets the list of lights affecting that mesh */
697
- get lightSources() {
698
- return this._lightSources;
699
- }
700
- /**
701
- * Gets or sets a skeleton to apply skinning transformations
702
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/bonesSkeletons
703
- */
704
- set skeleton(value) {
705
- const skeleton = this._internalAbstractMeshDataInfo._skeleton;
706
- if (skeleton) {
707
- skeleton.useCount--;
708
- }
709
- if (skeleton && skeleton.needInitialSkinMatrix) {
710
- skeleton._unregisterMeshWithPoseMatrix(this);
711
- }
712
- if (value && value.needInitialSkinMatrix) {
713
- value._registerMeshWithPoseMatrix(this);
714
- }
715
- if (value) {
716
- value.useCount++;
717
- }
718
- this._internalAbstractMeshDataInfo._skeleton = value;
719
- if (!this._internalAbstractMeshDataInfo._skeleton) {
720
- this._bonesTransformMatrices = null;
721
- }
722
- this._markSubMeshesAsAttributesDirty();
723
- }
724
- get skeleton() {
725
- return this._internalAbstractMeshDataInfo._skeleton;
726
- }
727
- // Constructor
728
- /**
729
- * Creates a new AbstractMesh
730
- * @param name defines the name of the mesh
731
- * @param scene defines the hosting scene
732
- */
733
- constructor(name, scene = null) {
734
- super(name, scene, false);
735
- // Internal data
736
- /** @internal */
737
- this._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo();
738
- /** @internal */
739
- this._waitingMaterialId = null;
740
- /** @internal */
741
- this._waitingMorphTargetManagerId = null;
742
- /** @internal */
743
- this._waitingSkeletonId = null;
744
- /** @internal */
745
- this._waitingSkeletonUniqueId = null;
746
- /**
747
- * The culling strategy to use to check whether the mesh must be rendered or not.
748
- * This value can be changed at any time and will be used on the next render mesh selection.
749
- * The possible values are :
750
- * - AbstractMesh.CULLINGSTRATEGY_STANDARD
751
- * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
752
- * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
753
- * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
754
- * Please read each static variable documentation to get details about the culling process.
755
- * */
756
- this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
757
- // Events
758
- /**
759
- * An event triggered when this mesh collides with another one
760
- */
761
- this.onCollideObservable = new Observable();
762
- /**
763
- * An event triggered when the collision's position changes
764
- */
765
- this.onCollisionPositionChangeObservable = new Observable();
766
- /**
767
- * An event triggered when material is changed
768
- */
769
- this.onMaterialChangedObservable = new Observable();
770
- // Properties
771
- /**
772
- * Gets or sets the orientation for POV movement & rotation
773
- */
774
- this.definedFacingForward = true;
775
- /** @internal */
776
- this._occlusionQuery = null;
777
- /** @internal */
778
- this._renderingGroup = null;
779
- /** Gets or sets the alpha index used to sort transparent meshes
780
- * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering#alpha-index
781
- */
782
- this.alphaIndex = Number.MAX_VALUE;
783
- /**
784
- * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions).
785
- * Default value is determined by {@link AbstractMesh.DefaultIsPickable} (true unless changed).
786
- */
787
- this.isPickable = AbstractMesh.DefaultIsPickable;
788
- /**
789
- * Gets or sets a boolean indicating if the mesh can be near picked (touched by the XR controller or hands). Default is false
790
- */
791
- this.isNearPickable = false;
792
- /**
793
- * Gets or sets a boolean indicating if the mesh can be grabbed. Default is false.
794
- * Setting this to true, while using the XR near interaction feature, will trigger a pointer event when the mesh is grabbed.
795
- * Grabbing means that the controller is using the squeeze or main trigger button to grab the mesh.
796
- * This is different from nearPickable which only triggers the event when the mesh is touched by the controller
797
- */
798
- this.isNearGrabbable = false;
799
- /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
800
- this.showSubMeshesBoundingBox = false;
801
- /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
802
- * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/lenseFlare
803
- */
804
- this.isBlocker = false;
805
- /**
806
- * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
807
- */
808
- this.enablePointerMoveEvents = false;
809
- /** Defines color to use when rendering outline */
810
- this.outlineColor = Color3.Red();
811
- /** Define width to use when rendering outline */
812
- this.outlineWidth = 0.02;
813
- /** Defines color to use when rendering overlay */
814
- this.overlayColor = Color3.Red();
815
- /** Defines alpha to use when rendering overlay */
816
- this.overlayAlpha = 0.5;
817
- /** Defines alpha to use when rendering internal overlay */
818
- this._internalOverlayAlpha = 0.5;
819
- /** Defines color to use when rendering internal overlay */
820
- this._internalOverlayColor = Color3.Red();
821
- /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
822
- this.useOctreeForRenderingSelection = true;
823
- /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
824
- this.useOctreeForPicking = true;
825
- /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
826
- this.useOctreeForCollisions = true;
827
- /**
828
- * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
829
- */
830
- this.alwaysSelectAsActiveMesh = false;
831
- /**
832
- * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
833
- */
834
- this.doNotSyncBoundingInfo = false;
835
- /**
836
- * Gets or sets the current action manager
837
- * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions
838
- */
839
- this.actionManager = null;
840
- /**
841
- * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
842
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
843
- */
844
- this.ellipsoid = new Vector3(0.5, 1, 0.5);
845
- /**
846
- * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
847
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
848
- */
849
- this.ellipsoidOffset = new Vector3(0, 0, 0);
850
- // Edges
851
- /**
852
- * Defines edge width used when edgesRenderer is enabled
853
- * @see https://www.babylonjs-playground.com/#10OJSG#13
854
- */
855
- this.edgesWidth = 1;
856
- /**
857
- * Defines edge color used when edgesRenderer is enabled
858
- * @see https://www.babylonjs-playground.com/#10OJSG#13
859
- */
860
- this.edgesColor = new Color4(1, 0, 0, 1);
861
- /** @internal */
862
- this._edgesRenderer = null;
863
- /** @internal */
864
- this._masterMesh = null;
865
- this._boundingInfo = null;
866
- this._boundingInfoIsDirty = true;
867
- /** @internal */
868
- this._renderId = 0;
869
- /** @internal */
870
- this._intersectionsInProgress = new Array();
871
- /** @internal */
872
- this._unIndexed = false;
873
- /** @internal */
874
- this._lightSources = new Array();
875
- // Loading properties
876
- /** @internal */
877
- this._waitingData = {
878
- lods: null,
879
- actions: null,
880
- freezeWorldMatrix: null,
881
- };
882
- /** @internal */
883
- this._bonesTransformMatrices = null;
884
- /** @internal */
885
- this._transformMatrixTexture = null;
886
- /**
887
- * An event triggered when the mesh is rebuilt.
888
- */
889
- this.onRebuildObservable = new Observable();
890
- this._onCollisionPositionChange = (collisionId, newPosition, collidedMesh = null) => {
891
- newPosition.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions);
892
- if (this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > AbstractEngine.CollisionsEpsilon) {
893
- this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions);
234
+ let AbstractMesh = (() => {
235
+ var _a;
236
+ let _classSuper = TransformNode;
237
+ let _staticExtraInitializers = [];
238
+ let _static__ApplySkeleton_decorators;
239
+ return _a = class AbstractMesh extends _classSuper {
240
+ /**
241
+ * No billboard
242
+ */
243
+ static get BILLBOARDMODE_NONE() {
244
+ return TransformNode.BILLBOARDMODE_NONE;
894
245
  }
895
- if (collidedMesh) {
896
- this.onCollideObservable.notifyObservers(collidedMesh);
246
+ /** Billboard on X axis */
247
+ static get BILLBOARDMODE_X() {
248
+ return TransformNode.BILLBOARDMODE_X;
897
249
  }
898
- this.onCollisionPositionChangeObservable.notifyObservers(this.position);
899
- };
900
- scene = this.getScene();
901
- this.layerMask = scene.defaultRenderableLayerMask;
902
- scene.addMesh(this);
903
- this._resyncLightSources();
904
- // Mesh Uniform Buffer.
905
- this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name, !this.getScene().getEngine().isWebGPU);
906
- this._buildUniformLayout();
907
- switch (scene.performancePriority) {
908
- case 2 /* ScenePerformancePriority.Aggressive */:
909
- this.doNotSyncBoundingInfo = true;
910
- // eslint-disable-next-line no-fallthrough
911
- case 1 /* ScenePerformancePriority.Intermediate */:
912
- this.alwaysSelectAsActiveMesh = true;
913
- this.isPickable = false;
914
- break;
915
- }
916
- }
917
- _buildUniformLayout() {
918
- this._uniformBuffer.addUniform("world", 16);
919
- this._uniformBuffer.addUniform("visibility", 1);
920
- this._uniformBuffer.create();
921
- }
922
- /**
923
- * Transfer the mesh values to its UBO.
924
- * @param world The world matrix associated with the mesh
925
- */
926
- transferToEffect(world) {
927
- const ubo = this._uniformBuffer;
928
- ubo.updateMatrix("world", world);
929
- ubo.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility);
930
- ubo.update();
931
- }
932
- /**
933
- * Gets the mesh uniform buffer.
934
- * @returns the uniform buffer of the mesh.
935
- */
936
- getMeshUniformBuffer() {
937
- return this._uniformBuffer;
938
- }
939
- /**
940
- * Returns the string "AbstractMesh"
941
- * @returns "AbstractMesh"
942
- */
943
- getClassName() {
944
- return "AbstractMesh";
945
- }
946
- /**
947
- * Gets a string representation of the current mesh
948
- * @param fullDetails defines a boolean indicating if full details must be included
949
- * @returns a string representation of the current mesh
950
- */
951
- toString(fullDetails) {
952
- let ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() === "InstancedMesh" ? "YES" : "NO");
953
- ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
954
- const skeleton = this._internalAbstractMeshDataInfo._skeleton;
955
- if (skeleton) {
956
- ret += ", skeleton: " + skeleton.name;
957
- }
958
- if (fullDetails) {
959
- ret += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode];
960
- ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO");
961
- }
962
- return ret;
963
- }
964
- /**
965
- * @internal
966
- */
967
- _getEffectiveParent() {
968
- if (this._masterMesh && this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
969
- return this._masterMesh;
970
- }
971
- return super._getEffectiveParent();
972
- }
973
- /**
974
- * @internal
975
- */
976
- _getActionManagerForTrigger(trigger, initialCall = true) {
977
- if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
978
- if (trigger) {
979
- if (this.actionManager.hasSpecificTrigger(trigger)) {
980
- return this.actionManager;
250
+ /** Billboard on Y axis */
251
+ static get BILLBOARDMODE_Y() {
252
+ return TransformNode.BILLBOARDMODE_Y;
253
+ }
254
+ /** Billboard on Z axis */
255
+ static get BILLBOARDMODE_Z() {
256
+ return TransformNode.BILLBOARDMODE_Z;
257
+ }
258
+ /** Billboard on all axes */
259
+ static get BILLBOARDMODE_ALL() {
260
+ return TransformNode.BILLBOARDMODE_ALL;
261
+ }
262
+ /** Billboard on using position instead of orientation */
263
+ static get BILLBOARDMODE_USE_POSITION() {
264
+ return TransformNode.BILLBOARDMODE_USE_POSITION;
265
+ }
266
+ /**
267
+ * Gets the number of facets in the mesh
268
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#what-is-a-mesh-facet
269
+ */
270
+ get facetNb() {
271
+ return this._internalAbstractMeshDataInfo._facetData.facetNb;
272
+ }
273
+ /**
274
+ * Gets or set the number (integer) of subdivisions per axis in the partitioning space
275
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#tweaking-the-partitioning
276
+ */
277
+ get partitioningSubdivisions() {
278
+ return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions;
279
+ }
280
+ set partitioningSubdivisions(nb) {
281
+ this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = nb;
282
+ }
283
+ /**
284
+ * The ratio (float) to apply to the bounding box size to set to the partitioning space.
285
+ * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
286
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#tweaking-the-partitioning
287
+ */
288
+ // eslint-disable-next-line @typescript-eslint/naming-convention
289
+ get partitioningBBoxRatio() {
290
+ return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio;
291
+ }
292
+ // eslint-disable-next-line @typescript-eslint/naming-convention
293
+ set partitioningBBoxRatio(ratio) {
294
+ this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = ratio;
295
+ }
296
+ /**
297
+ * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
298
+ * Works only for updatable meshes.
299
+ * Doesn't work with multi-materials
300
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#facet-depth-sort
301
+ */
302
+ get mustDepthSortFacets() {
303
+ return this._internalAbstractMeshDataInfo._facetData.facetDepthSort;
304
+ }
305
+ set mustDepthSortFacets(sort) {
306
+ this._internalAbstractMeshDataInfo._facetData.facetDepthSort = sort;
307
+ }
308
+ /**
309
+ * The location (Vector3) where the facet depth sort must be computed from.
310
+ * By default, the active camera position.
311
+ * Used only when facet depth sort is enabled
312
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#facet-depth-sort
313
+ */
314
+ get facetDepthSortFrom() {
315
+ return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom;
316
+ }
317
+ set facetDepthSortFrom(location) {
318
+ this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = location;
319
+ }
320
+ /** number of collision detection tries. Change this value if not all collisions are detected and handled properly */
321
+ get collisionRetryCount() {
322
+ return this._internalAbstractMeshDataInfo._collisionRetryCount;
323
+ }
324
+ set collisionRetryCount(retryCount) {
325
+ this._internalAbstractMeshDataInfo._collisionRetryCount = retryCount;
326
+ }
327
+ /**
328
+ * gets a boolean indicating if facetData is enabled
329
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData#what-is-a-mesh-facet
330
+ */
331
+ get isFacetDataEnabled() {
332
+ return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled;
333
+ }
334
+ /**
335
+ * Gets or sets the morph target manager
336
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets
337
+ */
338
+ get morphTargetManager() {
339
+ return this._internalAbstractMeshDataInfo._morphTargetManager;
340
+ }
341
+ set morphTargetManager(value) {
342
+ if (this._internalAbstractMeshDataInfo._morphTargetManager === value) {
343
+ return;
981
344
  }
345
+ this._internalAbstractMeshDataInfo._morphTargetManager = value;
346
+ this._syncGeometryWithMorphTargetManager();
982
347
  }
983
- else {
984
- return this.actionManager;
348
+ /**
349
+ * Gets or sets the baked vertex animation manager
350
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/baked_texture_animations
351
+ */
352
+ get bakedVertexAnimationManager() {
353
+ return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager;
985
354
  }
986
- }
987
- if (!this.parent) {
988
- return null;
989
- }
990
- return this.parent._getActionManagerForTrigger(trigger, false);
991
- }
992
- /**
993
- * @internal
994
- */
995
- _releaseRenderPassId(_id) { }
996
- /**
997
- * @internal
998
- */
999
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1000
- _rebuild(dispose = false) {
1001
- this.onRebuildObservable.notifyObservers(this);
1002
- if (this._occlusionQuery !== null) {
1003
- this._occlusionQuery = null;
1004
- }
1005
- if (!this.subMeshes) {
1006
- return;
1007
- }
1008
- for (const subMesh of this.subMeshes) {
1009
- subMesh._rebuild();
1010
- }
1011
- this.resetDrawCache();
1012
- }
1013
- /** @internal */
1014
- _resyncLightSources() {
1015
- this._lightSources.length = 0;
1016
- for (const light of this.getScene().lights) {
1017
- if (!light.isEnabled()) {
1018
- continue;
355
+ set bakedVertexAnimationManager(value) {
356
+ if (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager === value) {
357
+ return;
358
+ }
359
+ this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = value;
360
+ this._markSubMeshesAsAttributesDirty();
1019
361
  }
1020
- if (light.canAffectMesh(this)) {
1021
- this._lightSources.push(light);
362
+ /** @internal */
363
+ _syncGeometryWithMorphTargetManager() { }
364
+ /**
365
+ * @internal
366
+ */
367
+ _updateNonUniformScalingState(value) {
368
+ if (!super._updateNonUniformScalingState(value)) {
369
+ return false;
370
+ }
371
+ this._markSubMeshesAsMiscDirty();
372
+ return true;
1022
373
  }
1023
- }
1024
- this._markSubMeshesAsLightDirty();
1025
- }
1026
- /**
1027
- * @internal
1028
- */
1029
- _resyncLightSource(light) {
1030
- const isIn = light.isEnabled() && light.canAffectMesh(this) && light.internalEnabled;
1031
- const index = this._lightSources.indexOf(light);
1032
- let removed = false;
1033
- if (index === -1) {
1034
- if (!isIn) {
1035
- return;
1036
- }
1037
- this._lightSources.push(light);
1038
- }
1039
- else {
1040
- if (isIn) {
1041
- return;
374
+ /** @internal */
375
+ get rawBoundingInfo() {
376
+ return this._internalAbstractMeshDataInfo._rawBoundingInfo;
1042
377
  }
1043
- removed = true;
1044
- this._lightSources.splice(index, 1);
1045
- }
1046
- this._markSubMeshesAsLightDirty(removed);
1047
- }
1048
- /** @internal */
1049
- _unBindEffect() {
1050
- for (const subMesh of this.subMeshes) {
1051
- subMesh.setEffect(null);
1052
- }
1053
- }
1054
- /**
1055
- * @internal
1056
- */
1057
- _removeLightSource(light, dispose) {
1058
- const index = this._lightSources.indexOf(light);
1059
- if (index === -1) {
1060
- return;
1061
- }
1062
- this._lightSources.splice(index, 1);
1063
- this._markSubMeshesAsLightDirty(dispose);
1064
- }
1065
- _markSubMeshesAsDirty(func) {
1066
- if (!this.subMeshes) {
1067
- return;
1068
- }
1069
- for (const subMesh of this.subMeshes) {
1070
- for (let i = 0; i < subMesh._drawWrappers.length; ++i) {
1071
- const drawWrapper = subMesh._drawWrappers[i];
1072
- if (!drawWrapper || !drawWrapper.defines || !drawWrapper.defines.markAllAsDirty) {
1073
- continue;
378
+ set rawBoundingInfo(boundingInfo) {
379
+ this._internalAbstractMeshDataInfo._rawBoundingInfo = boundingInfo;
380
+ }
381
+ /** Set a function to call when this mesh collides with another one */
382
+ set onCollide(callback) {
383
+ if (this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver) {
384
+ this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver);
1074
385
  }
1075
- func(drawWrapper.defines);
386
+ this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(callback);
1076
387
  }
1077
- }
1078
- }
1079
- /**
1080
- * @internal
1081
- */
1082
- _markSubMeshesAsLightDirty(dispose = false) {
1083
- this._markSubMeshesAsDirty((defines) => defines.markAsLightDirty(dispose));
1084
- }
1085
- /** @internal */
1086
- _markSubMeshesAsAttributesDirty() {
1087
- this._markSubMeshesAsDirty((defines) => defines.markAsAttributesDirty());
1088
- }
1089
- /** @internal */
1090
- _markSubMeshesAsMiscDirty() {
1091
- this._markSubMeshesAsDirty((defines) => defines.markAsMiscDirty());
1092
- }
1093
- /**
1094
- * Flag the AbstractMesh as dirty (Forcing it to update everything)
1095
- * @param property if set to "rotation" the objects rotationQuaternion will be set to null
1096
- * @returns this AbstractMesh
1097
- */
1098
- markAsDirty(property) {
1099
- this._currentRenderId = Number.MAX_VALUE;
1100
- super.markAsDirty(property);
1101
- this._isDirty = true;
1102
- return this;
1103
- }
1104
- /**
1105
- * Resets the draw wrappers cache for all submeshes of this abstract mesh
1106
- * @param passId If provided, releases only the draw wrapper corresponding to this render pass id
1107
- * @param immediate If true, the effect will be released immediately, otherwise it will be released at the next frame
1108
- */
1109
- resetDrawCache(passId, immediate = false) {
1110
- if (!this.subMeshes) {
1111
- return;
1112
- }
1113
- for (const subMesh of this.subMeshes) {
1114
- subMesh.resetDrawCache(passId, immediate);
1115
- }
1116
- }
1117
- // Methods
1118
- /**
1119
- * Returns true if the mesh is blocked. Implemented by child classes
1120
- */
1121
- get isBlocked() {
1122
- return false;
1123
- }
1124
- /**
1125
- * Returns the mesh itself by default. Implemented by child classes
1126
- * @param camera defines the camera to use to pick the right LOD level
1127
- * @returns the currentAbstractMesh
1128
- */
1129
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1130
- getLOD(camera) {
1131
- return this;
1132
- }
1133
- /**
1134
- * Returns 0 by default. Implemented by child classes
1135
- * @returns an integer
1136
- */
1137
- getTotalVertices() {
1138
- return 0;
1139
- }
1140
- /**
1141
- * Returns a positive integer : the total number of indices in this mesh geometry.
1142
- * @returns the number of indices or zero if the mesh has no geometry.
1143
- */
1144
- getTotalIndices() {
1145
- return 0;
1146
- }
1147
- /**
1148
- * Returns null by default. Implemented by child classes
1149
- * @returns null
1150
- */
1151
- getIndices() {
1152
- return null;
1153
- }
1154
- /**
1155
- * Returns the array of the requested vertex data kind. Implemented by child classes
1156
- * @param kind defines the vertex data kind to use
1157
- * @returns null
1158
- */
1159
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1160
- getVerticesData(kind) {
1161
- return null;
1162
- }
1163
- /**
1164
- * Sets the vertex data of the mesh geometry for the requested `kind`.
1165
- * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
1166
- * Note that a new underlying VertexBuffer object is created each call.
1167
- * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
1168
- * @param kind defines vertex data kind:
1169
- * * VertexBuffer.PositionKind
1170
- * * VertexBuffer.UVKind
1171
- * * VertexBuffer.UV2Kind
1172
- * * VertexBuffer.UV3Kind
1173
- * * VertexBuffer.UV4Kind
1174
- * * VertexBuffer.UV5Kind
1175
- * * VertexBuffer.UV6Kind
1176
- * * VertexBuffer.ColorKind
1177
- * * VertexBuffer.MatricesIndicesKind
1178
- * * VertexBuffer.MatricesIndicesExtraKind
1179
- * * VertexBuffer.MatricesWeightsKind
1180
- * * VertexBuffer.MatricesWeightsExtraKind
1181
- * @param data defines the data source
1182
- * @param updatable defines if the data must be flagged as updatable (or static)
1183
- * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
1184
- * @returns the current mesh
1185
- */
1186
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1187
- setVerticesData(kind, data, updatable, stride) {
1188
- return this;
1189
- }
1190
- /**
1191
- * Updates the existing vertex data of the mesh geometry for the requested `kind`.
1192
- * If the mesh has no geometry, it is simply returned as it is.
1193
- * @param kind defines vertex data kind:
1194
- * * VertexBuffer.PositionKind
1195
- * * VertexBuffer.UVKind
1196
- * * VertexBuffer.UV2Kind
1197
- * * VertexBuffer.UV3Kind
1198
- * * VertexBuffer.UV4Kind
1199
- * * VertexBuffer.UV5Kind
1200
- * * VertexBuffer.UV6Kind
1201
- * * VertexBuffer.ColorKind
1202
- * * VertexBuffer.MatricesIndicesKind
1203
- * * VertexBuffer.MatricesIndicesExtraKind
1204
- * * VertexBuffer.MatricesWeightsKind
1205
- * * VertexBuffer.MatricesWeightsExtraKind
1206
- * @param data defines the data source
1207
- * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
1208
- * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
1209
- * @returns the current mesh
1210
- */
1211
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1212
- updateVerticesData(kind, data, updateExtends, makeItUnique) {
1213
- return this;
1214
- }
1215
- /**
1216
- * Sets the mesh indices,
1217
- * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
1218
- * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
1219
- * @param totalVertices Defines the total number of vertices
1220
- * @returns the current mesh
1221
- */
1222
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1223
- setIndices(indices, totalVertices) {
1224
- return this;
1225
- }
1226
- /**
1227
- * Gets a boolean indicating if specific vertex data is present
1228
- * @param kind defines the vertex data kind to use
1229
- * @returns true is data kind is present
1230
- */
1231
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1232
- isVerticesDataPresent(kind) {
1233
- return false;
1234
- }
1235
- /**
1236
- * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
1237
- * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
1238
- * However, if the mesh contains thin instances, it will be expanded to include them. If you want the "raw" bounding data instead, then use `getRawBoundingInfo()`.
1239
- * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
1240
- * @returns a BoundingInfo
1241
- */
1242
- getBoundingInfo() {
1243
- if (this._masterMesh) {
1244
- return this._masterMesh.getBoundingInfo();
1245
- }
1246
- if (this._boundingInfoIsDirty) {
1247
- this._boundingInfoIsDirty = false;
1248
- // this._boundingInfo is being created if undefined
1249
- this._updateBoundingInfo();
1250
- }
1251
- // cannot be null.
1252
- return this._boundingInfo;
1253
- }
1254
- /**
1255
- * Returns the bounding info unnafected by instance data.
1256
- * @returns the bounding info of the mesh unaffected by instance data.
1257
- */
1258
- getRawBoundingInfo() {
1259
- return this.rawBoundingInfo ?? this.getBoundingInfo();
1260
- }
1261
- /**
1262
- * Overwrite the current bounding info
1263
- * @param boundingInfo defines the new bounding info
1264
- * @returns the current mesh
1265
- */
1266
- setBoundingInfo(boundingInfo) {
1267
- this._boundingInfo = boundingInfo;
1268
- return this;
1269
- }
1270
- /**
1271
- * Returns true if there is already a bounding info
1272
- */
1273
- get hasBoundingInfo() {
1274
- return this._boundingInfo !== null;
1275
- }
1276
- /**
1277
- * Creates a new bounding info for the mesh
1278
- * @param minimum min vector of the bounding box/sphere
1279
- * @param maximum max vector of the bounding box/sphere
1280
- * @param worldMatrix defines the new world matrix
1281
- * @returns the new bounding info
1282
- */
1283
- buildBoundingInfo(minimum, maximum, worldMatrix) {
1284
- this._boundingInfo = new BoundingInfo(minimum, maximum, worldMatrix);
1285
- return this._boundingInfo;
1286
- }
1287
- /**
1288
- * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
1289
- * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
1290
- * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
1291
- * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
1292
- * @returns the current mesh
1293
- */
1294
- normalizeToUnitCube(includeDescendants = true, ignoreRotation = false, predicate) {
1295
- return super.normalizeToUnitCube(includeDescendants, ignoreRotation, predicate);
1296
- }
1297
- /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
1298
- get useBones() {
1299
- return ((this.skeleton &&
1300
- this.getScene().skeletonsEnabled &&
1301
- this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) &&
1302
- this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)));
1303
- }
1304
- /** @internal */
1305
- _preActivate() { }
1306
- /**
1307
- * @internal
1308
- */
1309
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1310
- _preActivateForIntermediateRendering(renderId) { }
1311
- /**
1312
- * @internal
1313
- */
1314
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1315
- _activate(renderId, intermediateRendering) {
1316
- this._renderId = renderId;
1317
- return true;
1318
- }
1319
- /** @internal */
1320
- _postActivate() {
1321
- // Do nothing
1322
- }
1323
- /** @internal */
1324
- _freeze() {
1325
- // Do nothing
1326
- }
1327
- /** @internal */
1328
- _unFreeze() {
1329
- // Do nothing
1330
- }
1331
- /**
1332
- * Gets the current world matrix
1333
- * @returns a Matrix
1334
- */
1335
- getWorldMatrix() {
1336
- if (this._masterMesh && this.billboardMode === TransformNode.BILLBOARDMODE_NONE) {
1337
- return this._masterMesh.getWorldMatrix();
1338
- }
1339
- return super.getWorldMatrix();
1340
- }
1341
- /** @internal */
1342
- _getWorldMatrixDeterminant() {
1343
- if (this._masterMesh) {
1344
- return this._masterMesh._getWorldMatrixDeterminant();
1345
- }
1346
- return super._getWorldMatrixDeterminant();
1347
- }
1348
- /**
1349
- * Gets a boolean indicating if this mesh is an instance or a regular mesh
1350
- */
1351
- get isAnInstance() {
1352
- return false;
1353
- }
1354
- /**
1355
- * Gets a boolean indicating if this mesh has instances
1356
- */
1357
- get hasInstances() {
1358
- return false;
1359
- }
1360
- /**
1361
- * Gets a boolean indicating if this mesh has thin instances
1362
- */
1363
- get hasThinInstances() {
1364
- return false;
1365
- }
1366
- // ================================== Point of View Movement =================================
1367
- /**
1368
- * Perform relative position change from the point of view of behind the front of the mesh.
1369
- * This is performed taking into account the meshes current rotation, so you do not have to care.
1370
- * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1371
- * @param amountRight defines the distance on the right axis
1372
- * @param amountUp defines the distance on the up axis
1373
- * @param amountForward defines the distance on the forward axis
1374
- * @returns the current mesh
1375
- */
1376
- movePOV(amountRight, amountUp, amountForward) {
1377
- this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
1378
- return this;
1379
- }
1380
- /**
1381
- * Calculate relative position change from the point of view of behind the front of the mesh.
1382
- * This is performed taking into account the meshes current rotation, so you do not have to care.
1383
- * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1384
- * @param amountRight defines the distance on the right axis
1385
- * @param amountUp defines the distance on the up axis
1386
- * @param amountForward defines the distance on the forward axis
1387
- * @returns the new displacement vector
1388
- */
1389
- calcMovePOV(amountRight, amountUp, amountForward) {
1390
- const rotMatrix = new Matrix();
1391
- const rotQuaternion = this.rotationQuaternion ? this.rotationQuaternion : Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
1392
- rotQuaternion.toRotationMatrix(rotMatrix);
1393
- const translationDelta = Vector3.Zero();
1394
- const defForwardMult = this.definedFacingForward ? -1 : 1;
1395
- Vector3.TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
1396
- return translationDelta;
1397
- }
1398
- // ================================== Point of View Rotation =================================
1399
- /**
1400
- * Perform relative rotation change from the point of view of behind the front of the mesh.
1401
- * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1402
- * @param flipBack defines the flip
1403
- * @param twirlClockwise defines the twirl
1404
- * @param tiltRight defines the tilt
1405
- * @returns the current mesh
1406
- */
1407
- rotatePOV(flipBack, twirlClockwise, tiltRight) {
1408
- this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
1409
- return this;
1410
- }
1411
- /**
1412
- * Calculate relative rotation change from the point of view of behind the front of the mesh.
1413
- * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1414
- * @param flipBack defines the flip
1415
- * @param twirlClockwise defines the twirl
1416
- * @param tiltRight defines the tilt
1417
- * @returns the new rotation vector
1418
- */
1419
- calcRotatePOV(flipBack, twirlClockwise, tiltRight) {
1420
- const defForwardMult = this.definedFacingForward ? 1 : -1;
1421
- return new Vector3(flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
1422
- }
1423
- /**
1424
- * @internal
1425
- */
1426
- _refreshBoundingInfo(data, bias) {
1427
- if (data) {
1428
- const extend = extractMinAndMax(data, 0, this.getTotalVertices(), bias);
1429
- if (this._boundingInfo) {
1430
- this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
1431
- }
1432
- else {
1433
- this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);
388
+ /** Set a function to call when the collision's position changes */
389
+ set onCollisionPositionChange(callback) {
390
+ if (this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver) {
391
+ this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver);
392
+ }
393
+ this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
1434
394
  }
1435
- }
1436
- if (this.subMeshes) {
1437
- for (let index = 0; index < this.subMeshes.length; index++) {
1438
- this.subMeshes[index].refreshBoundingInfo(data);
395
+ /**
396
+ * Gets or sets mesh visibility between 0 and 1 (default is 1)
397
+ */
398
+ get visibility() {
399
+ return this._internalAbstractMeshDataInfo._visibility;
1439
400
  }
1440
- }
1441
- this._updateBoundingInfo();
1442
- }
1443
- /**
1444
- * @internal
1445
- */
1446
- _refreshBoundingInfoDirect(extend) {
1447
- if (this._boundingInfo) {
1448
- this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
1449
- }
1450
- else {
1451
- this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);
1452
- }
1453
- if (this.subMeshes) {
1454
- for (let index = 0; index < this.subMeshes.length; index++) {
1455
- this.subMeshes[index].refreshBoundingInfo(null);
401
+ /**
402
+ * Gets or sets mesh visibility between 0 and 1 (default is 1)
403
+ */
404
+ set visibility(value) {
405
+ if (this._internalAbstractMeshDataInfo._visibility === value) {
406
+ return;
407
+ }
408
+ const oldValue = this._internalAbstractMeshDataInfo._visibility;
409
+ this._internalAbstractMeshDataInfo._visibility = value;
410
+ if ((oldValue === 1 && value !== 1) || (oldValue !== 1 && value === 1)) {
411
+ this._markSubMeshesAsDirty((defines) => {
412
+ defines.markAsMiscDirty();
413
+ defines.markAsPrePassDirty();
414
+ });
415
+ }
416
+ }
417
+ /**
418
+ * Gets or sets the property which disables the test that is checking that the mesh under the pointer is the same than the previous time we tested for it (default: false).
419
+ * Set this property to true if you want thin instances picking to be reported accurately when moving over the mesh.
420
+ * Note that setting this property to true will incur some performance penalties when dealing with pointer events for this mesh so use it sparingly.
421
+ */
422
+ get pointerOverDisableMeshTesting() {
423
+ return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting;
424
+ }
425
+ set pointerOverDisableMeshTesting(disable) {
426
+ this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting = disable;
427
+ }
428
+ /**
429
+ * Specifies the rendering group id for this mesh (0 by default)
430
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering#rendering-groups
431
+ */
432
+ get renderingGroupId() {
433
+ return this._internalAbstractMeshDataInfo._renderingGroupId;
434
+ }
435
+ set renderingGroupId(value) {
436
+ this._internalAbstractMeshDataInfo._renderingGroupId = value;
437
+ }
438
+ /**
439
+ * Control if the material should be rendered
440
+ */
441
+ get materialEnabled() {
442
+ return this._internalAbstractMeshDataInfo._materialEnabled;
443
+ }
444
+ set materialEnabled(enabled) {
445
+ if (this._internalAbstractMeshDataInfo._materialEnabled === enabled) {
446
+ return;
447
+ }
448
+ this._internalAbstractMeshDataInfo._materialEnabled = enabled;
449
+ }
450
+ /**
451
+ * Control if the camera should render material
452
+ */
453
+ get doNotRenderMaterialCameraUniqueIds() {
454
+ return this._internalAbstractMeshDataInfo._doNotRenderMaterialCameraUniqueIds;
455
+ }
456
+ set doNotRenderMaterialCameraUniqueIds(ids) {
457
+ if (this._internalAbstractMeshDataInfo._doNotRenderMaterialCameraUniqueIds === ids) {
458
+ return;
459
+ }
460
+ this._internalAbstractMeshDataInfo._doNotRenderMaterialCameraUniqueIds = ids;
461
+ }
462
+ /** Gets or sets current material */
463
+ get material() {
464
+ return this._internalAbstractMeshDataInfo._material;
465
+ }
466
+ set material(value) {
467
+ this._setMaterial(value);
468
+ }
469
+ /** @internal */
470
+ _setMaterial(value) {
471
+ if (this._internalAbstractMeshDataInfo._material === value) {
472
+ return;
473
+ }
474
+ // remove from material mesh map id needed
475
+ if (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap) {
476
+ this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = undefined;
477
+ }
478
+ this._internalAbstractMeshDataInfo._material = value;
479
+ if (value && value.meshMap) {
480
+ value.meshMap[this.uniqueId] = this;
481
+ }
482
+ if (this.onMaterialChangedObservable.hasObservers()) {
483
+ this.onMaterialChangedObservable.notifyObservers(this);
484
+ }
485
+ if (!this.subMeshes) {
486
+ return;
487
+ }
488
+ this.resetDrawCache(undefined, value == null);
489
+ this._unBindEffect();
490
+ }
491
+ /**
492
+ * Gets the material used to render the mesh in a specific render pass
493
+ * @param renderPassId render pass id
494
+ * @returns material used for the render pass. If no specific material is used for this render pass, undefined is returned (meaning mesh.material is used for this pass)
495
+ */
496
+ getMaterialForRenderPass(renderPassId) {
497
+ return this._internalAbstractMeshDataInfo._materialForRenderPass?.[renderPassId];
498
+ }
499
+ /**
500
+ * Sets the material to be used to render the mesh in a specific render pass
501
+ * @param renderPassId render pass id
502
+ * @param material material to use for this render pass. If undefined is passed, no specific material will be used for this render pass but the regular material will be used instead (mesh.material)
503
+ */
504
+ setMaterialForRenderPass(renderPassId, material) {
505
+ this.resetDrawCache(renderPassId);
506
+ if (!this._internalAbstractMeshDataInfo._materialForRenderPass) {
507
+ this._internalAbstractMeshDataInfo._materialForRenderPass = [];
508
+ }
509
+ const currentMaterial = this._internalAbstractMeshDataInfo._materialForRenderPass[renderPassId];
510
+ if (currentMaterial?.meshMap?.[this.uniqueId]) {
511
+ currentMaterial.meshMap[this.uniqueId] = undefined;
512
+ }
513
+ this._internalAbstractMeshDataInfo._materialForRenderPass[renderPassId] = material;
514
+ if (material && material.meshMap) {
515
+ material.meshMap[this.uniqueId] = this;
516
+ }
517
+ }
518
+ /**
519
+ * Gets or sets a boolean indicating that this mesh can receive realtime shadows
520
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows
521
+ */
522
+ get receiveShadows() {
523
+ return this._internalAbstractMeshDataInfo._receiveShadows;
524
+ }
525
+ set receiveShadows(value) {
526
+ if (this._internalAbstractMeshDataInfo._receiveShadows === value) {
527
+ return;
528
+ }
529
+ this._internalAbstractMeshDataInfo._receiveShadows = value;
530
+ this._markSubMeshesAsLightDirty();
531
+ }
532
+ /**
533
+ * Gets or sets a boolean indicating that if should auto render shadows with lights
534
+ */
535
+ get doNotRenderShadows() {
536
+ return this._internalAbstractMeshDataInfo._doNotRenderShadows;
537
+ }
538
+ set doNotRenderShadows(value) {
539
+ if (this._internalAbstractMeshDataInfo._doNotRenderShadows === value) {
540
+ return;
541
+ }
542
+ this._internalAbstractMeshDataInfo._doNotRenderShadows = value;
543
+ }
544
+ /**
545
+ * Returns a boolean indicating whether the shadow maps for this mesh are isolated.
546
+ * Isolated shadow maps can be useful for reducing light bleeding and improving shadow quality
547
+ * by ensuring that each shadow map is rendered with its own set of objects, rather than sharing
548
+ * a single shadow map with other lights.
549
+ */
550
+ get isolatedShadowMaps() {
551
+ return this._internalAbstractMeshDataInfo._isolatedShadowMaps;
552
+ }
553
+ set isolatedShadowMaps(value) {
554
+ if (this._internalAbstractMeshDataInfo._isolatedShadowMaps === value) {
555
+ return;
556
+ }
557
+ this._internalAbstractMeshDataInfo._isolatedShadowMaps = value;
558
+ }
559
+ /**
560
+ * Retrieves the sizes of the isolated shadow maps.
561
+ */
562
+ get isolatedShadowMapsSizes() {
563
+ return this._internalAbstractMeshDataInfo._isolatedShadowMapsSizes;
564
+ }
565
+ set isolatedShadowMapsSizes(size) {
566
+ if (this._internalAbstractMeshDataInfo._isolatedShadowMapsSizes === size) {
567
+ return;
568
+ }
569
+ this._internalAbstractMeshDataInfo._isolatedShadowMapsSizes = size;
570
+ }
571
+ /**
572
+ * Gets or sets a boolean indicating that this mesh needs to use vertex alpha data to render.
573
+ * This property is misnamed and should be `useVertexAlpha`. Note that the mesh will be rendered
574
+ * with alpha blending when this flag is set even if vertex alpha data is missing from the geometry.
575
+ */
576
+ get hasVertexAlpha() {
577
+ return this._internalAbstractMeshDataInfo._hasVertexAlpha;
578
+ }
579
+ set hasVertexAlpha(value) {
580
+ if (this._internalAbstractMeshDataInfo._hasVertexAlpha === value) {
581
+ return;
582
+ }
583
+ this._internalAbstractMeshDataInfo._hasVertexAlpha = value;
584
+ this._markSubMeshesAsAttributesDirty();
585
+ this._markSubMeshesAsMiscDirty();
586
+ }
587
+ /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
588
+ get useVertexColors() {
589
+ return this._internalAbstractMeshDataInfo._useVertexColors;
590
+ }
591
+ set useVertexColors(value) {
592
+ if (this._internalAbstractMeshDataInfo._useVertexColors === value) {
593
+ return;
594
+ }
595
+ this._internalAbstractMeshDataInfo._useVertexColors = value;
596
+ this._markSubMeshesAsAttributesDirty();
597
+ }
598
+ /**
599
+ * Gets or sets a boolean indicating that bone animations must be computed by the GPU (true by default)
600
+ */
601
+ get computeBonesUsingShaders() {
602
+ return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
603
+ }
604
+ set computeBonesUsingShaders(value) {
605
+ if (this._internalAbstractMeshDataInfo._computeBonesUsingShaders === value) {
606
+ return;
607
+ }
608
+ this._internalAbstractMeshDataInfo._computeBonesUsingShaders = value;
609
+ this._markSubMeshesAsAttributesDirty();
610
+ }
611
+ /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
612
+ get numBoneInfluencers() {
613
+ return this._internalAbstractMeshDataInfo._numBoneInfluencers;
614
+ }
615
+ set numBoneInfluencers(value) {
616
+ if (this._internalAbstractMeshDataInfo._numBoneInfluencers === value) {
617
+ return;
618
+ }
619
+ this._internalAbstractMeshDataInfo._numBoneInfluencers = value;
620
+ this._markSubMeshesAsAttributesDirty();
621
+ }
622
+ /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
623
+ get applyFog() {
624
+ return this._internalAbstractMeshDataInfo._applyFog;
625
+ }
626
+ set applyFog(value) {
627
+ if (this._internalAbstractMeshDataInfo._applyFog === value) {
628
+ return;
629
+ }
630
+ this._internalAbstractMeshDataInfo._applyFog = value;
631
+ this._markSubMeshesAsMiscDirty();
632
+ }
633
+ /** When enabled, decompose picking matrices for better precision with large values for mesh position and scling */
634
+ get enableDistantPicking() {
635
+ return this._internalAbstractMeshDataInfo._enableDistantPicking;
636
+ }
637
+ set enableDistantPicking(value) {
638
+ this._internalAbstractMeshDataInfo._enableDistantPicking = value;
639
+ }
640
+ /**
641
+ * Gets or sets the current layer mask (default is 0x0FFFFFFF)
642
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/layerMasksAndMultiCam
643
+ */
644
+ get layerMask() {
645
+ return this._internalAbstractMeshDataInfo._layerMask;
646
+ }
647
+ set layerMask(value) {
648
+ if (value === this._internalAbstractMeshDataInfo._layerMask) {
649
+ return;
650
+ }
651
+ this._internalAbstractMeshDataInfo._layerMask = value;
652
+ this._resyncLightSources();
653
+ }
654
+ /**
655
+ * Gets or sets a collision mask used to mask collisions (default is -1).
656
+ * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
657
+ */
658
+ get collisionMask() {
659
+ return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask;
660
+ }
661
+ set collisionMask(mask) {
662
+ this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = !isNaN(mask) ? mask : -1;
663
+ }
664
+ /**
665
+ * Gets or sets a collision response flag (default is true).
666
+ * when collisionResponse is false, events are still triggered but colliding entity has no response
667
+ * This helps creating trigger volume when user wants collision feedback events but not position/velocity
668
+ * to respond to the collision.
669
+ */
670
+ get collisionResponse() {
671
+ return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse;
672
+ }
673
+ set collisionResponse(response) {
674
+ this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = response;
675
+ }
676
+ /**
677
+ * Gets or sets the current collision group mask (-1 by default).
678
+ * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
679
+ */
680
+ get collisionGroup() {
681
+ return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup;
682
+ }
683
+ set collisionGroup(mask) {
684
+ this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = !isNaN(mask) ? mask : -1;
685
+ }
686
+ /**
687
+ * Gets or sets current surrounding meshes (null by default).
688
+ *
689
+ * By default collision detection is tested against every mesh in the scene.
690
+ * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
691
+ * meshes will be tested for the collision.
692
+ *
693
+ * Note: if set to an empty array no collision will happen when this mesh is moved.
694
+ */
695
+ get surroundingMeshes() {
696
+ return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes;
697
+ }
698
+ set surroundingMeshes(meshes) {
699
+ this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = meshes;
700
+ }
701
+ /** Gets the list of lights affecting that mesh */
702
+ get lightSources() {
703
+ return this._lightSources;
704
+ }
705
+ /**
706
+ * Gets or sets a skeleton to apply skinning transformations
707
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/bonesSkeletons
708
+ */
709
+ set skeleton(value) {
710
+ const skeleton = this._internalAbstractMeshDataInfo._skeleton;
711
+ if (skeleton) {
712
+ skeleton.useCount--;
713
+ }
714
+ if (skeleton && skeleton.needInitialSkinMatrix) {
715
+ skeleton._unregisterMeshWithPoseMatrix(this);
716
+ }
717
+ if (value && value.needInitialSkinMatrix) {
718
+ value._registerMeshWithPoseMatrix(this);
719
+ }
720
+ if (value) {
721
+ value.useCount++;
722
+ }
723
+ this._internalAbstractMeshDataInfo._skeleton = value;
724
+ if (!this._internalAbstractMeshDataInfo._skeleton) {
725
+ this._bonesTransformMatrices = null;
726
+ }
727
+ this._markSubMeshesAsAttributesDirty();
728
+ }
729
+ get skeleton() {
730
+ return this._internalAbstractMeshDataInfo._skeleton;
731
+ }
732
+ // Constructor
733
+ /**
734
+ * Creates a new AbstractMesh
735
+ * @param name defines the name of the mesh
736
+ * @param scene defines the hosting scene
737
+ */
738
+ constructor(name, scene = null) {
739
+ super(name, scene, false);
740
+ // Internal data
741
+ /** @internal */
742
+ this._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo();
743
+ /** @internal */
744
+ this._waitingMaterialId = null;
745
+ /** @internal */
746
+ this._waitingMorphTargetManagerId = null;
747
+ /** @internal */
748
+ this._waitingSkeletonId = null;
749
+ /** @internal */
750
+ this._waitingSkeletonUniqueId = null;
751
+ /**
752
+ * The culling strategy to use to check whether the mesh must be rendered or not.
753
+ * This value can be changed at any time and will be used on the next render mesh selection.
754
+ * The possible values are :
755
+ * - AbstractMesh.CULLINGSTRATEGY_STANDARD
756
+ * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
757
+ * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
758
+ * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
759
+ * Please read each static variable documentation to get details about the culling process.
760
+ * */
761
+ this.cullingStrategy = _a.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
762
+ // Events
763
+ /**
764
+ * An event triggered when this mesh collides with another one
765
+ */
766
+ this.onCollideObservable = new Observable();
767
+ /**
768
+ * An event triggered when the collision's position changes
769
+ */
770
+ this.onCollisionPositionChangeObservable = new Observable();
771
+ /**
772
+ * An event triggered when material is changed
773
+ */
774
+ this.onMaterialChangedObservable = new Observable();
775
+ // Properties
776
+ /**
777
+ * Gets or sets the orientation for POV movement & rotation
778
+ */
779
+ this.definedFacingForward = true;
780
+ /** @internal */
781
+ this._occlusionQuery = null;
782
+ /** @internal */
783
+ this._renderingGroup = null;
784
+ /** Gets or sets the alpha index used to sort transparent meshes
785
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/transparent_rendering#alpha-index
786
+ */
787
+ this.alphaIndex = Number.MAX_VALUE;
788
+ /**
789
+ * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions).
790
+ * Default value is determined by {@link AbstractMesh.DefaultIsPickable} (true unless changed).
791
+ */
792
+ this.isPickable = _a.DefaultIsPickable;
793
+ /**
794
+ * Gets or sets a boolean indicating if the mesh can be near picked (touched by the XR controller or hands). Default is false
795
+ */
796
+ this.isNearPickable = false;
797
+ /**
798
+ * Gets or sets a boolean indicating if the mesh can be grabbed. Default is false.
799
+ * Setting this to true, while using the XR near interaction feature, will trigger a pointer event when the mesh is grabbed.
800
+ * Grabbing means that the controller is using the squeeze or main trigger button to grab the mesh.
801
+ * This is different from nearPickable which only triggers the event when the mesh is touched by the controller
802
+ */
803
+ this.isNearGrabbable = false;
804
+ /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
805
+ this.showSubMeshesBoundingBox = false;
806
+ /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
807
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/lenseFlare
808
+ */
809
+ this.isBlocker = false;
810
+ /**
811
+ * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
812
+ */
813
+ this.enablePointerMoveEvents = false;
814
+ /** Defines color to use when rendering outline */
815
+ this.outlineColor = Color3.Red();
816
+ /** Define width to use when rendering outline */
817
+ this.outlineWidth = 0.02;
818
+ /** Defines color to use when rendering overlay */
819
+ this.overlayColor = Color3.Red();
820
+ /** Defines alpha to use when rendering overlay */
821
+ this.overlayAlpha = 0.5;
822
+ /** Defines alpha to use when rendering internal overlay */
823
+ this._internalOverlayAlpha = 0.5;
824
+ /** Defines color to use when rendering internal overlay */
825
+ this._internalOverlayColor = Color3.Red();
826
+ /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
827
+ this.useOctreeForRenderingSelection = true;
828
+ /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
829
+ this.useOctreeForPicking = true;
830
+ /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
831
+ this.useOctreeForCollisions = true;
832
+ /**
833
+ * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
834
+ */
835
+ this.alwaysSelectAsActiveMesh = false;
836
+ /**
837
+ * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
838
+ */
839
+ this.doNotSyncBoundingInfo = false;
840
+ /**
841
+ * Gets or sets the current action manager
842
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions
843
+ */
844
+ this.actionManager = null;
845
+ /**
846
+ * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
847
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
848
+ */
849
+ this.ellipsoid = new Vector3(0.5, 1, 0.5);
850
+ /**
851
+ * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
852
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
853
+ */
854
+ this.ellipsoidOffset = new Vector3(0, 0, 0);
855
+ // Edges
856
+ /**
857
+ * Defines edge width used when edgesRenderer is enabled
858
+ * @see https://www.babylonjs-playground.com/#10OJSG#13
859
+ */
860
+ this.edgesWidth = 1;
861
+ /**
862
+ * Defines edge color used when edgesRenderer is enabled
863
+ * @see https://www.babylonjs-playground.com/#10OJSG#13
864
+ */
865
+ this.edgesColor = new Color4(1, 0, 0, 1);
866
+ /** @internal */
867
+ this._edgesRenderer = null;
868
+ /** @internal */
869
+ this._masterMesh = null;
870
+ this._boundingInfo = null;
871
+ this._boundingInfoIsDirty = true;
872
+ /** @internal */
873
+ this._renderId = 0;
874
+ /** @internal */
875
+ this._intersectionsInProgress = new Array();
876
+ /** @internal */
877
+ this._unIndexed = false;
878
+ /** @internal */
879
+ this._lightSources = new Array();
880
+ // Loading properties
881
+ /** @internal */
882
+ this._waitingData = {
883
+ lods: null,
884
+ actions: null,
885
+ freezeWorldMatrix: null,
886
+ };
887
+ /** @internal */
888
+ this._bonesTransformMatrices = null;
889
+ /** @internal */
890
+ this._transformMatrixTexture = null;
891
+ /**
892
+ * An event triggered when the mesh is rebuilt.
893
+ */
894
+ this.onRebuildObservable = new Observable();
895
+ this._onCollisionPositionChange = (collisionId, newPosition, collidedMesh = null) => {
896
+ newPosition.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions);
897
+ if (this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > AbstractEngine.CollisionsEpsilon) {
898
+ this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions);
899
+ }
900
+ if (collidedMesh) {
901
+ this.onCollideObservable.notifyObservers(collidedMesh);
902
+ }
903
+ this.onCollisionPositionChangeObservable.notifyObservers(this.position);
904
+ };
905
+ scene = this.getScene();
906
+ this.layerMask = scene.defaultRenderableLayerMask;
907
+ scene.addMesh(this);
908
+ this._resyncLightSources();
909
+ // Mesh Uniform Buffer.
910
+ this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name, !this.getScene().getEngine().isWebGPU);
911
+ this._buildUniformLayout();
912
+ switch (scene.performancePriority) {
913
+ case 2 /* ScenePerformancePriority.Aggressive */:
914
+ this.doNotSyncBoundingInfo = true;
915
+ // eslint-disable-next-line no-fallthrough
916
+ case 1 /* ScenePerformancePriority.Intermediate */:
917
+ this.alwaysSelectAsActiveMesh = true;
918
+ this.isPickable = false;
919
+ break;
920
+ }
921
+ }
922
+ _buildUniformLayout() {
923
+ this._uniformBuffer.addUniform("world", 16);
924
+ this._uniformBuffer.addUniform("visibility", 1);
925
+ this._uniformBuffer.create();
926
+ }
927
+ /**
928
+ * Transfer the mesh values to its UBO.
929
+ * @param world The world matrix associated with the mesh
930
+ */
931
+ transferToEffect(world) {
932
+ const ubo = this._uniformBuffer;
933
+ ubo.updateMatrix("world", world);
934
+ ubo.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility);
935
+ ubo.update();
936
+ }
937
+ /**
938
+ * Gets the mesh uniform buffer.
939
+ * @returns the uniform buffer of the mesh.
940
+ */
941
+ getMeshUniformBuffer() {
942
+ return this._uniformBuffer;
943
+ }
944
+ /**
945
+ * Returns the string "AbstractMesh"
946
+ * @returns "AbstractMesh"
947
+ */
948
+ getClassName() {
949
+ return "AbstractMesh";
950
+ }
951
+ /**
952
+ * Gets a string representation of the current mesh
953
+ * @param fullDetails defines a boolean indicating if full details must be included
954
+ * @returns a string representation of the current mesh
955
+ */
956
+ toString(fullDetails) {
957
+ let ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() === "InstancedMesh" ? "YES" : "NO");
958
+ ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
959
+ const skeleton = this._internalAbstractMeshDataInfo._skeleton;
960
+ if (skeleton) {
961
+ ret += ", skeleton: " + skeleton.name;
962
+ }
963
+ if (fullDetails) {
964
+ ret += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode];
965
+ ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO");
966
+ }
967
+ return ret;
968
+ }
969
+ /**
970
+ * @internal
971
+ */
972
+ _getEffectiveParent() {
973
+ if (this._masterMesh && this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
974
+ return this._masterMesh;
975
+ }
976
+ return super._getEffectiveParent();
977
+ }
978
+ /**
979
+ * @internal
980
+ */
981
+ _getActionManagerForTrigger(trigger, initialCall = true) {
982
+ if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
983
+ if (trigger) {
984
+ if (this.actionManager.hasSpecificTrigger(trigger)) {
985
+ return this.actionManager;
986
+ }
987
+ }
988
+ else {
989
+ return this.actionManager;
990
+ }
991
+ }
992
+ if (!this.parent) {
993
+ return null;
994
+ }
995
+ return this.parent._getActionManagerForTrigger(trigger, false);
996
+ }
997
+ /**
998
+ * @internal
999
+ */
1000
+ _releaseRenderPassId(_id) { }
1001
+ /**
1002
+ * @internal
1003
+ */
1004
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1005
+ _rebuild(dispose = false) {
1006
+ this.onRebuildObservable.notifyObservers(this);
1007
+ if (this._occlusionQuery !== null) {
1008
+ this._occlusionQuery = null;
1009
+ }
1010
+ if (!this.subMeshes) {
1011
+ return;
1012
+ }
1013
+ for (const subMesh of this.subMeshes) {
1014
+ subMesh._rebuild();
1015
+ }
1016
+ this.resetDrawCache();
1017
+ }
1018
+ /** @internal */
1019
+ _resyncLightSources() {
1020
+ this._lightSources.length = 0;
1021
+ for (const light of this.getScene().lights) {
1022
+ if (!light.isEnabled()) {
1023
+ continue;
1024
+ }
1025
+ if (light.canAffectMesh(this)) {
1026
+ this._lightSources.push(light);
1027
+ }
1028
+ }
1029
+ this._markSubMeshesAsLightDirty();
1030
+ }
1031
+ /**
1032
+ * @internal
1033
+ */
1034
+ _resyncLightSource(light) {
1035
+ const isIn = light.isEnabled() && light.canAffectMesh(this) && light.internalEnabled;
1036
+ const index = this._lightSources.indexOf(light);
1037
+ let removed = false;
1038
+ if (index === -1) {
1039
+ if (!isIn) {
1040
+ return;
1041
+ }
1042
+ this._lightSources.push(light);
1043
+ }
1044
+ else {
1045
+ if (isIn) {
1046
+ return;
1047
+ }
1048
+ removed = true;
1049
+ this._lightSources.splice(index, 1);
1050
+ }
1051
+ this._markSubMeshesAsLightDirty(removed);
1052
+ }
1053
+ /** @internal */
1054
+ _unBindEffect() {
1055
+ for (const subMesh of this.subMeshes) {
1056
+ subMesh.setEffect(null);
1057
+ }
1058
+ }
1059
+ /**
1060
+ * @internal
1061
+ */
1062
+ _removeLightSource(light, dispose) {
1063
+ const index = this._lightSources.indexOf(light);
1064
+ if (index === -1) {
1065
+ return;
1066
+ }
1067
+ this._lightSources.splice(index, 1);
1068
+ this._markSubMeshesAsLightDirty(dispose);
1069
+ }
1070
+ _markSubMeshesAsDirty(func) {
1071
+ if (!this.subMeshes) {
1072
+ return;
1073
+ }
1074
+ for (const subMesh of this.subMeshes) {
1075
+ for (let i = 0; i < subMesh._drawWrappers.length; ++i) {
1076
+ const drawWrapper = subMesh._drawWrappers[i];
1077
+ if (!drawWrapper || !drawWrapper.defines || !drawWrapper.defines.markAllAsDirty) {
1078
+ continue;
1079
+ }
1080
+ func(drawWrapper.defines);
1081
+ }
1082
+ }
1083
+ }
1084
+ /**
1085
+ * @internal
1086
+ */
1087
+ _markSubMeshesAsLightDirty(dispose = false) {
1088
+ this._markSubMeshesAsDirty((defines) => defines.markAsLightDirty(dispose));
1089
+ }
1090
+ /** @internal */
1091
+ _markSubMeshesAsAttributesDirty() {
1092
+ this._markSubMeshesAsDirty((defines) => defines.markAsAttributesDirty());
1093
+ }
1094
+ /** @internal */
1095
+ _markSubMeshesAsMiscDirty() {
1096
+ this._markSubMeshesAsDirty((defines) => defines.markAsMiscDirty());
1097
+ }
1098
+ /**
1099
+ * Flag the AbstractMesh as dirty (Forcing it to update everything)
1100
+ * @param property if set to "rotation" the objects rotationQuaternion will be set to null
1101
+ * @returns this AbstractMesh
1102
+ */
1103
+ markAsDirty(property) {
1104
+ this._currentRenderId = Number.MAX_VALUE;
1105
+ super.markAsDirty(property);
1106
+ this._isDirty = true;
1107
+ return this;
1108
+ }
1109
+ /**
1110
+ * Resets the draw wrappers cache for all submeshes of this abstract mesh
1111
+ * @param passId If provided, releases only the draw wrapper corresponding to this render pass id
1112
+ * @param immediate If true, the effect will be released immediately, otherwise it will be released at the next frame
1113
+ */
1114
+ resetDrawCache(passId, immediate = false) {
1115
+ if (!this.subMeshes) {
1116
+ return;
1117
+ }
1118
+ for (const subMesh of this.subMeshes) {
1119
+ subMesh.resetDrawCache(passId, immediate);
1120
+ }
1121
+ }
1122
+ // Methods
1123
+ /**
1124
+ * Returns true if the mesh is blocked. Implemented by child classes
1125
+ */
1126
+ get isBlocked() {
1127
+ return false;
1128
+ }
1129
+ /**
1130
+ * Returns the mesh itself by default. Implemented by child classes
1131
+ * @param camera defines the camera to use to pick the right LOD level
1132
+ * @returns the currentAbstractMesh
1133
+ */
1134
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1135
+ getLOD(camera) {
1136
+ return this;
1137
+ }
1138
+ /**
1139
+ * Returns 0 by default. Implemented by child classes
1140
+ * @returns an integer
1141
+ */
1142
+ getTotalVertices() {
1143
+ return 0;
1144
+ }
1145
+ /**
1146
+ * Returns a positive integer : the total number of indices in this mesh geometry.
1147
+ * @returns the number of indices or zero if the mesh has no geometry.
1148
+ */
1149
+ getTotalIndices() {
1150
+ return 0;
1151
+ }
1152
+ /**
1153
+ * Returns null by default. Implemented by child classes
1154
+ * @returns null
1155
+ */
1156
+ getIndices() {
1157
+ return null;
1158
+ }
1159
+ /**
1160
+ * Returns the array of the requested vertex data kind. Implemented by child classes
1161
+ * @param kind defines the vertex data kind to use
1162
+ * @returns null
1163
+ */
1164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1165
+ getVerticesData(kind) {
1166
+ return null;
1167
+ }
1168
+ /**
1169
+ * Sets the vertex data of the mesh geometry for the requested `kind`.
1170
+ * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
1171
+ * Note that a new underlying VertexBuffer object is created each call.
1172
+ * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
1173
+ * @param kind defines vertex data kind:
1174
+ * * VertexBuffer.PositionKind
1175
+ * * VertexBuffer.UVKind
1176
+ * * VertexBuffer.UV2Kind
1177
+ * * VertexBuffer.UV3Kind
1178
+ * * VertexBuffer.UV4Kind
1179
+ * * VertexBuffer.UV5Kind
1180
+ * * VertexBuffer.UV6Kind
1181
+ * * VertexBuffer.ColorKind
1182
+ * * VertexBuffer.MatricesIndicesKind
1183
+ * * VertexBuffer.MatricesIndicesExtraKind
1184
+ * * VertexBuffer.MatricesWeightsKind
1185
+ * * VertexBuffer.MatricesWeightsExtraKind
1186
+ * @param data defines the data source
1187
+ * @param updatable defines if the data must be flagged as updatable (or static)
1188
+ * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
1189
+ * @returns the current mesh
1190
+ */
1191
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1192
+ setVerticesData(kind, data, updatable, stride) {
1193
+ return this;
1194
+ }
1195
+ /**
1196
+ * Updates the existing vertex data of the mesh geometry for the requested `kind`.
1197
+ * If the mesh has no geometry, it is simply returned as it is.
1198
+ * @param kind defines vertex data kind:
1199
+ * * VertexBuffer.PositionKind
1200
+ * * VertexBuffer.UVKind
1201
+ * * VertexBuffer.UV2Kind
1202
+ * * VertexBuffer.UV3Kind
1203
+ * * VertexBuffer.UV4Kind
1204
+ * * VertexBuffer.UV5Kind
1205
+ * * VertexBuffer.UV6Kind
1206
+ * * VertexBuffer.ColorKind
1207
+ * * VertexBuffer.MatricesIndicesKind
1208
+ * * VertexBuffer.MatricesIndicesExtraKind
1209
+ * * VertexBuffer.MatricesWeightsKind
1210
+ * * VertexBuffer.MatricesWeightsExtraKind
1211
+ * @param data defines the data source
1212
+ * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
1213
+ * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
1214
+ * @returns the current mesh
1215
+ */
1216
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1217
+ updateVerticesData(kind, data, updateExtends, makeItUnique) {
1218
+ return this;
1219
+ }
1220
+ /**
1221
+ * Sets the mesh indices,
1222
+ * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
1223
+ * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
1224
+ * @param totalVertices Defines the total number of vertices
1225
+ * @returns the current mesh
1226
+ */
1227
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1228
+ setIndices(indices, totalVertices) {
1229
+ return this;
1230
+ }
1231
+ /**
1232
+ * Gets a boolean indicating if specific vertex data is present
1233
+ * @param kind defines the vertex data kind to use
1234
+ * @returns true is data kind is present
1235
+ */
1236
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1237
+ isVerticesDataPresent(kind) {
1238
+ return false;
1239
+ }
1240
+ /**
1241
+ * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
1242
+ * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
1243
+ * However, if the mesh contains thin instances, it will be expanded to include them. If you want the "raw" bounding data instead, then use `getRawBoundingInfo()`.
1244
+ * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
1245
+ * @returns a BoundingInfo
1246
+ */
1247
+ getBoundingInfo() {
1248
+ if (this._masterMesh) {
1249
+ return this._masterMesh.getBoundingInfo();
1250
+ }
1251
+ if (this._boundingInfoIsDirty) {
1252
+ this._boundingInfoIsDirty = false;
1253
+ // this._boundingInfo is being created if undefined
1254
+ this._updateBoundingInfo();
1255
+ }
1256
+ // cannot be null.
1257
+ return this._boundingInfo;
1258
+ }
1259
+ /**
1260
+ * Returns the bounding info unnafected by instance data.
1261
+ * @returns the bounding info of the mesh unaffected by instance data.
1262
+ */
1263
+ getRawBoundingInfo() {
1264
+ return this.rawBoundingInfo ?? this.getBoundingInfo();
1265
+ }
1266
+ /**
1267
+ * Overwrite the current bounding info
1268
+ * @param boundingInfo defines the new bounding info
1269
+ * @returns the current mesh
1270
+ */
1271
+ setBoundingInfo(boundingInfo) {
1272
+ this._boundingInfo = boundingInfo;
1273
+ return this;
1274
+ }
1275
+ /**
1276
+ * Returns true if there is already a bounding info
1277
+ */
1278
+ get hasBoundingInfo() {
1279
+ return this._boundingInfo !== null;
1280
+ }
1281
+ /**
1282
+ * Creates a new bounding info for the mesh
1283
+ * @param minimum min vector of the bounding box/sphere
1284
+ * @param maximum max vector of the bounding box/sphere
1285
+ * @param worldMatrix defines the new world matrix
1286
+ * @returns the new bounding info
1287
+ */
1288
+ buildBoundingInfo(minimum, maximum, worldMatrix) {
1289
+ this._boundingInfo = new BoundingInfo(minimum, maximum, worldMatrix);
1290
+ return this._boundingInfo;
1291
+ }
1292
+ /**
1293
+ * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
1294
+ * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
1295
+ * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
1296
+ * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
1297
+ * @returns the current mesh
1298
+ */
1299
+ normalizeToUnitCube(includeDescendants = true, ignoreRotation = false, predicate) {
1300
+ return super.normalizeToUnitCube(includeDescendants, ignoreRotation, predicate);
1301
+ }
1302
+ /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
1303
+ get useBones() {
1304
+ return ((this.skeleton &&
1305
+ this.getScene().skeletonsEnabled &&
1306
+ this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) &&
1307
+ this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)));
1308
+ }
1309
+ /** @internal */
1310
+ _preActivate() { }
1311
+ /**
1312
+ * @internal
1313
+ */
1314
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1315
+ _preActivateForIntermediateRendering(renderId) { }
1316
+ /**
1317
+ * @internal
1318
+ */
1319
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1320
+ _activate(renderId, intermediateRendering) {
1321
+ this._renderId = renderId;
1322
+ return true;
1323
+ }
1324
+ /** @internal */
1325
+ _postActivate() {
1326
+ // Do nothing
1327
+ }
1328
+ /** @internal */
1329
+ _freeze() {
1330
+ // Do nothing
1331
+ }
1332
+ /** @internal */
1333
+ _unFreeze() {
1334
+ // Do nothing
1335
+ }
1336
+ /**
1337
+ * Gets the current world matrix
1338
+ * @returns a Matrix
1339
+ */
1340
+ getWorldMatrix() {
1341
+ if (this._masterMesh && this.billboardMode === TransformNode.BILLBOARDMODE_NONE) {
1342
+ return this._masterMesh.getWorldMatrix();
1343
+ }
1344
+ return super.getWorldMatrix();
1345
+ }
1346
+ /** @internal */
1347
+ _getWorldMatrixDeterminant() {
1348
+ if (this._masterMesh) {
1349
+ return this._masterMesh._getWorldMatrixDeterminant();
1350
+ }
1351
+ return super._getWorldMatrixDeterminant();
1352
+ }
1353
+ /**
1354
+ * Gets a boolean indicating if this mesh is an instance or a regular mesh
1355
+ */
1356
+ get isAnInstance() {
1357
+ return false;
1358
+ }
1359
+ /**
1360
+ * Gets a boolean indicating if this mesh has instances
1361
+ */
1362
+ get hasInstances() {
1363
+ return false;
1364
+ }
1365
+ /**
1366
+ * Gets a boolean indicating if this mesh has thin instances
1367
+ */
1368
+ get hasThinInstances() {
1369
+ return false;
1370
+ }
1371
+ // ================================== Point of View Movement =================================
1372
+ /**
1373
+ * Perform relative position change from the point of view of behind the front of the mesh.
1374
+ * This is performed taking into account the meshes current rotation, so you do not have to care.
1375
+ * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1376
+ * @param amountRight defines the distance on the right axis
1377
+ * @param amountUp defines the distance on the up axis
1378
+ * @param amountForward defines the distance on the forward axis
1379
+ * @returns the current mesh
1380
+ */
1381
+ movePOV(amountRight, amountUp, amountForward) {
1382
+ this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
1383
+ return this;
1384
+ }
1385
+ /**
1386
+ * Calculate relative position change from the point of view of behind the front of the mesh.
1387
+ * This is performed taking into account the meshes current rotation, so you do not have to care.
1388
+ * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1389
+ * @param amountRight defines the distance on the right axis
1390
+ * @param amountUp defines the distance on the up axis
1391
+ * @param amountForward defines the distance on the forward axis
1392
+ * @returns the new displacement vector
1393
+ */
1394
+ calcMovePOV(amountRight, amountUp, amountForward) {
1395
+ const rotMatrix = new Matrix();
1396
+ const rotQuaternion = this.rotationQuaternion ? this.rotationQuaternion : Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
1397
+ rotQuaternion.toRotationMatrix(rotMatrix);
1398
+ const translationDelta = Vector3.Zero();
1399
+ const defForwardMult = this.definedFacingForward ? -1 : 1;
1400
+ Vector3.TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
1401
+ return translationDelta;
1402
+ }
1403
+ // ================================== Point of View Rotation =================================
1404
+ /**
1405
+ * Perform relative rotation change from the point of view of behind the front of the mesh.
1406
+ * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1407
+ * @param flipBack defines the flip
1408
+ * @param twirlClockwise defines the twirl
1409
+ * @param tiltRight defines the tilt
1410
+ * @returns the current mesh
1411
+ */
1412
+ rotatePOV(flipBack, twirlClockwise, tiltRight) {
1413
+ this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
1414
+ return this;
1415
+ }
1416
+ /**
1417
+ * Calculate relative rotation change from the point of view of behind the front of the mesh.
1418
+ * Supports definition of mesh facing forward or backward {@link definedFacingForwardSearch | See definedFacingForwardSearch }.
1419
+ * @param flipBack defines the flip
1420
+ * @param twirlClockwise defines the twirl
1421
+ * @param tiltRight defines the tilt
1422
+ * @returns the new rotation vector
1423
+ */
1424
+ calcRotatePOV(flipBack, twirlClockwise, tiltRight) {
1425
+ const defForwardMult = this.definedFacingForward ? 1 : -1;
1426
+ return new Vector3(flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
1427
+ }
1428
+ /**
1429
+ * @internal
1430
+ */
1431
+ _refreshBoundingInfo(data, bias) {
1432
+ if (data) {
1433
+ const extend = extractMinAndMax(data, 0, this.getTotalVertices(), bias);
1434
+ if (this._boundingInfo) {
1435
+ this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
1436
+ }
1437
+ else {
1438
+ this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);
1439
+ }
1440
+ }
1441
+ if (this.subMeshes) {
1442
+ for (let index = 0; index < this.subMeshes.length; index++) {
1443
+ this.subMeshes[index].refreshBoundingInfo(data);
1444
+ }
1445
+ }
1446
+ this._updateBoundingInfo();
1447
+ }
1448
+ /**
1449
+ * @internal
1450
+ */
1451
+ _refreshBoundingInfoDirect(extend) {
1452
+ if (this._boundingInfo) {
1453
+ this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
1454
+ }
1455
+ else {
1456
+ this._boundingInfo = new BoundingInfo(extend.minimum, extend.maximum);
1457
+ }
1458
+ if (this.subMeshes) {
1459
+ for (let index = 0; index < this.subMeshes.length; index++) {
1460
+ this.subMeshes[index].refreshBoundingInfo(null);
1461
+ }
1462
+ }
1463
+ this._updateBoundingInfo();
1456
1464
  }
1457
- }
1458
- this._updateBoundingInfo();
1459
- }
1460
- // This function is only here so we can apply the nativeOverride decorator.
1461
- static _ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData) {
1462
- ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData);
1463
- }
1464
- /** @internal */
1465
- _getData(options, data, kind = VertexBuffer.PositionKind) {
1466
- const cache = options.cache;
1467
- const getVertexData = (kind) => {
1468
- if (cache) {
1469
- const vertexData = (cache._vertexData || (cache._vertexData = {}));
1470
- if (!vertexData[kind]) {
1471
- this.copyVerticesData(kind, vertexData);
1472
- }
1473
- return vertexData[kind];
1474
- }
1475
- return this.getVerticesData(kind);
1476
- };
1477
- data || (data = getVertexData(kind));
1478
- if (!data) {
1479
- return null;
1480
- }
1481
- if (cache) {
1482
- if (cache._outputData) {
1483
- cache._outputData.set(data);
1465
+ // This function is only here so we can apply the nativeOverride decorator.
1466
+ static _ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData) {
1467
+ ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData);
1484
1468
  }
1485
- else {
1486
- cache._outputData = new Float32Array(data);
1469
+ /** @internal */
1470
+ _getData(options, data, kind = VertexBuffer.PositionKind) {
1471
+ const cache = options.cache;
1472
+ const getVertexData = (kind) => {
1473
+ if (cache) {
1474
+ const vertexData = (cache._vertexData || (cache._vertexData = {}));
1475
+ if (!vertexData[kind]) {
1476
+ this.copyVerticesData(kind, vertexData);
1477
+ }
1478
+ return vertexData[kind];
1479
+ }
1480
+ return this.getVerticesData(kind);
1481
+ };
1482
+ data || (data = getVertexData(kind));
1483
+ if (!data) {
1484
+ return null;
1485
+ }
1486
+ if (cache) {
1487
+ if (cache._outputData) {
1488
+ cache._outputData.set(data);
1489
+ }
1490
+ else {
1491
+ cache._outputData = new Float32Array(data);
1492
+ }
1493
+ data = cache._outputData;
1494
+ }
1495
+ else if ((options.applyMorph && this.morphTargetManager) ||
1496
+ (options.applySkeleton && this.skeleton) ||
1497
+ (options.applyBakedVertexAnimation && this.bakedVertexAnimationManager?.isEnabled)) {
1498
+ data = data.slice();
1499
+ }
1500
+ if (options.applyMorph && this.morphTargetManager) {
1501
+ ApplyMorph(data, kind, this.morphTargetManager);
1502
+ }
1503
+ const bakedVertexAnimationManager = this.bakedVertexAnimationManager;
1504
+ let bakedVertexAnimationApplied = false;
1505
+ if (options.applyBakedVertexAnimation && bakedVertexAnimationManager?.isEnabled) {
1506
+ const matricesIndicesData = getVertexData(VertexBuffer.MatricesIndicesKind);
1507
+ const matricesWeightsData = getVertexData(VertexBuffer.MatricesWeightsKind);
1508
+ if (matricesWeightsData && matricesIndicesData) {
1509
+ const needExtras = this.numBoneInfluencers > 4;
1510
+ const matricesIndicesExtraData = needExtras ? getVertexData(VertexBuffer.MatricesIndicesExtraKind) : null;
1511
+ const matricesWeightsExtraData = needExtras ? getVertexData(VertexBuffer.MatricesWeightsExtraKind) : null;
1512
+ bakedVertexAnimationApplied = ApplyBakedVertexAnimation(data, kind, bakedVertexAnimationManager, options.bakedVertexAnimationSettings ?? bakedVertexAnimationManager.animationParameters, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData, this.numBoneInfluencers);
1513
+ }
1514
+ }
1515
+ if (!bakedVertexAnimationApplied && options.applySkeleton && this.skeleton) {
1516
+ const matricesIndicesData = getVertexData(VertexBuffer.MatricesIndicesKind);
1517
+ const matricesWeightsData = getVertexData(VertexBuffer.MatricesWeightsKind);
1518
+ if (matricesWeightsData && matricesIndicesData) {
1519
+ const needExtras = this.numBoneInfluencers > 4;
1520
+ const matricesIndicesExtraData = needExtras ? getVertexData(VertexBuffer.MatricesIndicesExtraKind) : null;
1521
+ const matricesWeightsExtraData = needExtras ? getVertexData(VertexBuffer.MatricesWeightsExtraKind) : null;
1522
+ const skeletonMatrices = this.skeleton.getTransformMatrices(this);
1523
+ _a._ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData);
1524
+ }
1525
+ }
1526
+ if (options.updatePositionsArray !== false && kind === VertexBuffer.PositionKind) {
1527
+ const positions = this._internalAbstractMeshDataInfo._positions || [];
1528
+ const previousLength = positions.length;
1529
+ positions.length = data.length / 3;
1530
+ if (previousLength < positions.length) {
1531
+ for (let positionIndex = previousLength; positionIndex < positions.length; positionIndex++) {
1532
+ positions[positionIndex] = new Vector3();
1533
+ }
1534
+ }
1535
+ for (let positionIndex = 0, dataIndex = 0; positionIndex < positions.length; positionIndex++, dataIndex += 3) {
1536
+ positions[positionIndex].copyFromFloats(data[dataIndex], data[dataIndex + 1], data[dataIndex + 2]);
1537
+ }
1538
+ this._internalAbstractMeshDataInfo._positions = positions;
1539
+ }
1540
+ return data;
1487
1541
  }
1488
- data = cache._outputData;
1489
- }
1490
- else if ((options.applyMorph && this.morphTargetManager) ||
1491
- (options.applySkeleton && this.skeleton) ||
1492
- (options.applyBakedVertexAnimation && this.bakedVertexAnimationManager?.isEnabled)) {
1493
- data = data.slice();
1494
- }
1495
- if (options.applyMorph && this.morphTargetManager) {
1496
- ApplyMorph(data, kind, this.morphTargetManager);
1497
- }
1498
- const bakedVertexAnimationManager = this.bakedVertexAnimationManager;
1499
- let bakedVertexAnimationApplied = false;
1500
- if (options.applyBakedVertexAnimation && bakedVertexAnimationManager?.isEnabled) {
1501
- const matricesIndicesData = getVertexData(VertexBuffer.MatricesIndicesKind);
1502
- const matricesWeightsData = getVertexData(VertexBuffer.MatricesWeightsKind);
1503
- if (matricesWeightsData && matricesIndicesData) {
1504
- const needExtras = this.numBoneInfluencers > 4;
1505
- const matricesIndicesExtraData = needExtras ? getVertexData(VertexBuffer.MatricesIndicesExtraKind) : null;
1506
- const matricesWeightsExtraData = needExtras ? getVertexData(VertexBuffer.MatricesWeightsExtraKind) : null;
1507
- bakedVertexAnimationApplied = ApplyBakedVertexAnimation(data, kind, bakedVertexAnimationManager, options.bakedVertexAnimationSettings ?? bakedVertexAnimationManager.animationParameters, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData, this.numBoneInfluencers);
1542
+ /**
1543
+ * Get the normals vertex data and optionally apply skeleton and morphing.
1544
+ * @param applySkeleton defines whether to apply the skeleton
1545
+ * @param applyMorph defines whether to apply the morph target
1546
+ * @returns the normals data
1547
+ */
1548
+ getNormalsData(applySkeleton = false, applyMorph = false) {
1549
+ return this._getData({ applySkeleton, applyMorph, updatePositionsArray: false }, null, VertexBuffer.NormalKind);
1508
1550
  }
1509
- }
1510
- if (!bakedVertexAnimationApplied && options.applySkeleton && this.skeleton) {
1511
- const matricesIndicesData = getVertexData(VertexBuffer.MatricesIndicesKind);
1512
- const matricesWeightsData = getVertexData(VertexBuffer.MatricesWeightsKind);
1513
- if (matricesWeightsData && matricesIndicesData) {
1514
- const needExtras = this.numBoneInfluencers > 4;
1515
- const matricesIndicesExtraData = needExtras ? getVertexData(VertexBuffer.MatricesIndicesExtraKind) : null;
1516
- const matricesWeightsExtraData = needExtras ? getVertexData(VertexBuffer.MatricesWeightsExtraKind) : null;
1517
- const skeletonMatrices = this.skeleton.getTransformMatrices(this);
1518
- AbstractMesh._ApplySkeleton(data, kind, skeletonMatrices, matricesIndicesData, matricesWeightsData, matricesIndicesExtraData, matricesWeightsExtraData);
1551
+ /**
1552
+ * Get the position vertex data and optionally apply skeleton and morphing.
1553
+ * @param applySkeleton defines whether to apply the skeleton
1554
+ * @param applyMorph defines whether to apply the morph target
1555
+ * @param data defines the position data to apply the skeleton and morph to
1556
+ * @returns the position data
1557
+ */
1558
+ getPositionData(applySkeleton = false, applyMorph = false, data = null) {
1559
+ return this._getData({ applySkeleton, applyMorph, updatePositionsArray: false }, data, VertexBuffer.PositionKind);
1519
1560
  }
1520
- }
1521
- if (options.updatePositionsArray !== false && kind === VertexBuffer.PositionKind) {
1522
- const positions = this._internalAbstractMeshDataInfo._positions || [];
1523
- const previousLength = positions.length;
1524
- positions.length = data.length / 3;
1525
- if (previousLength < positions.length) {
1526
- for (let positionIndex = previousLength; positionIndex < positions.length; positionIndex++) {
1527
- positions[positionIndex] = new Vector3();
1561
+ /** @internal */
1562
+ _updateBoundingInfo() {
1563
+ if (this._boundingInfo) {
1564
+ this._boundingInfo.update(this.worldMatrixFromCache);
1565
+ }
1566
+ else {
1567
+ this._boundingInfo = new BoundingInfo(Vector3.Zero(), Vector3.Zero(), this.worldMatrixFromCache);
1528
1568
  }
1569
+ this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
1570
+ return this;
1529
1571
  }
1530
- for (let positionIndex = 0, dataIndex = 0; positionIndex < positions.length; positionIndex++, dataIndex += 3) {
1531
- positions[positionIndex].copyFromFloats(data[dataIndex], data[dataIndex + 1], data[dataIndex + 2]);
1572
+ /**
1573
+ * @internal
1574
+ */
1575
+ _updateSubMeshesBoundingInfo(matrix) {
1576
+ if (!this.subMeshes) {
1577
+ return this;
1578
+ }
1579
+ const count = this.subMeshes.length;
1580
+ for (let subIndex = 0; subIndex < count; subIndex++) {
1581
+ const subMesh = this.subMeshes[subIndex];
1582
+ if (count > 1 || !subMesh.IsGlobal) {
1583
+ subMesh.updateBoundingInfo(matrix);
1584
+ }
1585
+ }
1586
+ return this;
1532
1587
  }
1533
- this._internalAbstractMeshDataInfo._positions = positions;
1534
- }
1535
- return data;
1536
- }
1537
- /**
1538
- * Get the normals vertex data and optionally apply skeleton and morphing.
1539
- * @param applySkeleton defines whether to apply the skeleton
1540
- * @param applyMorph defines whether to apply the morph target
1541
- * @returns the normals data
1542
- */
1543
- getNormalsData(applySkeleton = false, applyMorph = false) {
1544
- return this._getData({ applySkeleton, applyMorph, updatePositionsArray: false }, null, VertexBuffer.NormalKind);
1545
- }
1546
- /**
1547
- * Get the position vertex data and optionally apply skeleton and morphing.
1548
- * @param applySkeleton defines whether to apply the skeleton
1549
- * @param applyMorph defines whether to apply the morph target
1550
- * @param data defines the position data to apply the skeleton and morph to
1551
- * @returns the position data
1552
- */
1553
- getPositionData(applySkeleton = false, applyMorph = false, data = null) {
1554
- return this._getData({ applySkeleton, applyMorph, updatePositionsArray: false }, data, VertexBuffer.PositionKind);
1555
- }
1556
- /** @internal */
1557
- _updateBoundingInfo() {
1558
- if (this._boundingInfo) {
1559
- this._boundingInfo.update(this.worldMatrixFromCache);
1560
- }
1561
- else {
1562
- this._boundingInfo = new BoundingInfo(Vector3.Zero(), Vector3.Zero(), this.worldMatrixFromCache);
1563
- }
1564
- this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
1565
- return this;
1566
- }
1567
- /**
1568
- * @internal
1569
- */
1570
- _updateSubMeshesBoundingInfo(matrix) {
1571
- if (!this.subMeshes) {
1572
- return this;
1573
- }
1574
- const count = this.subMeshes.length;
1575
- for (let subIndex = 0; subIndex < count; subIndex++) {
1576
- const subMesh = this.subMeshes[subIndex];
1577
- if (count > 1 || !subMesh.IsGlobal) {
1578
- subMesh.updateBoundingInfo(matrix);
1588
+ /** @internal */
1589
+ _afterComputeWorldMatrix() {
1590
+ if (this.doNotSyncBoundingInfo) {
1591
+ return;
1592
+ }
1593
+ // Bounding info
1594
+ this._boundingInfoIsDirty = true;
1579
1595
  }
1580
- }
1581
- return this;
1582
- }
1583
- /** @internal */
1584
- _afterComputeWorldMatrix() {
1585
- if (this.doNotSyncBoundingInfo) {
1586
- return;
1587
- }
1588
- // Bounding info
1589
- this._boundingInfoIsDirty = true;
1590
- }
1591
- /**
1592
- * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
1593
- * A mesh is in the frustum if its bounding box intersects the frustum
1594
- * @param frustumPlanes defines the frustum to test
1595
- * @returns true if the mesh is in the frustum planes
1596
- */
1597
- isInFrustum(frustumPlanes) {
1598
- return this.getBoundingInfo().isInFrustum(frustumPlanes, this.cullingStrategy);
1599
- }
1600
- /**
1601
- * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
1602
- * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
1603
- * @param frustumPlanes defines the frustum to test
1604
- * @returns true if the mesh is completely in the frustum planes
1605
- */
1606
- isCompletelyInFrustum(frustumPlanes) {
1607
- return this.getBoundingInfo().isCompletelyInFrustum(frustumPlanes);
1608
- }
1609
- /**
1610
- * True if the mesh intersects another mesh or a SolidParticle object
1611
- * @param mesh defines a target mesh or SolidParticle to test
1612
- * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
1613
- * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
1614
- * @returns true if there is an intersection
1615
- */
1616
- intersectsMesh(mesh, precise = false, includeDescendants) {
1617
- const boundingInfo = this.getBoundingInfo();
1618
- const otherBoundingInfo = mesh.getBoundingInfo();
1619
- if (boundingInfo.intersects(otherBoundingInfo, precise)) {
1620
- return true;
1621
- }
1622
- if (includeDescendants) {
1623
- for (const child of this.getChildMeshes()) {
1624
- if (child.intersectsMesh(mesh, precise, true)) {
1596
+ /**
1597
+ * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
1598
+ * A mesh is in the frustum if its bounding box intersects the frustum
1599
+ * @param frustumPlanes defines the frustum to test
1600
+ * @returns true if the mesh is in the frustum planes
1601
+ */
1602
+ isInFrustum(frustumPlanes) {
1603
+ return this.getBoundingInfo().isInFrustum(frustumPlanes, this.cullingStrategy);
1604
+ }
1605
+ /**
1606
+ * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
1607
+ * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
1608
+ * @param frustumPlanes defines the frustum to test
1609
+ * @returns true if the mesh is completely in the frustum planes
1610
+ */
1611
+ isCompletelyInFrustum(frustumPlanes) {
1612
+ return this.getBoundingInfo().isCompletelyInFrustum(frustumPlanes);
1613
+ }
1614
+ /**
1615
+ * True if the mesh intersects another mesh or a SolidParticle object
1616
+ * @param mesh defines a target mesh or SolidParticle to test
1617
+ * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
1618
+ * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
1619
+ * @returns true if there is an intersection
1620
+ */
1621
+ intersectsMesh(mesh, precise = false, includeDescendants) {
1622
+ const boundingInfo = this.getBoundingInfo();
1623
+ const otherBoundingInfo = mesh.getBoundingInfo();
1624
+ if (boundingInfo.intersects(otherBoundingInfo, precise)) {
1625
1625
  return true;
1626
1626
  }
1627
+ if (includeDescendants) {
1628
+ for (const child of this.getChildMeshes()) {
1629
+ if (child.intersectsMesh(mesh, precise, true)) {
1630
+ return true;
1631
+ }
1632
+ }
1633
+ }
1634
+ return false;
1627
1635
  }
1628
- }
1629
- return false;
1630
- }
1631
- /**
1632
- * Returns true if the passed point (Vector3) is inside the mesh bounding box
1633
- * @param point defines the point to test
1634
- * @returns true if there is an intersection
1635
- */
1636
- intersectsPoint(point) {
1637
- return this.getBoundingInfo().intersectsPoint(point);
1638
- }
1639
- // Collisions
1640
- /**
1641
- * Gets or sets a boolean indicating that this mesh can be used in the collision engine
1642
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
1643
- */
1644
- get checkCollisions() {
1645
- return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions;
1646
- }
1647
- set checkCollisions(collisionEnabled) {
1648
- this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = collisionEnabled;
1649
- }
1650
- /**
1651
- * Gets Collider object used to compute collisions (not physics)
1652
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
1653
- */
1654
- get collider() {
1655
- return this._internalAbstractMeshDataInfo._meshCollisionData._collider;
1656
- }
1657
- /**
1658
- * Move the mesh using collision engine
1659
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
1660
- * @param displacement defines the requested displacement vector
1661
- * @param slideOnCollide If true, the mesh will slide along a collider's surface. If false, it will stop moving at the first collision. (true by default)
1662
- * @returns the current mesh
1663
- */
1664
- moveWithCollisions(displacement, slideOnCollide = true) {
1665
- const globalPosition = this.getAbsolutePosition();
1666
- globalPosition.addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
1667
- const coordinator = this.getScene().collisionCoordinator;
1668
- if (!this._internalAbstractMeshDataInfo._meshCollisionData._collider) {
1669
- this._internalAbstractMeshDataInfo._meshCollisionData._collider = coordinator.createCollider();
1670
- }
1671
- this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid;
1672
- coordinator.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, displacement, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId, slideOnCollide);
1673
- return this;
1674
- }
1675
- // Collisions
1676
- /**
1677
- * @internal
1678
- */
1679
- _collideForSubMesh(subMesh, transformMatrix, collider) {
1680
- this._generatePointsArray();
1681
- if (!this._positions) {
1682
- return this;
1683
- }
1684
- // Transformation
1685
- if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
1686
- subMesh._lastColliderTransformMatrix = transformMatrix.clone();
1687
- subMesh._lastColliderWorldVertices = [];
1688
- subMesh._trianglePlanes = [];
1689
- const start = subMesh.verticesStart;
1690
- const end = subMesh.verticesStart + subMesh.verticesCount;
1691
- for (let i = start; i < end; i++) {
1692
- subMesh._lastColliderWorldVertices.push(Vector3.TransformCoordinates(this._positions[i], transformMatrix));
1636
+ /**
1637
+ * Returns true if the passed point (Vector3) is inside the mesh bounding box
1638
+ * @param point defines the point to test
1639
+ * @returns true if there is an intersection
1640
+ */
1641
+ intersectsPoint(point) {
1642
+ return this.getBoundingInfo().intersectsPoint(point);
1693
1643
  }
1694
- }
1695
- // Collide
1696
- collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial(), this, this._shouldConvertRHS(), subMesh.getMaterial()?.fillMode === 7);
1697
- return this;
1698
- }
1699
- /**
1700
- * @internal
1701
- */
1702
- _processCollisionsForSubMeshes(collider, transformMatrix) {
1703
- const subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
1704
- const len = subMeshes.length;
1705
- for (let index = 0; index < len; index++) {
1706
- const subMesh = subMeshes.data[index];
1707
- // Bounding test
1708
- if (len > 1 && !subMesh._checkCollision(collider)) {
1709
- continue;
1710
- }
1711
- this._collideForSubMesh(subMesh, transformMatrix, collider);
1712
- }
1713
- return this;
1714
- }
1715
- /** @internal */
1716
- _shouldConvertRHS() {
1717
- return false;
1718
- }
1719
- /**
1720
- * @internal
1721
- */
1722
- _checkCollision(collider) {
1723
- // Bounding box test
1724
- if (!this.getBoundingInfo()._checkCollision(collider)) {
1725
- return this;
1726
- }
1727
- // Transformation matrix
1728
- const collisionsScalingMatrix = TmpVectors.Matrix[0];
1729
- const collisionsTransformMatrix = TmpVectors.Matrix[1];
1730
- Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
1731
- this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
1732
- this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
1733
- return this;
1734
- }
1735
- // Picking
1736
- /** @internal */
1737
- _generatePointsArray() {
1738
- return false;
1739
- }
1740
- /**
1741
- * Checks if the passed Ray intersects with the mesh. A mesh triangle can be picked both from its front and back sides,
1742
- * irrespective of orientation.
1743
- * @param ray defines the ray to use. It should be in the mesh's LOCAL coordinate space.
1744
- * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
1745
- * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1746
- * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
1747
- * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
1748
- * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
1749
- * @returns the picking info
1750
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect
1751
- */
1752
- intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo = false, worldToUse, skipBoundingInfo = false) {
1753
- const pickingInfo = new PickingInfo();
1754
- const className = this.getClassName();
1755
- const intersectionThreshold = className === "InstancedLinesMesh" || className === "LinesMesh" || className === "GreasedLineMesh" ? this.intersectionThreshold : 0;
1756
- const boundingInfo = this.getBoundingInfo();
1757
- if (!this.subMeshes) {
1758
- return pickingInfo;
1759
- }
1760
- if (!skipBoundingInfo &&
1761
- (!ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold))) {
1762
- return pickingInfo;
1763
- }
1764
- if (onlyBoundingInfo) {
1765
- pickingInfo.hit = skipBoundingInfo ? false : true;
1766
- pickingInfo.pickedMesh = skipBoundingInfo ? null : this;
1767
- pickingInfo.distance = skipBoundingInfo ? 0 : Vector3.Distance(ray.origin, boundingInfo.boundingSphere.center);
1768
- pickingInfo.subMeshId = 0;
1769
- return pickingInfo;
1770
- }
1771
- if (!this._generatePointsArray()) {
1772
- return pickingInfo;
1773
- }
1774
- let intersectInfo = null;
1775
- const subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
1776
- const len = subMeshes.length;
1777
- // Check if all submeshes are using a material that don't allow picking (point/lines rendering)
1778
- // if no submesh can be picked that way, then fallback to BBox picking
1779
- let anySubmeshSupportIntersect = false;
1780
- for (let index = 0; index < len; index++) {
1781
- const subMesh = subMeshes.data[index];
1782
- const material = subMesh.getMaterial();
1783
- if (!material) {
1784
- continue;
1785
- }
1786
- if (material.fillMode == 7 ||
1787
- material.fillMode == 0 ||
1788
- material.fillMode == 1 ||
1789
- material.fillMode == 2 ||
1790
- material.fillMode == 4) {
1791
- anySubmeshSupportIntersect = true;
1792
- break;
1644
+ // Collisions
1645
+ /**
1646
+ * Gets or sets a boolean indicating that this mesh can be used in the collision engine
1647
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
1648
+ */
1649
+ get checkCollisions() {
1650
+ return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions;
1793
1651
  }
1794
- }
1795
- // no sub mesh support intersection, fallback to BBox that has already be done
1796
- if (!anySubmeshSupportIntersect) {
1797
- pickingInfo.hit = true;
1798
- pickingInfo.pickedMesh = this;
1799
- pickingInfo.distance = Vector3.Distance(ray.origin, boundingInfo.boundingSphere.center);
1800
- pickingInfo.subMeshId = -1;
1801
- return pickingInfo;
1802
- }
1803
- // at least 1 submesh supports intersection, keep going
1804
- for (let index = 0; index < len; index++) {
1805
- const subMesh = subMeshes.data[index];
1806
- // Bounding test
1807
- if (len > 1 && !skipBoundingInfo && !subMesh.canIntersects(ray)) {
1808
- continue;
1809
- }
1810
- const currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
1811
- if (currentIntersectInfo) {
1812
- if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
1813
- intersectInfo = currentIntersectInfo;
1814
- intersectInfo.subMeshId = subMesh._id;
1815
- intersectInfo._internalSubMeshId = index;
1816
- if (fastCheck) {
1817
- break;
1652
+ set checkCollisions(collisionEnabled) {
1653
+ this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = collisionEnabled;
1654
+ }
1655
+ /**
1656
+ * Gets Collider object used to compute collisions (not physics)
1657
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
1658
+ */
1659
+ get collider() {
1660
+ return this._internalAbstractMeshDataInfo._meshCollisionData._collider;
1661
+ }
1662
+ /**
1663
+ * Move the mesh using collision engine
1664
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
1665
+ * @param displacement defines the requested displacement vector
1666
+ * @param slideOnCollide If true, the mesh will slide along a collider's surface. If false, it will stop moving at the first collision. (true by default)
1667
+ * @returns the current mesh
1668
+ */
1669
+ moveWithCollisions(displacement, slideOnCollide = true) {
1670
+ const globalPosition = this.getAbsolutePosition();
1671
+ globalPosition.addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
1672
+ const coordinator = this.getScene().collisionCoordinator;
1673
+ if (!this._internalAbstractMeshDataInfo._meshCollisionData._collider) {
1674
+ this._internalAbstractMeshDataInfo._meshCollisionData._collider = coordinator.createCollider();
1675
+ }
1676
+ this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid;
1677
+ coordinator.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, displacement, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId, slideOnCollide);
1678
+ return this;
1679
+ }
1680
+ // Collisions
1681
+ /**
1682
+ * @internal
1683
+ */
1684
+ _collideForSubMesh(subMesh, transformMatrix, collider) {
1685
+ this._generatePointsArray();
1686
+ if (!this._positions) {
1687
+ return this;
1688
+ }
1689
+ // Transformation
1690
+ if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
1691
+ subMesh._lastColliderTransformMatrix = transformMatrix.clone();
1692
+ subMesh._lastColliderWorldVertices = [];
1693
+ subMesh._trianglePlanes = [];
1694
+ const start = subMesh.verticesStart;
1695
+ const end = subMesh.verticesStart + subMesh.verticesCount;
1696
+ for (let i = start; i < end; i++) {
1697
+ subMesh._lastColliderWorldVertices.push(Vector3.TransformCoordinates(this._positions[i], transformMatrix));
1818
1698
  }
1819
1699
  }
1700
+ // Collide
1701
+ collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial(), this, this._shouldConvertRHS(), subMesh.getMaterial()?.fillMode === 7);
1702
+ return this;
1820
1703
  }
1821
- }
1822
- if (intersectInfo) {
1823
- // Get picked point
1824
- const world = worldToUse ?? this.getWorldMatrix();
1825
- const worldOrigin = TmpVectors.Vector3[0];
1826
- const direction = TmpVectors.Vector3[1];
1827
- Vector3.TransformCoordinatesToRef(ray.origin, world, worldOrigin);
1828
- ray.direction.scaleToRef(intersectInfo.distance, direction);
1829
- const worldDirection = Vector3.TransformNormal(direction, world);
1830
- const pickedPoint = worldDirection.addInPlace(worldOrigin);
1831
- // Return result
1832
- pickingInfo.hit = true;
1833
- pickingInfo.distance = Vector3.Distance(worldOrigin, pickedPoint);
1834
- pickingInfo.pickedPoint = pickedPoint;
1835
- pickingInfo.pickedMesh = this;
1836
- pickingInfo.bu = intersectInfo.bu || 0;
1837
- pickingInfo.bv = intersectInfo.bv || 0;
1838
- pickingInfo.subMeshFaceId = intersectInfo.faceId;
1839
- pickingInfo.faceId = intersectInfo.faceId + subMeshes.data[intersectInfo._internalSubMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3);
1840
- pickingInfo.subMeshId = intersectInfo.subMeshId;
1841
- return pickingInfo;
1842
- }
1843
- return pickingInfo;
1844
- }
1845
- /**
1846
- * Clones the current mesh
1847
- * @param name defines the mesh name
1848
- * @param newParent defines the new mesh parent
1849
- * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
1850
- * @returns the new mesh
1851
- */
1852
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1853
- clone(name, newParent, doNotCloneChildren) {
1854
- return null;
1855
- }
1856
- /**
1857
- * Disposes all the submeshes of the current mesh
1858
- * @param immediate should dispose the effects immediately or not
1859
- * @returns the current mesh
1860
- */
1861
- releaseSubMeshes(immediate = false) {
1862
- if (this.subMeshes) {
1863
- while (this.subMeshes.length) {
1864
- this.subMeshes[0].dispose(immediate);
1704
+ /**
1705
+ * @internal
1706
+ */
1707
+ _processCollisionsForSubMeshes(collider, transformMatrix) {
1708
+ const subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
1709
+ const len = subMeshes.length;
1710
+ for (let index = 0; index < len; index++) {
1711
+ const subMesh = subMeshes.data[index];
1712
+ // Bounding test
1713
+ if (len > 1 && !subMesh._checkCollision(collider)) {
1714
+ continue;
1715
+ }
1716
+ this._collideForSubMesh(subMesh, transformMatrix, collider);
1717
+ }
1718
+ return this;
1865
1719
  }
1866
- }
1867
- else {
1868
- this.subMeshes = [];
1869
- }
1870
- return this;
1871
- }
1872
- /**
1873
- * Releases resources associated with this abstract mesh.
1874
- * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
1875
- * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
1876
- */
1877
- dispose(doNotRecurse, disposeMaterialAndTextures = false) {
1878
- let index;
1879
- const scene = this.getScene();
1880
- if (this.skeleton) {
1881
- this.skeleton = null;
1882
- }
1883
- // mesh map release.
1884
- if (this._scene.useMaterialMeshMap) {
1885
- // remove from material mesh map id needed
1886
- if (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap) {
1887
- this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = undefined;
1720
+ /** @internal */
1721
+ _shouldConvertRHS() {
1722
+ return false;
1888
1723
  }
1889
- }
1890
- // Smart Array Retainers.
1891
- scene.freeActiveMeshes();
1892
- scene.freeRenderingGroups();
1893
- if (scene.renderingManager.maintainStateBetweenFrames) {
1894
- scene.renderingManager.restoreDispachedFlags();
1895
- }
1896
- // Action manager
1897
- if (this.actionManager !== undefined && this.actionManager !== null) {
1898
- // If we are the only mesh using the action manager, dispose of the action manager too unless it has opted out from that behavior
1899
- if (this.actionManager.disposeWhenUnowned && !this._scene.meshes.some((m) => m !== this && m.actionManager === this.actionManager)) {
1900
- this.actionManager.dispose();
1724
+ /**
1725
+ * @internal
1726
+ */
1727
+ _checkCollision(collider) {
1728
+ // Bounding box test
1729
+ if (!this.getBoundingInfo()._checkCollision(collider)) {
1730
+ return this;
1731
+ }
1732
+ // Transformation matrix
1733
+ const collisionsScalingMatrix = TmpVectors.Matrix[0];
1734
+ const collisionsTransformMatrix = TmpVectors.Matrix[1];
1735
+ Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
1736
+ this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
1737
+ this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
1738
+ return this;
1901
1739
  }
1902
- this.actionManager = null;
1903
- }
1904
- // Skeleton
1905
- this._internalAbstractMeshDataInfo._skeleton = null;
1906
- if (this._transformMatrixTexture) {
1907
- this._transformMatrixTexture.dispose();
1908
- this._transformMatrixTexture = null;
1909
- }
1910
- // Intersections in progress
1911
- for (index = 0; index < this._intersectionsInProgress.length; index++) {
1912
- const other = this._intersectionsInProgress[index];
1913
- const pos = other._intersectionsInProgress.indexOf(this);
1914
- other._intersectionsInProgress.splice(pos, 1);
1915
- }
1916
- this._intersectionsInProgress.length = 0;
1917
- // Lights
1918
- const lights = scene.lights;
1919
- for (const light of lights) {
1920
- let meshIndex = light.includedOnlyMeshes.indexOf(this);
1921
- if (meshIndex !== -1) {
1922
- light.includedOnlyMeshes.splice(meshIndex, 1);
1923
- }
1924
- meshIndex = light.excludedMeshes.indexOf(this);
1925
- if (meshIndex !== -1) {
1926
- light.excludedMeshes.splice(meshIndex, 1);
1927
- }
1928
- // Shadow generators
1929
- const generators = light.getShadowGenerators();
1930
- if (generators) {
1931
- const iterator = generators.values();
1932
- for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
1933
- const generator = key.value;
1934
- const shadowMap = generator.getShadowMap();
1935
- if (shadowMap && shadowMap.renderList) {
1936
- meshIndex = shadowMap.renderList.indexOf(this);
1937
- if (meshIndex !== -1) {
1938
- shadowMap.renderList.splice(meshIndex, 1);
1740
+ // Picking
1741
+ /** @internal */
1742
+ _generatePointsArray() {
1743
+ return false;
1744
+ }
1745
+ /**
1746
+ * Checks if the passed Ray intersects with the mesh. A mesh triangle can be picked both from its front and back sides,
1747
+ * irrespective of orientation.
1748
+ * @param ray defines the ray to use. It should be in the mesh's LOCAL coordinate space.
1749
+ * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
1750
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1751
+ * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
1752
+ * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
1753
+ * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
1754
+ * @returns the picking info
1755
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect
1756
+ */
1757
+ intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo = false, worldToUse, skipBoundingInfo = false) {
1758
+ const pickingInfo = new PickingInfo();
1759
+ const className = this.getClassName();
1760
+ const intersectionThreshold = className === "InstancedLinesMesh" || className === "LinesMesh" || className === "GreasedLineMesh" ? this.intersectionThreshold : 0;
1761
+ const boundingInfo = this.getBoundingInfo();
1762
+ if (!this.subMeshes) {
1763
+ return pickingInfo;
1764
+ }
1765
+ if (!skipBoundingInfo &&
1766
+ (!ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold))) {
1767
+ return pickingInfo;
1768
+ }
1769
+ if (onlyBoundingInfo) {
1770
+ pickingInfo.hit = skipBoundingInfo ? false : true;
1771
+ pickingInfo.pickedMesh = skipBoundingInfo ? null : this;
1772
+ pickingInfo.distance = skipBoundingInfo ? 0 : Vector3.Distance(ray.origin, boundingInfo.boundingSphere.center);
1773
+ pickingInfo.subMeshId = 0;
1774
+ return pickingInfo;
1775
+ }
1776
+ if (!this._generatePointsArray()) {
1777
+ return pickingInfo;
1778
+ }
1779
+ let intersectInfo = null;
1780
+ const subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
1781
+ const len = subMeshes.length;
1782
+ // Check if all submeshes are using a material that don't allow picking (point/lines rendering)
1783
+ // if no submesh can be picked that way, then fallback to BBox picking
1784
+ let anySubmeshSupportIntersect = false;
1785
+ for (let index = 0; index < len; index++) {
1786
+ const subMesh = subMeshes.data[index];
1787
+ const material = subMesh.getMaterial();
1788
+ if (!material) {
1789
+ continue;
1790
+ }
1791
+ if (material.fillMode == 7 ||
1792
+ material.fillMode == 0 ||
1793
+ material.fillMode == 1 ||
1794
+ material.fillMode == 2 ||
1795
+ material.fillMode == 4) {
1796
+ anySubmeshSupportIntersect = true;
1797
+ break;
1798
+ }
1799
+ }
1800
+ // no sub mesh support intersection, fallback to BBox that has already be done
1801
+ if (!anySubmeshSupportIntersect) {
1802
+ pickingInfo.hit = true;
1803
+ pickingInfo.pickedMesh = this;
1804
+ pickingInfo.distance = Vector3.Distance(ray.origin, boundingInfo.boundingSphere.center);
1805
+ pickingInfo.subMeshId = -1;
1806
+ return pickingInfo;
1807
+ }
1808
+ // at least 1 submesh supports intersection, keep going
1809
+ for (let index = 0; index < len; index++) {
1810
+ const subMesh = subMeshes.data[index];
1811
+ // Bounding test
1812
+ if (len > 1 && !skipBoundingInfo && !subMesh.canIntersects(ray)) {
1813
+ continue;
1814
+ }
1815
+ const currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
1816
+ if (currentIntersectInfo) {
1817
+ if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
1818
+ intersectInfo = currentIntersectInfo;
1819
+ intersectInfo.subMeshId = subMesh._id;
1820
+ intersectInfo._internalSubMeshId = index;
1821
+ if (fastCheck) {
1822
+ break;
1823
+ }
1939
1824
  }
1940
1825
  }
1941
1826
  }
1827
+ if (intersectInfo) {
1828
+ // Get picked point
1829
+ const world = worldToUse ?? this.getWorldMatrix();
1830
+ const worldOrigin = TmpVectors.Vector3[0];
1831
+ const direction = TmpVectors.Vector3[1];
1832
+ Vector3.TransformCoordinatesToRef(ray.origin, world, worldOrigin);
1833
+ ray.direction.scaleToRef(intersectInfo.distance, direction);
1834
+ const worldDirection = Vector3.TransformNormal(direction, world);
1835
+ const pickedPoint = worldDirection.addInPlace(worldOrigin);
1836
+ // Return result
1837
+ pickingInfo.hit = true;
1838
+ pickingInfo.distance = Vector3.Distance(worldOrigin, pickedPoint);
1839
+ pickingInfo.pickedPoint = pickedPoint;
1840
+ pickingInfo.pickedMesh = this;
1841
+ pickingInfo.bu = intersectInfo.bu || 0;
1842
+ pickingInfo.bv = intersectInfo.bv || 0;
1843
+ pickingInfo.subMeshFaceId = intersectInfo.faceId;
1844
+ pickingInfo.faceId = intersectInfo.faceId + subMeshes.data[intersectInfo._internalSubMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3);
1845
+ pickingInfo.subMeshId = intersectInfo.subMeshId;
1846
+ return pickingInfo;
1847
+ }
1848
+ return pickingInfo;
1942
1849
  }
1943
- }
1944
- // SubMeshes
1945
- if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
1946
- this.releaseSubMeshes(true);
1947
- }
1948
- // Query
1949
- const engine = scene.getEngine();
1950
- if (this._occlusionQuery !== null) {
1951
- this.isOcclusionQueryInProgress = false;
1952
- engine.deleteQuery(this._occlusionQuery);
1953
- this._occlusionQuery = null;
1954
- }
1955
- // Engine
1956
- engine.wipeCaches();
1957
- // Remove from scene
1958
- scene.removeMesh(this);
1959
- if (this._parentContainer) {
1960
- const index = this._parentContainer.meshes.indexOf(this);
1961
- if (index > -1) {
1962
- this._parentContainer.meshes.splice(index, 1);
1963
- }
1964
- this._parentContainer = null;
1965
- }
1966
- if (disposeMaterialAndTextures) {
1967
- if (this.material) {
1968
- if (this.material.getClassName() === "MultiMaterial") {
1969
- this.material.dispose(false, true, true);
1850
+ /**
1851
+ * Clones the current mesh
1852
+ * @param name defines the mesh name
1853
+ * @param newParent defines the new mesh parent
1854
+ * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
1855
+ * @returns the new mesh
1856
+ */
1857
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1858
+ clone(name, newParent, doNotCloneChildren) {
1859
+ return null;
1860
+ }
1861
+ /**
1862
+ * Disposes all the submeshes of the current mesh
1863
+ * @param immediate should dispose the effects immediately or not
1864
+ * @returns the current mesh
1865
+ */
1866
+ releaseSubMeshes(immediate = false) {
1867
+ if (this.subMeshes) {
1868
+ while (this.subMeshes.length) {
1869
+ this.subMeshes[0].dispose(immediate);
1870
+ }
1970
1871
  }
1971
1872
  else {
1972
- this.material.dispose(false, true);
1873
+ this.subMeshes = [];
1973
1874
  }
1875
+ return this;
1974
1876
  }
1975
- }
1976
- if (!doNotRecurse) {
1977
- // Particles
1978
- for (index = 0; index < scene.particleSystems.length; index++) {
1979
- if (scene.particleSystems[index].emitter === this) {
1980
- scene.particleSystems[index].dispose();
1981
- index--;
1877
+ /**
1878
+ * Releases resources associated with this abstract mesh.
1879
+ * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
1880
+ * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
1881
+ */
1882
+ dispose(doNotRecurse, disposeMaterialAndTextures = false) {
1883
+ let index;
1884
+ const scene = this.getScene();
1885
+ if (this.skeleton) {
1886
+ this.skeleton = null;
1887
+ }
1888
+ // mesh map release.
1889
+ if (this._scene.useMaterialMeshMap) {
1890
+ // remove from material mesh map id needed
1891
+ if (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap) {
1892
+ this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = undefined;
1893
+ }
1894
+ }
1895
+ // Smart Array Retainers.
1896
+ scene.freeActiveMeshes();
1897
+ scene.freeRenderingGroups();
1898
+ if (scene.renderingManager.maintainStateBetweenFrames) {
1899
+ scene.renderingManager.restoreDispachedFlags();
1900
+ }
1901
+ // Action manager
1902
+ if (this.actionManager !== undefined && this.actionManager !== null) {
1903
+ // If we are the only mesh using the action manager, dispose of the action manager too unless it has opted out from that behavior
1904
+ if (this.actionManager.disposeWhenUnowned && !this._scene.meshes.some((m) => m !== this && m.actionManager === this.actionManager)) {
1905
+ this.actionManager.dispose();
1906
+ }
1907
+ this.actionManager = null;
1908
+ }
1909
+ // Skeleton
1910
+ this._internalAbstractMeshDataInfo._skeleton = null;
1911
+ if (this._transformMatrixTexture) {
1912
+ this._transformMatrixTexture.dispose();
1913
+ this._transformMatrixTexture = null;
1914
+ }
1915
+ // Intersections in progress
1916
+ for (index = 0; index < this._intersectionsInProgress.length; index++) {
1917
+ const other = this._intersectionsInProgress[index];
1918
+ const pos = other._intersectionsInProgress.indexOf(this);
1919
+ other._intersectionsInProgress.splice(pos, 1);
1920
+ }
1921
+ this._intersectionsInProgress.length = 0;
1922
+ // Lights
1923
+ const lights = scene.lights;
1924
+ for (const light of lights) {
1925
+ let meshIndex = light.includedOnlyMeshes.indexOf(this);
1926
+ if (meshIndex !== -1) {
1927
+ light.includedOnlyMeshes.splice(meshIndex, 1);
1928
+ }
1929
+ meshIndex = light.excludedMeshes.indexOf(this);
1930
+ if (meshIndex !== -1) {
1931
+ light.excludedMeshes.splice(meshIndex, 1);
1932
+ }
1933
+ // Shadow generators
1934
+ const generators = light.getShadowGenerators();
1935
+ if (generators) {
1936
+ const iterator = generators.values();
1937
+ for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
1938
+ const generator = key.value;
1939
+ const shadowMap = generator.getShadowMap();
1940
+ if (shadowMap && shadowMap.renderList) {
1941
+ meshIndex = shadowMap.renderList.indexOf(this);
1942
+ if (meshIndex !== -1) {
1943
+ shadowMap.renderList.splice(meshIndex, 1);
1944
+ }
1945
+ }
1946
+ }
1947
+ }
1948
+ }
1949
+ // SubMeshes
1950
+ if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
1951
+ this.releaseSubMeshes(true);
1952
+ }
1953
+ // Query
1954
+ const engine = scene.getEngine();
1955
+ if (this._occlusionQuery !== null) {
1956
+ this.isOcclusionQueryInProgress = false;
1957
+ engine.deleteQuery(this._occlusionQuery);
1958
+ this._occlusionQuery = null;
1959
+ }
1960
+ // Engine
1961
+ engine.wipeCaches();
1962
+ // Remove from scene
1963
+ scene.removeMesh(this);
1964
+ if (this._parentContainer) {
1965
+ const index = this._parentContainer.meshes.indexOf(this);
1966
+ if (index > -1) {
1967
+ this._parentContainer.meshes.splice(index, 1);
1968
+ }
1969
+ this._parentContainer = null;
1970
+ }
1971
+ if (disposeMaterialAndTextures) {
1972
+ if (this.material) {
1973
+ if (this.material.getClassName() === "MultiMaterial") {
1974
+ this.material.dispose(false, true, true);
1975
+ }
1976
+ else {
1977
+ this.material.dispose(false, true);
1978
+ }
1979
+ }
1980
+ }
1981
+ if (!doNotRecurse) {
1982
+ // Particles
1983
+ for (index = 0; index < scene.particleSystems.length; index++) {
1984
+ if (scene.particleSystems[index].emitter === this) {
1985
+ scene.particleSystems[index].dispose();
1986
+ index--;
1987
+ }
1988
+ }
1989
+ }
1990
+ // facet data
1991
+ if (this._internalAbstractMeshDataInfo._facetData.facetDataEnabled) {
1992
+ this.disableFacetData();
1982
1993
  }
1994
+ this._uniformBuffer.dispose();
1995
+ this.onAfterWorldMatrixUpdateObservable.clear();
1996
+ this.onCollideObservable.clear();
1997
+ this.onCollisionPositionChangeObservable.clear();
1998
+ this.onRebuildObservable.clear();
1999
+ super.dispose(doNotRecurse, disposeMaterialAndTextures);
1983
2000
  }
1984
- }
1985
- // facet data
1986
- if (this._internalAbstractMeshDataInfo._facetData.facetDataEnabled) {
1987
- this.disableFacetData();
1988
- }
1989
- this._uniformBuffer.dispose();
1990
- this.onAfterWorldMatrixUpdateObservable.clear();
1991
- this.onCollideObservable.clear();
1992
- this.onCollisionPositionChangeObservable.clear();
1993
- this.onRebuildObservable.clear();
1994
- super.dispose(doNotRecurse, disposeMaterialAndTextures);
1995
- }
1996
- // Facet data
1997
- /** @internal */
1998
- _initFacetData() {
1999
- const data = this._internalAbstractMeshDataInfo._facetData;
2000
- if (!data.facetNormals) {
2001
- data.facetNormals = [];
2002
- }
2003
- if (!data.facetPositions) {
2004
- data.facetPositions = [];
2005
- }
2006
- if (!data.facetPartitioning) {
2007
- data.facetPartitioning = new Array();
2008
- }
2009
- data.facetNb = (this.getIndices().length / 3) | 0;
2010
- data.partitioningSubdivisions = data.partitioningSubdivisions ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
2011
- data.partitioningBBoxRatio = data.partitioningBBoxRatio ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
2012
- for (let f = 0; f < data.facetNb; f++) {
2013
- data.facetNormals[f] = Vector3.Zero();
2014
- data.facetPositions[f] = Vector3.Zero();
2015
- }
2016
- data.facetDataEnabled = true;
2017
- return this;
2018
- }
2019
- /**
2020
- * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
2021
- * This method can be called within the render loop.
2022
- * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
2023
- * @returns the current mesh
2024
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2025
- */
2026
- updateFacetData() {
2027
- const data = this._internalAbstractMeshDataInfo._facetData;
2028
- if (!data.facetDataEnabled) {
2029
- this._initFacetData();
2030
- }
2031
- const positions = this.getVerticesData(VertexBuffer.PositionKind);
2032
- const indices = this.getIndices();
2033
- const normals = this.getVerticesData(VertexBuffer.NormalKind)?.slice();
2034
- const bInfo = this.getBoundingInfo();
2035
- if (data.facetDepthSort && !data.facetDepthSortEnabled) {
2036
- // init arrays, matrix and sort function on first call
2037
- data.facetDepthSortEnabled = true;
2038
- if (indices instanceof Uint16Array) {
2039
- data.depthSortedIndices = new Uint16Array(indices);
2040
- }
2041
- else if (indices instanceof Uint32Array) {
2042
- data.depthSortedIndices = new Uint32Array(indices);
2043
- }
2044
- else {
2045
- let needs32bits = false;
2046
- for (let i = 0; i < indices.length; i++) {
2047
- if (indices[i] > 65535) {
2048
- needs32bits = true;
2049
- break;
2001
+ // Facet data
2002
+ /** @internal */
2003
+ _initFacetData() {
2004
+ const data = this._internalAbstractMeshDataInfo._facetData;
2005
+ if (!data.facetNormals) {
2006
+ data.facetNormals = [];
2007
+ }
2008
+ if (!data.facetPositions) {
2009
+ data.facetPositions = [];
2010
+ }
2011
+ if (!data.facetPartitioning) {
2012
+ data.facetPartitioning = new Array();
2013
+ }
2014
+ data.facetNb = (this.getIndices().length / 3) | 0;
2015
+ data.partitioningSubdivisions = data.partitioningSubdivisions ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
2016
+ data.partitioningBBoxRatio = data.partitioningBBoxRatio ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
2017
+ for (let f = 0; f < data.facetNb; f++) {
2018
+ data.facetNormals[f] = Vector3.Zero();
2019
+ data.facetPositions[f] = Vector3.Zero();
2020
+ }
2021
+ data.facetDataEnabled = true;
2022
+ return this;
2023
+ }
2024
+ /**
2025
+ * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
2026
+ * This method can be called within the render loop.
2027
+ * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
2028
+ * @returns the current mesh
2029
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2030
+ */
2031
+ updateFacetData() {
2032
+ const data = this._internalAbstractMeshDataInfo._facetData;
2033
+ if (!data.facetDataEnabled) {
2034
+ this._initFacetData();
2035
+ }
2036
+ const positions = this.getVerticesData(VertexBuffer.PositionKind);
2037
+ const indices = this.getIndices();
2038
+ const normals = this.getVerticesData(VertexBuffer.NormalKind)?.slice();
2039
+ const bInfo = this.getBoundingInfo();
2040
+ if (data.facetDepthSort && !data.facetDepthSortEnabled) {
2041
+ // init arrays, matrix and sort function on first call
2042
+ data.facetDepthSortEnabled = true;
2043
+ if (indices instanceof Uint16Array) {
2044
+ data.depthSortedIndices = new Uint16Array(indices);
2050
2045
  }
2046
+ else if (indices instanceof Uint32Array) {
2047
+ data.depthSortedIndices = new Uint32Array(indices);
2048
+ }
2049
+ else {
2050
+ let needs32bits = false;
2051
+ for (let i = 0; i < indices.length; i++) {
2052
+ if (indices[i] > 65535) {
2053
+ needs32bits = true;
2054
+ break;
2055
+ }
2056
+ }
2057
+ if (needs32bits) {
2058
+ data.depthSortedIndices = new Uint32Array(indices);
2059
+ }
2060
+ else {
2061
+ data.depthSortedIndices = new Uint16Array(indices);
2062
+ }
2063
+ }
2064
+ data.facetDepthSortFunction = function (f1, f2) {
2065
+ return f2.sqDistance - f1.sqDistance;
2066
+ };
2067
+ if (!data.facetDepthSortFrom) {
2068
+ const camera = this.getScene().activeCamera;
2069
+ data.facetDepthSortFrom = camera ? camera.position : Vector3.Zero();
2070
+ }
2071
+ data.depthSortedFacets = [];
2072
+ for (let f = 0; f < data.facetNb; f++) {
2073
+ const depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
2074
+ data.depthSortedFacets.push(depthSortedFacet);
2075
+ }
2076
+ data.invertedMatrix = Matrix.Identity();
2077
+ data.facetDepthSortOrigin = Vector3.Zero();
2051
2078
  }
2052
- if (needs32bits) {
2053
- data.depthSortedIndices = new Uint32Array(indices);
2079
+ data.bbSize.x = bInfo.maximum.x - bInfo.minimum.x > Epsilon ? bInfo.maximum.x - bInfo.minimum.x : Epsilon;
2080
+ data.bbSize.y = bInfo.maximum.y - bInfo.minimum.y > Epsilon ? bInfo.maximum.y - bInfo.minimum.y : Epsilon;
2081
+ data.bbSize.z = bInfo.maximum.z - bInfo.minimum.z > Epsilon ? bInfo.maximum.z - bInfo.minimum.z : Epsilon;
2082
+ let bbSizeMax = data.bbSize.x > data.bbSize.y ? data.bbSize.x : data.bbSize.y;
2083
+ bbSizeMax = bbSizeMax > data.bbSize.z ? bbSizeMax : data.bbSize.z;
2084
+ data.subDiv.max = data.partitioningSubdivisions;
2085
+ data.subDiv.X = Math.floor((data.subDiv.max * data.bbSize.x) / bbSizeMax); // adjust the number of subdivisions per axis
2086
+ data.subDiv.Y = Math.floor((data.subDiv.max * data.bbSize.y) / bbSizeMax); // according to each bbox size per axis
2087
+ data.subDiv.Z = Math.floor((data.subDiv.max * data.bbSize.z) / bbSizeMax);
2088
+ data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
2089
+ data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
2090
+ data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
2091
+ // set the parameters for ComputeNormals()
2092
+ data.facetParameters.facetNormals = this.getFacetLocalNormals();
2093
+ data.facetParameters.facetPositions = this.getFacetLocalPositions();
2094
+ data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
2095
+ data.facetParameters.bInfo = bInfo;
2096
+ data.facetParameters.bbSize = data.bbSize;
2097
+ data.facetParameters.subDiv = data.subDiv;
2098
+ data.facetParameters.ratio = this.partitioningBBoxRatio;
2099
+ data.facetParameters.depthSort = data.facetDepthSort;
2100
+ if (data.facetDepthSort && data.facetDepthSortEnabled) {
2101
+ this.computeWorldMatrix(true);
2102
+ this._worldMatrix.invertToRef(data.invertedMatrix);
2103
+ Vector3.TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
2104
+ data.facetParameters.distanceTo = data.facetDepthSortOrigin;
2054
2105
  }
2055
- else {
2056
- data.depthSortedIndices = new Uint16Array(indices);
2106
+ data.facetParameters.depthSortedFacets = data.depthSortedFacets;
2107
+ if (normals) {
2108
+ VertexData.ComputeNormals(positions, indices, normals, data.facetParameters);
2057
2109
  }
2110
+ if (data.facetDepthSort && data.facetDepthSortEnabled) {
2111
+ data.depthSortedFacets.sort(data.facetDepthSortFunction);
2112
+ const l = (data.depthSortedIndices.length / 3) | 0;
2113
+ for (let f = 0; f < l; f++) {
2114
+ const sind = data.depthSortedFacets[f].ind;
2115
+ data.depthSortedIndices[f * 3] = indices[sind];
2116
+ data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
2117
+ data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
2118
+ }
2119
+ this.updateIndices(data.depthSortedIndices, undefined, true);
2120
+ }
2121
+ return this;
2058
2122
  }
2059
- data.facetDepthSortFunction = function (f1, f2) {
2060
- return f2.sqDistance - f1.sqDistance;
2061
- };
2062
- if (!data.facetDepthSortFrom) {
2063
- const camera = this.getScene().activeCamera;
2064
- data.facetDepthSortFrom = camera ? camera.position : Vector3.Zero();
2123
+ /**
2124
+ * Returns the facetLocalNormals array.
2125
+ * The normals are expressed in the mesh local spac
2126
+ * @returns an array of Vector3
2127
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2128
+ */
2129
+ getFacetLocalNormals() {
2130
+ const facetData = this._internalAbstractMeshDataInfo._facetData;
2131
+ if (!facetData.facetNormals) {
2132
+ this.updateFacetData();
2133
+ }
2134
+ return facetData.facetNormals;
2065
2135
  }
2066
- data.depthSortedFacets = [];
2067
- for (let f = 0; f < data.facetNb; f++) {
2068
- const depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
2069
- data.depthSortedFacets.push(depthSortedFacet);
2136
+ /**
2137
+ * Returns the facetLocalPositions array.
2138
+ * The facet positions are expressed in the mesh local space
2139
+ * @returns an array of Vector3
2140
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2141
+ */
2142
+ getFacetLocalPositions() {
2143
+ const facetData = this._internalAbstractMeshDataInfo._facetData;
2144
+ if (!facetData.facetPositions) {
2145
+ this.updateFacetData();
2146
+ }
2147
+ return facetData.facetPositions;
2070
2148
  }
2071
- data.invertedMatrix = Matrix.Identity();
2072
- data.facetDepthSortOrigin = Vector3.Zero();
2073
- }
2074
- data.bbSize.x = bInfo.maximum.x - bInfo.minimum.x > Epsilon ? bInfo.maximum.x - bInfo.minimum.x : Epsilon;
2075
- data.bbSize.y = bInfo.maximum.y - bInfo.minimum.y > Epsilon ? bInfo.maximum.y - bInfo.minimum.y : Epsilon;
2076
- data.bbSize.z = bInfo.maximum.z - bInfo.minimum.z > Epsilon ? bInfo.maximum.z - bInfo.minimum.z : Epsilon;
2077
- let bbSizeMax = data.bbSize.x > data.bbSize.y ? data.bbSize.x : data.bbSize.y;
2078
- bbSizeMax = bbSizeMax > data.bbSize.z ? bbSizeMax : data.bbSize.z;
2079
- data.subDiv.max = data.partitioningSubdivisions;
2080
- data.subDiv.X = Math.floor((data.subDiv.max * data.bbSize.x) / bbSizeMax); // adjust the number of subdivisions per axis
2081
- data.subDiv.Y = Math.floor((data.subDiv.max * data.bbSize.y) / bbSizeMax); // according to each bbox size per axis
2082
- data.subDiv.Z = Math.floor((data.subDiv.max * data.bbSize.z) / bbSizeMax);
2083
- data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
2084
- data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
2085
- data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
2086
- // set the parameters for ComputeNormals()
2087
- data.facetParameters.facetNormals = this.getFacetLocalNormals();
2088
- data.facetParameters.facetPositions = this.getFacetLocalPositions();
2089
- data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
2090
- data.facetParameters.bInfo = bInfo;
2091
- data.facetParameters.bbSize = data.bbSize;
2092
- data.facetParameters.subDiv = data.subDiv;
2093
- data.facetParameters.ratio = this.partitioningBBoxRatio;
2094
- data.facetParameters.depthSort = data.facetDepthSort;
2095
- if (data.facetDepthSort && data.facetDepthSortEnabled) {
2096
- this.computeWorldMatrix(true);
2097
- this._worldMatrix.invertToRef(data.invertedMatrix);
2098
- Vector3.TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
2099
- data.facetParameters.distanceTo = data.facetDepthSortOrigin;
2100
- }
2101
- data.facetParameters.depthSortedFacets = data.depthSortedFacets;
2102
- if (normals) {
2103
- VertexData.ComputeNormals(positions, indices, normals, data.facetParameters);
2104
- }
2105
- if (data.facetDepthSort && data.facetDepthSortEnabled) {
2106
- data.depthSortedFacets.sort(data.facetDepthSortFunction);
2107
- const l = (data.depthSortedIndices.length / 3) | 0;
2108
- for (let f = 0; f < l; f++) {
2109
- const sind = data.depthSortedFacets[f].ind;
2110
- data.depthSortedIndices[f * 3] = indices[sind];
2111
- data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
2112
- data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
2113
- }
2114
- this.updateIndices(data.depthSortedIndices, undefined, true);
2115
- }
2116
- return this;
2117
- }
2118
- /**
2119
- * Returns the facetLocalNormals array.
2120
- * The normals are expressed in the mesh local spac
2121
- * @returns an array of Vector3
2122
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2123
- */
2124
- getFacetLocalNormals() {
2125
- const facetData = this._internalAbstractMeshDataInfo._facetData;
2126
- if (!facetData.facetNormals) {
2127
- this.updateFacetData();
2128
- }
2129
- return facetData.facetNormals;
2130
- }
2131
- /**
2132
- * Returns the facetLocalPositions array.
2133
- * The facet positions are expressed in the mesh local space
2134
- * @returns an array of Vector3
2135
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2136
- */
2137
- getFacetLocalPositions() {
2138
- const facetData = this._internalAbstractMeshDataInfo._facetData;
2139
- if (!facetData.facetPositions) {
2140
- this.updateFacetData();
2141
- }
2142
- return facetData.facetPositions;
2143
- }
2144
- /**
2145
- * Returns the facetLocalPartitioning array
2146
- * @returns an array of array of numbers
2147
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2148
- */
2149
- getFacetLocalPartitioning() {
2150
- const facetData = this._internalAbstractMeshDataInfo._facetData;
2151
- if (!facetData.facetPartitioning) {
2152
- this.updateFacetData();
2153
- }
2154
- return facetData.facetPartitioning;
2155
- }
2156
- /**
2157
- * Returns the i-th facet position in the world system.
2158
- * This method allocates a new Vector3 per call
2159
- * @param i defines the facet index
2160
- * @returns a new Vector3
2161
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2162
- */
2163
- getFacetPosition(i) {
2164
- const pos = Vector3.Zero();
2165
- this.getFacetPositionToRef(i, pos);
2166
- return pos;
2167
- }
2168
- /**
2169
- * Sets the reference Vector3 with the i-th facet position in the world system
2170
- * @param i defines the facet index
2171
- * @param ref defines the target vector
2172
- * @returns the current mesh
2173
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2174
- */
2175
- getFacetPositionToRef(i, ref) {
2176
- const localPos = this.getFacetLocalPositions()[i];
2177
- const world = this.getWorldMatrix();
2178
- Vector3.TransformCoordinatesToRef(localPos, world, ref);
2179
- return this;
2180
- }
2181
- /**
2182
- * Returns the i-th facet normal in the world system.
2183
- * This method allocates a new Vector3 per call
2184
- * @param i defines the facet index
2185
- * @returns a new Vector3
2186
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2187
- */
2188
- getFacetNormal(i) {
2189
- const norm = Vector3.Zero();
2190
- this.getFacetNormalToRef(i, norm);
2191
- return norm;
2192
- }
2193
- /**
2194
- * Sets the reference Vector3 with the i-th facet normal in the world system
2195
- * @param i defines the facet index
2196
- * @param ref defines the target vector
2197
- * @returns the current mesh
2198
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2199
- */
2200
- getFacetNormalToRef(i, ref) {
2201
- const localNorm = this.getFacetLocalNormals()[i];
2202
- Vector3.TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
2203
- return this;
2204
- }
2205
- /**
2206
- * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
2207
- * @param x defines x coordinate
2208
- * @param y defines y coordinate
2209
- * @param z defines z coordinate
2210
- * @returns the array of facet indexes
2211
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2212
- */
2213
- getFacetsAtLocalCoordinates(x, y, z) {
2214
- const bInfo = this.getBoundingInfo();
2215
- const data = this._internalAbstractMeshDataInfo._facetData;
2216
- const ox = Math.floor(((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio) / data.bbSize.x);
2217
- const oy = Math.floor(((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio) / data.bbSize.y);
2218
- const oz = Math.floor(((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio) / data.bbSize.z);
2219
- if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
2220
- return null;
2221
- }
2222
- return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
2223
- }
2224
- /**
2225
- * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
2226
- * @param x defines x coordinate
2227
- * @param y defines y coordinate
2228
- * @param z defines z coordinate
2229
- * @param projected sets as the (x,y,z) world projection on the facet
2230
- * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
2231
- * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
2232
- * @returns the face index if found (or null instead)
2233
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2234
- */
2235
- getClosestFacetAtCoordinates(x, y, z, projected, checkFace = false, facing = true) {
2236
- const world = this.getWorldMatrix();
2237
- const invMat = TmpVectors.Matrix[5];
2238
- world.invertToRef(invMat);
2239
- const invVect = TmpVectors.Vector3[8];
2240
- Vector3.TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
2241
- const closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
2242
- if (projected) {
2243
- // transform the local computed projected vector to world coordinates
2244
- Vector3.TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
2245
- }
2246
- return closest;
2247
- }
2248
- /**
2249
- * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
2250
- * @param x defines x coordinate
2251
- * @param y defines y coordinate
2252
- * @param z defines z coordinate
2253
- * @param projected sets as the (x,y,z) local projection on the facet
2254
- * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
2255
- * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
2256
- * @returns the face index if found (or null instead)
2257
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2258
- */
2259
- getClosestFacetAtLocalCoordinates(x, y, z, projected, checkFace = false, facing = true) {
2260
- let closest = null;
2261
- let tmpx;
2262
- let tmpy;
2263
- let tmpz;
2264
- let d; // tmp dot facet normal * facet position
2265
- let t0;
2266
- let projx;
2267
- let projy;
2268
- let projz;
2269
- // Get all the facets in the same partitioning block than (x, y, z)
2270
- const facetPositions = this.getFacetLocalPositions();
2271
- const facetNormals = this.getFacetLocalNormals();
2272
- const facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
2273
- if (!facetsInBlock) {
2274
- return null;
2275
- }
2276
- // Get the closest facet to (x, y, z)
2277
- let shortest = Number.MAX_VALUE; // init distance vars
2278
- let tmpDistance;
2279
- let fib; // current facet in the block
2280
- let norm; // current facet normal
2281
- let p0; // current facet barycenter position
2282
- // loop on all the facets in the current partitioning block
2283
- for (let idx = 0; idx < facetsInBlock.length; idx++) {
2284
- fib = facetsInBlock[idx];
2285
- norm = facetNormals[fib];
2286
- p0 = facetPositions[fib];
2287
- d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
2288
- if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
2289
- // compute (x,y,z) projection on the facet = (projx, projy, projz)
2290
- d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
2291
- t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
2292
- projx = x + norm.x * t0;
2293
- projy = y + norm.y * t0;
2294
- projz = z + norm.z * t0;
2295
- tmpx = projx - x;
2296
- tmpy = projy - y;
2297
- tmpz = projz - z;
2298
- tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
2299
- if (tmpDistance < shortest) {
2300
- // just keep the closest facet to (x, y, z)
2301
- shortest = tmpDistance;
2302
- closest = fib;
2303
- if (projected) {
2304
- projected.x = projx;
2305
- projected.y = projy;
2306
- projected.z = projz;
2149
+ /**
2150
+ * Returns the facetLocalPartitioning array
2151
+ * @returns an array of array of numbers
2152
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2153
+ */
2154
+ getFacetLocalPartitioning() {
2155
+ const facetData = this._internalAbstractMeshDataInfo._facetData;
2156
+ if (!facetData.facetPartitioning) {
2157
+ this.updateFacetData();
2158
+ }
2159
+ return facetData.facetPartitioning;
2160
+ }
2161
+ /**
2162
+ * Returns the i-th facet position in the world system.
2163
+ * This method allocates a new Vector3 per call
2164
+ * @param i defines the facet index
2165
+ * @returns a new Vector3
2166
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2167
+ */
2168
+ getFacetPosition(i) {
2169
+ const pos = Vector3.Zero();
2170
+ this.getFacetPositionToRef(i, pos);
2171
+ return pos;
2172
+ }
2173
+ /**
2174
+ * Sets the reference Vector3 with the i-th facet position in the world system
2175
+ * @param i defines the facet index
2176
+ * @param ref defines the target vector
2177
+ * @returns the current mesh
2178
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2179
+ */
2180
+ getFacetPositionToRef(i, ref) {
2181
+ const localPos = this.getFacetLocalPositions()[i];
2182
+ const world = this.getWorldMatrix();
2183
+ Vector3.TransformCoordinatesToRef(localPos, world, ref);
2184
+ return this;
2185
+ }
2186
+ /**
2187
+ * Returns the i-th facet normal in the world system.
2188
+ * This method allocates a new Vector3 per call
2189
+ * @param i defines the facet index
2190
+ * @returns a new Vector3
2191
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2192
+ */
2193
+ getFacetNormal(i) {
2194
+ const norm = Vector3.Zero();
2195
+ this.getFacetNormalToRef(i, norm);
2196
+ return norm;
2197
+ }
2198
+ /**
2199
+ * Sets the reference Vector3 with the i-th facet normal in the world system
2200
+ * @param i defines the facet index
2201
+ * @param ref defines the target vector
2202
+ * @returns the current mesh
2203
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2204
+ */
2205
+ getFacetNormalToRef(i, ref) {
2206
+ const localNorm = this.getFacetLocalNormals()[i];
2207
+ Vector3.TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
2208
+ return this;
2209
+ }
2210
+ /**
2211
+ * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
2212
+ * @param x defines x coordinate
2213
+ * @param y defines y coordinate
2214
+ * @param z defines z coordinate
2215
+ * @returns the array of facet indexes
2216
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2217
+ */
2218
+ getFacetsAtLocalCoordinates(x, y, z) {
2219
+ const bInfo = this.getBoundingInfo();
2220
+ const data = this._internalAbstractMeshDataInfo._facetData;
2221
+ const ox = Math.floor(((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio) / data.bbSize.x);
2222
+ const oy = Math.floor(((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio) / data.bbSize.y);
2223
+ const oz = Math.floor(((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio) / data.bbSize.z);
2224
+ if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
2225
+ return null;
2226
+ }
2227
+ return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
2228
+ }
2229
+ /**
2230
+ * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
2231
+ * @param x defines x coordinate
2232
+ * @param y defines y coordinate
2233
+ * @param z defines z coordinate
2234
+ * @param projected sets as the (x,y,z) world projection on the facet
2235
+ * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
2236
+ * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
2237
+ * @returns the face index if found (or null instead)
2238
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2239
+ */
2240
+ getClosestFacetAtCoordinates(x, y, z, projected, checkFace = false, facing = true) {
2241
+ const world = this.getWorldMatrix();
2242
+ const invMat = TmpVectors.Matrix[5];
2243
+ world.invertToRef(invMat);
2244
+ const invVect = TmpVectors.Vector3[8];
2245
+ Vector3.TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
2246
+ const closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
2247
+ if (projected) {
2248
+ // transform the local computed projected vector to world coordinates
2249
+ Vector3.TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
2250
+ }
2251
+ return closest;
2252
+ }
2253
+ /**
2254
+ * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
2255
+ * @param x defines x coordinate
2256
+ * @param y defines y coordinate
2257
+ * @param z defines z coordinate
2258
+ * @param projected sets as the (x,y,z) local projection on the facet
2259
+ * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
2260
+ * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
2261
+ * @returns the face index if found (or null instead)
2262
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2263
+ */
2264
+ getClosestFacetAtLocalCoordinates(x, y, z, projected, checkFace = false, facing = true) {
2265
+ let closest = null;
2266
+ let tmpx;
2267
+ let tmpy;
2268
+ let tmpz;
2269
+ let d; // tmp dot facet normal * facet position
2270
+ let t0;
2271
+ let projx;
2272
+ let projy;
2273
+ let projz;
2274
+ // Get all the facets in the same partitioning block than (x, y, z)
2275
+ const facetPositions = this.getFacetLocalPositions();
2276
+ const facetNormals = this.getFacetLocalNormals();
2277
+ const facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
2278
+ if (!facetsInBlock) {
2279
+ return null;
2280
+ }
2281
+ // Get the closest facet to (x, y, z)
2282
+ let shortest = Number.MAX_VALUE; // init distance vars
2283
+ let tmpDistance;
2284
+ let fib; // current facet in the block
2285
+ let norm; // current facet normal
2286
+ let p0; // current facet barycenter position
2287
+ // loop on all the facets in the current partitioning block
2288
+ for (let idx = 0; idx < facetsInBlock.length; idx++) {
2289
+ fib = facetsInBlock[idx];
2290
+ norm = facetNormals[fib];
2291
+ p0 = facetPositions[fib];
2292
+ d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
2293
+ if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
2294
+ // compute (x,y,z) projection on the facet = (projx, projy, projz)
2295
+ d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
2296
+ t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
2297
+ projx = x + norm.x * t0;
2298
+ projy = y + norm.y * t0;
2299
+ projz = z + norm.z * t0;
2300
+ tmpx = projx - x;
2301
+ tmpy = projy - y;
2302
+ tmpz = projz - z;
2303
+ tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
2304
+ if (tmpDistance < shortest) {
2305
+ // just keep the closest facet to (x, y, z)
2306
+ shortest = tmpDistance;
2307
+ closest = fib;
2308
+ if (projected) {
2309
+ projected.x = projx;
2310
+ projected.y = projy;
2311
+ projected.z = projz;
2312
+ }
2313
+ }
2307
2314
  }
2308
2315
  }
2316
+ return closest;
2309
2317
  }
2310
- }
2311
- return closest;
2312
- }
2313
- /**
2314
- * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
2315
- * @returns the parameters
2316
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2317
- */
2318
- getFacetDataParameters() {
2319
- return this._internalAbstractMeshDataInfo._facetData.facetParameters;
2320
- }
2321
- /**
2322
- * Disables the feature FacetData and frees the related memory
2323
- * @returns the current mesh
2324
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2325
- */
2326
- disableFacetData() {
2327
- const facetData = this._internalAbstractMeshDataInfo._facetData;
2328
- if (facetData.facetDataEnabled) {
2329
- facetData.facetDataEnabled = false;
2330
- facetData.facetPositions = [];
2331
- facetData.facetNormals = [];
2332
- facetData.facetPartitioning = new Array();
2333
- facetData.facetParameters = {};
2334
- facetData.depthSortedIndices = new Uint32Array(0);
2335
- }
2336
- return this;
2337
- }
2338
- /**
2339
- * Updates the AbstractMesh indices array
2340
- * @param indices defines the data source
2341
- * @param offset defines the offset in the index buffer where to store the new data (can be null)
2342
- * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
2343
- * @returns the current mesh
2344
- */
2345
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2346
- updateIndices(indices, offset, gpuMemoryOnly = false) {
2347
- return this;
2348
- }
2349
- /**
2350
- * Creates new normals data for the mesh
2351
- * @param updatable defines if the normal vertex buffer must be flagged as updatable
2352
- * @returns the current mesh
2353
- */
2354
- createNormals(updatable) {
2355
- const positions = this.getVerticesData(VertexBuffer.PositionKind);
2356
- const indices = this.getIndices();
2357
- let normals;
2358
- if (this.isVerticesDataPresent(VertexBuffer.NormalKind)) {
2359
- normals = this.getVerticesData(VertexBuffer.NormalKind);
2360
- }
2361
- else {
2362
- normals = [];
2363
- }
2364
- VertexData.ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
2365
- this.setVerticesData(VertexBuffer.NormalKind, normals, updatable);
2366
- return this;
2367
- }
2368
- /**
2369
- * Optimize the indices order so that we keep the faces with similar indices together
2370
- * @returns the current mesh
2371
- */
2372
- async optimizeIndicesAsync() {
2373
- const indices = this.getIndices();
2374
- if (!indices) {
2375
- return this;
2376
- }
2377
- const { OptimizeIndices } = await import("./mesh.vertexData.functions.js");
2378
- OptimizeIndices(indices);
2379
- this.setIndices(indices, this.getTotalVertices());
2380
- return this;
2381
- }
2382
- /**
2383
- * Align the mesh with a normal
2384
- * @param normal defines the normal to use
2385
- * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
2386
- * @returns the current mesh
2387
- */
2388
- alignWithNormal(normal, upDirection) {
2389
- if (!upDirection) {
2390
- upDirection = Axis.Y;
2391
- }
2392
- const axisX = TmpVectors.Vector3[0];
2393
- const axisZ = TmpVectors.Vector3[1];
2394
- Vector3.CrossToRef(upDirection, normal, axisZ);
2395
- Vector3.CrossToRef(normal, axisZ, axisX);
2396
- if (this.rotationQuaternion) {
2397
- Quaternion.RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
2398
- }
2399
- else {
2400
- Vector3.RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
2401
- }
2402
- return this;
2403
- }
2404
- /** @internal */
2405
- _checkOcclusionQuery(_checkOnly = false) {
2406
- // Will be replaced by correct code if Occlusion queries are referenced
2407
- return false;
2408
- }
2409
- // eslint-disable-next-line jsdoc/require-returns-check
2410
- /**
2411
- * Disables the mesh edge rendering mode
2412
- * @returns the currentAbstractMesh
2413
- */
2414
- disableEdgesRendering() {
2415
- throw _WarnImport("EdgesRenderer");
2416
- }
2417
- // eslint-disable-next-line jsdoc/require-returns-check
2418
- /**
2419
- * Enables the edge rendering mode on the mesh.
2420
- * This mode makes the mesh edges visible
2421
- * @param epsilon defines the maximal distance between two angles to detect a face
2422
- * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
2423
- * @param options options to the edge renderer
2424
- * @returns the currentAbstractMesh
2425
- * @see https://www.babylonjs-playground.com/#19O9TU#0
2426
- */
2427
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2428
- enableEdgesRendering(epsilon, checkVerticesInsteadOfIndices, options) {
2429
- throw _WarnImport("EdgesRenderer");
2430
- }
2431
- /**
2432
- * This function returns all of the particle systems in the scene that use the mesh as an emitter.
2433
- * @returns an array of particle systems in the scene that use the mesh as an emitter
2434
- */
2435
- getConnectedParticleSystems() {
2436
- return this._scene.particleSystems.filter((particleSystem) => particleSystem.emitter === this);
2437
- }
2438
- }
2439
- /** No occlusion */
2440
- AbstractMesh.OCCLUSION_TYPE_NONE = 0;
2441
- /** Occlusion set to optimistic */
2442
- AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
2443
- /** Occlusion set to strict */
2444
- AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
2445
- /** Use an accurate occlusion algorithm */
2446
- AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
2447
- /** Use a conservative occlusion algorithm */
2448
- AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
2449
- /** Default culling strategy : this is an exclusion test and it's the more accurate.
2450
- * Test order :
2451
- * Is the bounding sphere outside the frustum ?
2452
- * If not, are the bounding box vertices outside the frustum ?
2453
- * It not, then the cullable object is in the frustum.
2454
- */
2455
- AbstractMesh.CULLINGSTRATEGY_STANDARD = 0;
2456
- /** Culling strategy : Bounding Sphere Only.
2457
- * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
2458
- * It's also less accurate than the standard because some not visible objects can still be selected.
2459
- * Test : is the bounding sphere outside the frustum ?
2460
- * If not, then the cullable object is in the frustum.
2461
- */
2462
- AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
2463
- /** Culling strategy : Optimistic Inclusion.
2464
- * This in an inclusion test first, then the standard exclusion test.
2465
- * This can be faster when a cullable object is expected to be almost always in the camera frustum.
2466
- * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
2467
- * Anyway, it's as accurate as the standard strategy.
2468
- * Test :
2469
- * Is the cullable object bounding sphere center in the frustum ?
2470
- * If not, apply the default culling strategy.
2471
- */
2472
- AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
2473
- /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
2474
- * This in an inclusion test first, then the bounding sphere only exclusion test.
2475
- * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
2476
- * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
2477
- * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
2478
- * Test :
2479
- * Is the cullable object bounding sphere center in the frustum ?
2480
- * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
2481
- */
2482
- AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
2483
- /**
2484
- * Gets or sets the default value for isPickable for newly created meshes.
2485
- * When set to false, all meshes created after the change will not be pickable by default.
2486
- * Individual meshes can still override this by setting their own isPickable property.
2487
- */
2488
- AbstractMesh.DefaultIsPickable = true;
2489
- __decorate([
2490
- nativeOverride.filter((...args) => !Array.isArray(args[0]) && !Array.isArray(args[3]) && !Array.isArray(args[4]) && !Array.isArray(args[5]) && !Array.isArray(args[6]))
2491
- ], AbstractMesh, "_ApplySkeleton", null);
2318
+ /**
2319
+ * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
2320
+ * @returns the parameters
2321
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2322
+ */
2323
+ getFacetDataParameters() {
2324
+ return this._internalAbstractMeshDataInfo._facetData.facetParameters;
2325
+ }
2326
+ /**
2327
+ * Disables the feature FacetData and frees the related memory
2328
+ * @returns the current mesh
2329
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/facetData
2330
+ */
2331
+ disableFacetData() {
2332
+ const facetData = this._internalAbstractMeshDataInfo._facetData;
2333
+ if (facetData.facetDataEnabled) {
2334
+ facetData.facetDataEnabled = false;
2335
+ facetData.facetPositions = [];
2336
+ facetData.facetNormals = [];
2337
+ facetData.facetPartitioning = new Array();
2338
+ facetData.facetParameters = {};
2339
+ facetData.depthSortedIndices = new Uint32Array(0);
2340
+ }
2341
+ return this;
2342
+ }
2343
+ /**
2344
+ * Updates the AbstractMesh indices array
2345
+ * @param indices defines the data source
2346
+ * @param offset defines the offset in the index buffer where to store the new data (can be null)
2347
+ * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
2348
+ * @returns the current mesh
2349
+ */
2350
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2351
+ updateIndices(indices, offset, gpuMemoryOnly = false) {
2352
+ return this;
2353
+ }
2354
+ /**
2355
+ * Creates new normals data for the mesh
2356
+ * @param updatable defines if the normal vertex buffer must be flagged as updatable
2357
+ * @returns the current mesh
2358
+ */
2359
+ createNormals(updatable) {
2360
+ const positions = this.getVerticesData(VertexBuffer.PositionKind);
2361
+ const indices = this.getIndices();
2362
+ let normals;
2363
+ if (this.isVerticesDataPresent(VertexBuffer.NormalKind)) {
2364
+ normals = this.getVerticesData(VertexBuffer.NormalKind);
2365
+ }
2366
+ else {
2367
+ normals = [];
2368
+ }
2369
+ VertexData.ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
2370
+ this.setVerticesData(VertexBuffer.NormalKind, normals, updatable);
2371
+ return this;
2372
+ }
2373
+ /**
2374
+ * Optimize the indices order so that we keep the faces with similar indices together
2375
+ * @returns the current mesh
2376
+ */
2377
+ async optimizeIndicesAsync() {
2378
+ const indices = this.getIndices();
2379
+ if (!indices) {
2380
+ return this;
2381
+ }
2382
+ const { OptimizeIndices } = await import("./mesh.vertexData.functions.js");
2383
+ OptimizeIndices(indices);
2384
+ this.setIndices(indices, this.getTotalVertices());
2385
+ return this;
2386
+ }
2387
+ /**
2388
+ * Align the mesh with a normal
2389
+ * @param normal defines the normal to use
2390
+ * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
2391
+ * @returns the current mesh
2392
+ */
2393
+ alignWithNormal(normal, upDirection) {
2394
+ if (!upDirection) {
2395
+ upDirection = Axis.Y;
2396
+ }
2397
+ const axisX = TmpVectors.Vector3[0];
2398
+ const axisZ = TmpVectors.Vector3[1];
2399
+ Vector3.CrossToRef(upDirection, normal, axisZ);
2400
+ Vector3.CrossToRef(normal, axisZ, axisX);
2401
+ if (this.rotationQuaternion) {
2402
+ Quaternion.RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
2403
+ }
2404
+ else {
2405
+ Vector3.RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
2406
+ }
2407
+ return this;
2408
+ }
2409
+ /** @internal */
2410
+ _checkOcclusionQuery(_checkOnly = false) {
2411
+ // Will be replaced by correct code if Occlusion queries are referenced
2412
+ return false;
2413
+ }
2414
+ // eslint-disable-next-line jsdoc/require-returns-check
2415
+ /**
2416
+ * Disables the mesh edge rendering mode
2417
+ * @returns the currentAbstractMesh
2418
+ */
2419
+ disableEdgesRendering() {
2420
+ throw _WarnImport("EdgesRenderer");
2421
+ }
2422
+ // eslint-disable-next-line jsdoc/require-returns-check
2423
+ /**
2424
+ * Enables the edge rendering mode on the mesh.
2425
+ * This mode makes the mesh edges visible
2426
+ * @param epsilon defines the maximal distance between two angles to detect a face
2427
+ * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
2428
+ * @param options options to the edge renderer
2429
+ * @returns the currentAbstractMesh
2430
+ * @see https://www.babylonjs-playground.com/#19O9TU#0
2431
+ */
2432
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2433
+ enableEdgesRendering(epsilon, checkVerticesInsteadOfIndices, options) {
2434
+ throw _WarnImport("EdgesRenderer");
2435
+ }
2436
+ /**
2437
+ * This function returns all of the particle systems in the scene that use the mesh as an emitter.
2438
+ * @returns an array of particle systems in the scene that use the mesh as an emitter
2439
+ */
2440
+ getConnectedParticleSystems() {
2441
+ return this._scene.particleSystems.filter((particleSystem) => particleSystem.emitter === this);
2442
+ }
2443
+ },
2444
+ (() => {
2445
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
2446
+ _static__ApplySkeleton_decorators = [nativeOverride.filter((...args) => !Array.isArray(args[0]) && !Array.isArray(args[3]) && !Array.isArray(args[4]) && !Array.isArray(args[5]) && !Array.isArray(args[6]))];
2447
+ __esDecorate(_a, null, _static__ApplySkeleton_decorators, { kind: "method", name: "_ApplySkeleton", static: true, private: false, access: { has: obj => "_ApplySkeleton" in obj, get: obj => obj._ApplySkeleton }, metadata: _metadata }, null, _staticExtraInitializers);
2448
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
2449
+ })(),
2450
+ /** No occlusion */
2451
+ _a.OCCLUSION_TYPE_NONE = (__runInitializers(_a, _staticExtraInitializers), 0),
2452
+ /** Occlusion set to optimistic */
2453
+ _a.OCCLUSION_TYPE_OPTIMISTIC = 1,
2454
+ /** Occlusion set to strict */
2455
+ _a.OCCLUSION_TYPE_STRICT = 2,
2456
+ /** Use an accurate occlusion algorithm */
2457
+ _a.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0,
2458
+ /** Use a conservative occlusion algorithm */
2459
+ _a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1,
2460
+ /** Default culling strategy : this is an exclusion test and it's the more accurate.
2461
+ * Test order :
2462
+ * Is the bounding sphere outside the frustum ?
2463
+ * If not, are the bounding box vertices outside the frustum ?
2464
+ * It not, then the cullable object is in the frustum.
2465
+ */
2466
+ _a.CULLINGSTRATEGY_STANDARD = 0,
2467
+ /** Culling strategy : Bounding Sphere Only.
2468
+ * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
2469
+ * It's also less accurate than the standard because some not visible objects can still be selected.
2470
+ * Test : is the bounding sphere outside the frustum ?
2471
+ * If not, then the cullable object is in the frustum.
2472
+ */
2473
+ _a.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
2474
+ /** Culling strategy : Optimistic Inclusion.
2475
+ * This in an inclusion test first, then the standard exclusion test.
2476
+ * This can be faster when a cullable object is expected to be almost always in the camera frustum.
2477
+ * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
2478
+ * Anyway, it's as accurate as the standard strategy.
2479
+ * Test :
2480
+ * Is the cullable object bounding sphere center in the frustum ?
2481
+ * If not, apply the default culling strategy.
2482
+ */
2483
+ _a.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
2484
+ /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
2485
+ * This in an inclusion test first, then the bounding sphere only exclusion test.
2486
+ * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
2487
+ * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
2488
+ * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
2489
+ * Test :
2490
+ * Is the cullable object bounding sphere center in the frustum ?
2491
+ * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
2492
+ */
2493
+ _a.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
2494
+ /**
2495
+ * Gets or sets the default value for isPickable for newly created meshes.
2496
+ * When set to false, all meshes created after the change will not be pickable by default.
2497
+ * Individual meshes can still override this by setting their own isPickable property.
2498
+ */
2499
+ _a.DefaultIsPickable = true,
2500
+ _a;
2501
+ })();
2502
+ export { AbstractMesh };
2492
2503
  let _Registered = false;
2493
2504
  /**
2494
2505
  * Register side effects for abstractMesh.