@onerjs/core 8.53.4 → 8.53.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (841) hide show
  1. package/Animations/animationGroup.d.ts +0 -1
  2. package/Animations/animationGroup.js +0 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Animations/animationGroup.pure.js +2 -0
  5. package/Animations/animationGroup.pure.js.map +1 -1
  6. package/Animations/runtimeAnimation.js +11 -0
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.pure.js +1 -1
  9. package/AudioV2/abstractAudio/abstractSound.d.ts +2 -1
  10. package/AudioV2/abstractAudio/abstractSound.js +7 -2
  11. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  12. package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +3 -1
  13. package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -1
  14. package/AudioV2/abstractAudio/staticSound.d.ts +6 -0
  15. package/AudioV2/abstractAudio/staticSound.js +17 -1
  16. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/staticSoundInstance.d.ts +4 -2
  18. package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
  19. package/AudioV2/abstractAudio/streamingSound.d.ts +6 -0
  20. package/AudioV2/abstractAudio/streamingSound.js +9 -1
  21. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  22. package/AudioV2/webAudio/webAudioStaticSound.d.ts +7 -1
  23. package/AudioV2/webAudio/webAudioStaticSound.js +56 -8
  24. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  25. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -1
  26. package/AudioV2/webAudio/webAudioStreamingSound.js +16 -4
  27. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  28. package/BakedVertexAnimation/bakedVertexAnimationManager.d.ts +2 -2
  29. package/BakedVertexAnimation/bakedVertexAnimationManager.js +151 -121
  30. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  31. package/Behaviors/Cameras/interpolatingBehavior.d.ts +17 -2
  32. package/Behaviors/Cameras/interpolatingBehavior.js +53 -23
  33. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  34. package/Bones/bone.pure.js +3 -3
  35. package/Buffers/buffer.pure.js +0 -12
  36. package/Buffers/buffer.pure.js.map +1 -1
  37. package/Cameras/Inputs/BaseCameraMouseWheelInput.js +141 -126
  38. package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
  39. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +2 -1
  40. package/Cameras/Inputs/BaseCameraPointersInput.js +290 -277
  41. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  42. package/Cameras/Inputs/arcRotateCameraGamepadInput.js +115 -102
  43. package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
  44. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.d.ts +3 -0
  45. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js +334 -273
  46. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
  47. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +273 -258
  48. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  49. package/Cameras/Inputs/arcRotateCameraPointersInput.js +237 -213
  50. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  51. package/Cameras/Inputs/flyCameraKeyboardInput.js +199 -168
  52. package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
  53. package/Cameras/Inputs/flyCameraMouseInput.js +243 -229
  54. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  55. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +311 -266
  56. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  57. package/Cameras/Inputs/followCameraMouseWheelInput.js +139 -119
  58. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  59. package/Cameras/Inputs/followCameraPointersInput.js +239 -203
  60. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  61. package/Cameras/Inputs/freeCameraGamepadInput.js +127 -114
  62. package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
  63. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +278 -244
  64. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  65. package/Cameras/Inputs/freeCameraMouseInput.js +216 -202
  66. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  67. package/Cameras/Inputs/freeCameraMouseWheelInput.js +368 -353
  68. package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
  69. package/Cameras/Inputs/freeCameraTouchInput.js +185 -172
  70. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  71. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +2 -0
  72. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +291 -246
  73. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  74. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +11 -1
  75. package/Cameras/Inputs/geospatialCameraPointersInput.js +18 -2
  76. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  77. package/Cameras/Inputs/orbitCameraPointersInput.js +112 -96
  78. package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -1
  79. package/Cameras/VR/vrExperienceHelper.d.ts +0 -2
  80. package/Cameras/VR/vrExperienceHelper.js +0 -2
  81. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  82. package/Cameras/VR/vrExperienceHelper.pure.js +5 -0
  83. package/Cameras/VR/vrExperienceHelper.pure.js.map +1 -1
  84. package/Cameras/arcRotateCamera.pure.js +1559 -1479
  85. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  86. package/Cameras/camera.pure.js +1225 -1178
  87. package/Cameras/camera.pure.js.map +1 -1
  88. package/Cameras/flyCamera.pure.js +369 -351
  89. package/Cameras/flyCamera.pure.js.map +1 -1
  90. package/Cameras/followCamera.pure.js +229 -192
  91. package/Cameras/followCamera.pure.js.map +1 -1
  92. package/Cameras/freeCamera.pure.js +373 -351
  93. package/Cameras/freeCamera.pure.js.map +1 -1
  94. package/Cameras/geospatialCamera.pure.d.ts +30 -7
  95. package/Cameras/geospatialCamera.pure.js +502 -457
  96. package/Cameras/geospatialCamera.pure.js.map +1 -1
  97. package/Cameras/geospatialCameraMovement.js +2 -2
  98. package/Cameras/geospatialCameraMovement.js.map +1 -1
  99. package/Cameras/targetCamera.pure.d.ts +7 -0
  100. package/Cameras/targetCamera.pure.js +550 -509
  101. package/Cameras/targetCamera.pure.js.map +1 -1
  102. package/Cameras/universalCamera.pure.js +98 -85
  103. package/Cameras/universalCamera.pure.js.map +1 -1
  104. package/Collisions/gpuPicker.d.ts +111 -4
  105. package/Collisions/gpuPicker.js +696 -119
  106. package/Collisions/gpuPicker.js.map +1 -1
  107. package/Compute/computeShader.pure.js +372 -355
  108. package/Compute/computeShader.pure.js.map +1 -1
  109. package/Culling/Helper/transformFeedbackBoundingHelper.pure.js +2 -2
  110. package/Decorators/nodeDecorator.d.ts +11 -1
  111. package/Decorators/nodeDecorator.js +43 -6
  112. package/Decorators/nodeDecorator.js.map +1 -1
  113. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js +8 -0
  114. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js.map +1 -1
  115. package/Engines/Native/nativeHelpers.js +15 -0
  116. package/Engines/Native/nativeHelpers.js.map +1 -1
  117. package/Engines/Native/nativeInterfaces.d.ts +7 -2
  118. package/Engines/Native/nativeInterfaces.js.map +1 -1
  119. package/Engines/Native/nativeRenderTargetWrapper.d.ts +5 -0
  120. package/Engines/Native/nativeRenderTargetWrapper.js +35 -1
  121. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  122. package/Engines/Processors/shaderProcessor.js +5 -3
  123. package/Engines/Processors/shaderProcessor.js.map +1 -1
  124. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js +16 -3
  125. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js.map +1 -1
  126. package/Engines/WebGPU/webgpuClearQuad.pure.js +7 -1
  127. package/Engines/WebGPU/webgpuClearQuad.pure.js.map +1 -1
  128. package/Engines/abstractEngine.functions.d.ts +8 -2
  129. package/Engines/abstractEngine.functions.js +12 -4
  130. package/Engines/abstractEngine.functions.js.map +1 -1
  131. package/Engines/abstractEngine.pure.d.ts +20 -1
  132. package/Engines/abstractEngine.pure.js +21 -134
  133. package/Engines/abstractEngine.pure.js.map +1 -1
  134. package/Engines/engine.d.ts +208 -0
  135. package/Engines/engine.pure.js +0 -15
  136. package/Engines/engine.pure.js.map +1 -1
  137. package/Engines/nullEngine.pure.d.ts +66 -0
  138. package/Engines/nullEngine.pure.js +97 -0
  139. package/Engines/nullEngine.pure.js.map +1 -1
  140. package/Engines/thinEngine.pure.d.ts +0 -13
  141. package/Engines/thinEngine.pure.js +4 -23
  142. package/Engines/thinEngine.pure.js.map +1 -1
  143. package/Engines/thinNativeEngine.d.ts +0 -1
  144. package/Engines/thinNativeEngine.js +0 -1
  145. package/Engines/thinNativeEngine.js.map +1 -1
  146. package/Engines/thinNativeEngine.pure.d.ts +27 -0
  147. package/Engines/thinNativeEngine.pure.js +383 -17
  148. package/Engines/thinNativeEngine.pure.js.map +1 -1
  149. package/Engines/webgpuEngine.d.ts +1 -0
  150. package/Engines/webgpuEngine.js +1 -0
  151. package/Engines/webgpuEngine.js.map +1 -1
  152. package/Engines/webgpuEngine.pure.d.ts +9 -0
  153. package/Engines/webgpuEngine.pure.js +7 -0
  154. package/Engines/webgpuEngine.pure.js.map +1 -1
  155. package/FlowGraph/flowGraph.js +9 -0
  156. package/FlowGraph/flowGraph.js.map +1 -1
  157. package/FlowGraph/flowGraphContext.js +597 -584
  158. package/FlowGraph/flowGraphContext.js.map +1 -1
  159. package/FlowGraph/flowGraphDataConnection.pure.d.ts +14 -0
  160. package/FlowGraph/flowGraphDataConnection.pure.js +38 -1
  161. package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
  162. package/FlowGraph/serialization.d.ts +11 -0
  163. package/FlowGraph/serialization.js +11 -1
  164. package/FlowGraph/serialization.js.map +1 -1
  165. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js +182 -170
  166. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js.map +1 -1
  167. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js +196 -184
  168. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js.map +1 -1
  169. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js +222 -210
  170. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js.map +1 -1
  171. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +123 -111
  172. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  173. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +158 -146
  174. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
  175. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js +63 -51
  176. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js.map +1 -1
  177. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js +122 -110
  178. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js.map +1 -1
  179. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js +76 -64
  180. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js.map +1 -1
  181. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js +89 -77
  182. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js.map +1 -1
  183. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js +134 -122
  184. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js.map +1 -1
  185. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js +58 -46
  186. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js.map +1 -1
  187. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js +107 -95
  188. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js.map +1 -1
  189. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js +181 -169
  190. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js.map +1 -1
  191. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js +63 -51
  192. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js.map +1 -1
  193. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js +63 -51
  194. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js.map +1 -1
  195. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js +76 -64
  196. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js.map +1 -1
  197. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js +246 -234
  198. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js.map +1 -1
  199. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js +108 -96
  200. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js.map +1 -1
  201. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js +87 -75
  202. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js.map +1 -1
  203. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js +76 -64
  204. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js.map +1 -1
  205. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js +313 -301
  206. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js.map +1 -1
  207. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js +502 -490
  208. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js.map +1 -1
  209. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js +147 -135
  210. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js.map +1 -1
  211. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js +90 -78
  212. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js.map +1 -1
  213. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js +179 -167
  214. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js.map +1 -1
  215. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +462 -451
  216. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  217. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +265 -253
  218. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
  219. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js +204 -192
  220. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js.map +1 -1
  221. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +611 -550
  222. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
  223. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js +320 -308
  224. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js.map +1 -1
  225. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js +87 -75
  226. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js.map +1 -1
  227. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js +154 -142
  228. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js.map +1 -1
  229. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js +150 -138
  230. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js.map +1 -1
  231. package/FrameGraph/Node/Blocks/inputBlock.pure.js +270 -256
  232. package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
  233. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js +95 -83
  234. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js.map +1 -1
  235. package/FrameGraph/Node/nodeRenderGraph.js +715 -693
  236. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  237. package/FrameGraph/Node/nodeRenderGraphBlock.js +548 -533
  238. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  239. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +2 -2
  240. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +43 -51
  241. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
  242. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.d.ts +0 -1
  243. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js +0 -1
  244. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js.map +1 -1
  245. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.d.ts +0 -1
  246. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +66 -35
  247. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
  248. package/Helpers/environmentHelper.js +2 -2
  249. package/Helpers/environmentHelper.js.map +1 -1
  250. package/Layers/effectLayer.js +529 -519
  251. package/Layers/effectLayer.js.map +1 -1
  252. package/Layers/glowLayer.pure.js +428 -413
  253. package/Layers/glowLayer.pure.js.map +1 -1
  254. package/Layers/highlightLayer.pure.js +473 -458
  255. package/Layers/highlightLayer.pure.js.map +1 -1
  256. package/Layers/selectionOutlineLayer.pure.js +360 -345
  257. package/Layers/selectionOutlineLayer.pure.js.map +1 -1
  258. package/Lights/Clustered/clusteredLightContainer.pure.d.ts +1 -1
  259. package/Lights/Clustered/clusteredLightContainer.pure.js +583 -558
  260. package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
  261. package/Lights/Shadows/shadowGenerator.js +6 -1
  262. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  263. package/Lights/areaLight.pure.js +61 -39
  264. package/Lights/areaLight.pure.js.map +1 -1
  265. package/Lights/directionalLight.pure.js +308 -284
  266. package/Lights/directionalLight.pure.js.map +1 -1
  267. package/Lights/hemisphericLight.pure.js +123 -104
  268. package/Lights/hemisphericLight.pure.js.map +1 -1
  269. package/Lights/light.d.ts +5 -3
  270. package/Lights/light.js +869 -827
  271. package/Lights/light.js.map +1 -1
  272. package/Lights/pointLight.pure.js +185 -174
  273. package/Lights/pointLight.pure.js.map +1 -1
  274. package/Lights/rectAreaLight.pure.d.ts +17 -0
  275. package/Lights/rectAreaLight.pure.js +238 -159
  276. package/Lights/rectAreaLight.pure.js.map +1 -1
  277. package/Lights/shadowLight.js +280 -268
  278. package/Lights/shadowLight.js.map +1 -1
  279. package/Lights/spotLight.pure.js +460 -427
  280. package/Lights/spotLight.pure.js.map +1 -1
  281. package/Loading/Plugins/babylonFileLoader.pure.js +17 -5
  282. package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
  283. package/Loading/sceneLoader.d.ts +5 -1
  284. package/Loading/sceneLoader.js +299 -402
  285. package/Loading/sceneLoader.js.map +1 -1
  286. package/Materials/Background/backgroundMaterial.pure.d.ts +18 -18
  287. package/Materials/Background/backgroundMaterial.pure.js +949 -794
  288. package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
  289. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.d.ts +15 -0
  290. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +34 -1
  291. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
  292. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +9 -0
  293. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +26 -2
  294. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  295. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.d.ts +2 -1
  296. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js +169 -149
  297. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js.map +1 -1
  298. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +1 -1
  299. package/Materials/Node/Blocks/Dual/lightBlock.pure.js +442 -429
  300. package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
  301. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js +396 -383
  302. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js.map +1 -1
  303. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js +237 -220
  304. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js.map +1 -1
  305. package/Materials/Node/Blocks/Dual/textureBlock.pure.js +1 -1
  306. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js +150 -133
  307. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
  308. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +265 -250
  309. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
  310. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js +159 -142
  311. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js.map +1 -1
  312. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js +214 -201
  313. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js.map +1 -1
  314. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js +419 -400
  315. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js.map +1 -1
  316. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +3 -1
  317. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
  318. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js +302 -289
  319. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js.map +1 -1
  320. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +1327 -1272
  321. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  322. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js +352 -337
  323. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js.map +1 -1
  324. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js +297 -277
  325. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js.map +1 -1
  326. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js +146 -131
  327. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js.map +1 -1
  328. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js +158 -145
  329. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js.map +1 -1
  330. package/Materials/Node/Blocks/clampBlock.pure.js +92 -77
  331. package/Materials/Node/Blocks/clampBlock.pure.js.map +1 -1
  332. package/Materials/Node/Blocks/cloudBlock.pure.js +145 -132
  333. package/Materials/Node/Blocks/cloudBlock.pure.js.map +1 -1
  334. package/Materials/Node/Blocks/conditionalBlock.pure.js +182 -169
  335. package/Materials/Node/Blocks/conditionalBlock.pure.js.map +1 -1
  336. package/Materials/Node/Blocks/curveBlock.pure.js +259 -246
  337. package/Materials/Node/Blocks/curveBlock.pure.js.map +1 -1
  338. package/Materials/Node/Blocks/debugBlock.pure.js +119 -106
  339. package/Materials/Node/Blocks/debugBlock.pure.js.map +1 -1
  340. package/Materials/Node/Blocks/loopBlock.pure.js +123 -110
  341. package/Materials/Node/Blocks/loopBlock.pure.js.map +1 -1
  342. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js +185 -172
  343. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js.map +1 -1
  344. package/Materials/Node/Blocks/remapBlock.pure.js +127 -112
  345. package/Materials/Node/Blocks/remapBlock.pure.js.map +1 -1
  346. package/Materials/Node/Blocks/transformBlock.pure.js +196 -185
  347. package/Materials/Node/Blocks/transformBlock.pure.js.map +1 -1
  348. package/Materials/Node/Blocks/triPlanarBlock.pure.js +451 -438
  349. package/Materials/Node/Blocks/triPlanarBlock.pure.js.map +1 -1
  350. package/Materials/Node/Blocks/trigonometryBlock.pure.js +184 -171
  351. package/Materials/Node/Blocks/trigonometryBlock.pure.js.map +1 -1
  352. package/Materials/Node/Blocks/waveBlock.pure.js +97 -84
  353. package/Materials/Node/Blocks/waveBlock.pure.js.map +1 -1
  354. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js +276 -263
  355. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js.map +1 -1
  356. package/Materials/Node/nodeMaterial.pure.js +1765 -1737
  357. package/Materials/Node/nodeMaterial.pure.js.map +1 -1
  358. package/Materials/Node/nodeMaterialBuildState.d.ts +3 -3
  359. package/Materials/PBR/openpbrMaterial.pure.d.ts +102 -102
  360. package/Materials/PBR/openpbrMaterial.pure.js +3115 -2243
  361. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  362. package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +3 -3
  363. package/Materials/PBR/pbrAnisotropicConfiguration.js +255 -227
  364. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  365. package/Materials/PBR/pbrBRDFConfiguration.d.ts +9 -9
  366. package/Materials/PBR/pbrBRDFConfiguration.js +203 -155
  367. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  368. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +1 -1
  369. package/Materials/PBR/pbrBaseMaterial.pure.js +1751 -1736
  370. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  371. package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +13 -13
  372. package/Materials/PBR/pbrBaseSimpleMaterial.js +205 -117
  373. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  374. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +9 -9
  375. package/Materials/PBR/pbrClearCoatConfiguration.js +464 -406
  376. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  377. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +3 -3
  378. package/Materials/PBR/pbrIridescenceConfiguration.js +271 -239
  379. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  380. package/Materials/PBR/pbrMaterial.pure.d.ts +66 -66
  381. package/Materials/PBR/pbrMaterial.pure.js +1041 -685
  382. package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
  383. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.d.ts +5 -5
  384. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js +176 -115
  385. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js.map +1 -1
  386. package/Materials/PBR/pbrSheenConfiguration.d.ts +7 -7
  387. package/Materials/PBR/pbrSheenConfiguration.js +314 -270
  388. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  389. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.d.ts +5 -5
  390. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js +172 -117
  391. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js.map +1 -1
  392. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +16 -16
  393. package/Materials/PBR/pbrSubSurfaceConfiguration.js +864 -764
  394. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  395. package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +43 -0
  396. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +64 -0
  397. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -0
  398. package/Materials/Textures/HTML/htmlInteractionManager.d.ts +69 -0
  399. package/Materials/Textures/HTML/htmlInteractionManager.js +130 -0
  400. package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -0
  401. package/Materials/Textures/HTML/htmlRaycastInteractionManager.d.ts +84 -0
  402. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js +246 -0
  403. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js.map +1 -0
  404. package/Materials/Textures/HTML/htmlTexture.d.ts +148 -0
  405. package/Materials/Textures/HTML/htmlTexture.js +455 -0
  406. package/Materials/Textures/HTML/htmlTexture.js.map +1 -0
  407. package/Materials/Textures/HTML/index.d.ts +4 -0
  408. package/Materials/Textures/HTML/index.js +5 -0
  409. package/Materials/Textures/HTML/index.js.map +1 -0
  410. package/Materials/Textures/HTML/pure.d.ts +5 -0
  411. package/Materials/Textures/HTML/pure.js +6 -0
  412. package/Materials/Textures/HTML/pure.js.map +1 -0
  413. package/Materials/Textures/Procedurals/proceduralTexture.pure.js +671 -643
  414. package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
  415. package/Materials/Textures/baseTexture.pure.js +880 -825
  416. package/Materials/Textures/baseTexture.pure.js.map +1 -1
  417. package/Materials/Textures/cubeTexture.d.ts +0 -1
  418. package/Materials/Textures/cubeTexture.js +0 -1
  419. package/Materials/Textures/cubeTexture.js.map +1 -1
  420. package/Materials/Textures/cubeTexture.pure.js +368 -333
  421. package/Materials/Textures/cubeTexture.pure.js.map +1 -1
  422. package/Materials/Textures/dynamicTexture.d.ts +0 -1
  423. package/Materials/Textures/dynamicTexture.js +0 -1
  424. package/Materials/Textures/dynamicTexture.js.map +1 -1
  425. package/Materials/Textures/dynamicTexture.pure.js +2 -0
  426. package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
  427. package/Materials/Textures/htmlElementTexture.d.ts +0 -2
  428. package/Materials/Textures/htmlElementTexture.js +0 -2
  429. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  430. package/Materials/Textures/htmlElementTexture.pure.js +4 -0
  431. package/Materials/Textures/htmlElementTexture.pure.js.map +1 -1
  432. package/Materials/Textures/index.d.ts +1 -0
  433. package/Materials/Textures/index.js +1 -1
  434. package/Materials/Textures/index.js.map +1 -1
  435. package/Materials/Textures/multiRenderTarget.d.ts +0 -1
  436. package/Materials/Textures/multiRenderTarget.js +0 -1
  437. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  438. package/Materials/Textures/multiRenderTarget.pure.js +2 -0
  439. package/Materials/Textures/multiRenderTarget.pure.js.map +1 -1
  440. package/Materials/Textures/pure.d.ts +1 -0
  441. package/Materials/Textures/pure.js +1 -0
  442. package/Materials/Textures/pure.js.map +1 -1
  443. package/Materials/Textures/texture.pure.js +961 -923
  444. package/Materials/Textures/texture.pure.js.map +1 -1
  445. package/Materials/Textures/videoTexture.pure.d.ts +3 -0
  446. package/Materials/Textures/videoTexture.pure.js +450 -401
  447. package/Materials/Textures/videoTexture.pure.js.map +1 -1
  448. package/Materials/colorCurves.pure.js +510 -477
  449. package/Materials/colorCurves.pure.js.map +1 -1
  450. package/Materials/effect.pure.js +0 -7
  451. package/Materials/effect.pure.js.map +1 -1
  452. package/Materials/imageProcessing.js +12 -4
  453. package/Materials/imageProcessing.js.map +1 -1
  454. package/Materials/imageProcessingConfiguration.pure.js +647 -587
  455. package/Materials/imageProcessingConfiguration.pure.js.map +1 -1
  456. package/Materials/material.decalMapConfiguration.pure.d.ts +2 -2
  457. package/Materials/material.decalMapConfiguration.pure.js +149 -130
  458. package/Materials/material.decalMapConfiguration.pure.js.map +1 -1
  459. package/Materials/material.detailMapConfiguration.d.ts +3 -3
  460. package/Materials/material.detailMapConfiguration.js +213 -175
  461. package/Materials/material.detailMapConfiguration.js.map +1 -1
  462. package/Materials/material.pure.js +1815 -1721
  463. package/Materials/material.pure.js.map +1 -1
  464. package/Materials/materialPluginBase.pure.js +270 -249
  465. package/Materials/materialPluginBase.pure.js.map +1 -1
  466. package/Materials/materialPluginManager.pure.js +18 -8
  467. package/Materials/materialPluginManager.pure.js.map +1 -1
  468. package/Materials/materialStencilState.js +211 -200
  469. package/Materials/materialStencilState.js.map +1 -1
  470. package/Materials/meshDebugPluginMaterial.pure.d.ts +2 -2
  471. package/Materials/meshDebugPluginMaterial.pure.js +397 -275
  472. package/Materials/meshDebugPluginMaterial.pure.js.map +1 -1
  473. package/Materials/standardMaterial.pure.d.ts +32 -32
  474. package/Materials/standardMaterial.pure.js +1804 -1394
  475. package/Materials/standardMaterial.pure.js.map +1 -1
  476. package/Maths/math.color.pure.js +5 -5
  477. package/Maths/math.functions.js +38 -30
  478. package/Maths/math.functions.js.map +1 -1
  479. package/Maths/math.vector.pure.js +25 -25
  480. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +18 -8
  481. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  482. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +86 -1
  483. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +255 -104
  484. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  485. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.d.ts +39 -0
  486. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +322 -0
  487. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -0
  488. package/Meshes/GreasedLine/greasedLineMesh.pure.js +4 -4
  489. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +3 -3
  490. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +107 -94
  491. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
  492. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js +276 -263
  493. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js.map +1 -1
  494. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js +247 -232
  495. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js.map +1 -1
  496. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js +299 -284
  497. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js.map +1 -1
  498. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js +196 -181
  499. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js.map +1 -1
  500. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js +198 -179
  501. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js.map +1 -1
  502. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js +151 -138
  503. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js.map +1 -1
  504. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js +107 -94
  505. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js.map +1 -1
  506. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js +138 -125
  507. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js.map +1 -1
  508. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js +213 -200
  509. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js.map +1 -1
  510. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js +138 -125
  511. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js.map +1 -1
  512. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js +179 -164
  513. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js.map +1 -1
  514. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js +183 -170
  515. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js.map +1 -1
  516. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js +125 -112
  517. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js.map +1 -1
  518. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js +153 -140
  519. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js.map +1 -1
  520. package/Meshes/Node/Blocks/Sources/discBlock.pure.js +112 -99
  521. package/Meshes/Node/Blocks/Sources/discBlock.pure.js.map +1 -1
  522. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js +133 -120
  523. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js.map +1 -1
  524. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js +128 -115
  525. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js.map +1 -1
  526. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js +116 -103
  527. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js.map +1 -1
  528. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js +160 -147
  529. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js.map +1 -1
  530. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js +144 -131
  531. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js.map +1 -1
  532. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js +112 -99
  533. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js.map +1 -1
  534. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js +200 -185
  535. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js.map +1 -1
  536. package/Meshes/Node/Blocks/bevelBlock.pure.js +111 -98
  537. package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
  538. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js +182 -165
  539. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js.map +1 -1
  540. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js +89 -76
  541. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js.map +1 -1
  542. package/Meshes/Node/Blocks/conditionBlock.pure.js +184 -169
  543. package/Meshes/Node/Blocks/conditionBlock.pure.js.map +1 -1
  544. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js +270 -255
  545. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js.map +1 -1
  546. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js +172 -159
  547. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js.map +1 -1
  548. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js +230 -217
  549. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js.map +1 -1
  550. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js +256 -245
  551. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js.map +1 -1
  552. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js +206 -189
  553. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js.map +1 -1
  554. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js +166 -153
  555. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js.map +1 -1
  556. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js +221 -208
  557. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js.map +1 -1
  558. package/Meshes/Node/Blocks/mappingBlock.pure.js +150 -137
  559. package/Meshes/Node/Blocks/mappingBlock.pure.js.map +1 -1
  560. package/Meshes/Node/Blocks/mathBlock.pure.js +269 -256
  561. package/Meshes/Node/Blocks/mathBlock.pure.js.map +1 -1
  562. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js +141 -128
  563. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js.map +1 -1
  564. package/Meshes/Node/Blocks/randomBlock.pure.js +161 -148
  565. package/Meshes/Node/Blocks/randomBlock.pure.js.map +1 -1
  566. package/Meshes/Node/Blocks/subdivideBlock.pure.js +102 -87
  567. package/Meshes/Node/Blocks/subdivideBlock.pure.js.map +1 -1
  568. package/Meshes/Node/nodeGeometry.js +560 -538
  569. package/Meshes/Node/nodeGeometry.js.map +1 -1
  570. package/Meshes/Node/nodeGeometryBlock.js +473 -458
  571. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  572. package/Meshes/abstractMesh.pure.js +2218 -2207
  573. package/Meshes/abstractMesh.pure.js.map +1 -1
  574. package/Meshes/geometry.js +30 -15
  575. package/Meshes/geometry.js.map +1 -1
  576. package/Meshes/mesh.pure.js +26 -14
  577. package/Meshes/mesh.pure.js.map +1 -1
  578. package/Meshes/mesh.vertexData.js +1665 -1655
  579. package/Meshes/mesh.vertexData.js.map +1 -1
  580. package/Meshes/transformNode.pure.js +1400 -1372
  581. package/Meshes/transformNode.pure.js.map +1 -1
  582. package/Misc/decorators.d.ts +34 -19
  583. package/Misc/decorators.functions.d.ts +33 -2
  584. package/Misc/decorators.functions.js +114 -35
  585. package/Misc/decorators.functions.js.map +1 -1
  586. package/Misc/decorators.js +96 -68
  587. package/Misc/decorators.js.map +1 -1
  588. package/Misc/decorators.serialization.js +47 -40
  589. package/Misc/decorators.serialization.js.map +1 -1
  590. package/Misc/decorators.serializationUtilities.d.ts +24 -0
  591. package/Misc/decorators.serializationUtilities.js +20 -0
  592. package/Misc/decorators.serializationUtilities.js.map +1 -0
  593. package/Misc/dumpTools.pure.js +43 -33
  594. package/Misc/dumpTools.pure.js.map +1 -1
  595. package/Misc/fileTools.pure.js +8 -0
  596. package/Misc/fileTools.pure.js.map +1 -1
  597. package/Misc/observable.pure.js +0 -7
  598. package/Misc/observable.pure.js.map +1 -1
  599. package/Misc/snapshotRenderingHelper.d.ts +4 -1
  600. package/Misc/snapshotRenderingHelper.js.map +1 -1
  601. package/Misc/symbolMetadataPolyfill.d.ts +11 -0
  602. package/Misc/symbolMetadataPolyfill.js +22 -0
  603. package/Misc/symbolMetadataPolyfill.js.map +1 -0
  604. package/Misc/tools.pure.js +2 -2
  605. package/Misc/tools.pure.js.map +1 -1
  606. package/Morph/morphTarget.js +382 -365
  607. package/Morph/morphTarget.js.map +1 -1
  608. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js +160 -145
  609. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js.map +1 -1
  610. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js +187 -174
  611. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js.map +1 -1
  612. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js +238 -219
  613. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js.map +1 -1
  614. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js +140 -115
  615. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js.map +1 -1
  616. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js +157 -144
  617. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js.map +1 -1
  618. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js +133 -119
  619. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js.map +1 -1
  620. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js +93 -80
  621. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js.map +1 -1
  622. package/Particles/Node/Blocks/particleDebugBlock.pure.js +117 -105
  623. package/Particles/Node/Blocks/particleDebugBlock.pure.js.map +1 -1
  624. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js +105 -92
  625. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js.map +1 -1
  626. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js +82 -69
  627. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js.map +1 -1
  628. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js +113 -101
  629. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js.map +1 -1
  630. package/Particles/Node/Blocks/particleMathBlock.pure.js +278 -265
  631. package/Particles/Node/Blocks/particleMathBlock.pure.js.map +1 -1
  632. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js +155 -142
  633. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js.map +1 -1
  634. package/Particles/Node/Blocks/particleRandomBlock.pure.js +156 -143
  635. package/Particles/Node/Blocks/particleRandomBlock.pure.js.map +1 -1
  636. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js +217 -204
  637. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js.map +1 -1
  638. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js +106 -93
  639. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js.map +1 -1
  640. package/Particles/Node/Blocks/systemBlock.pure.js +366 -330
  641. package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
  642. package/Particles/Node/nodeParticleBlock.js +339 -324
  643. package/Particles/Node/nodeParticleBlock.js.map +1 -1
  644. package/Particles/Node/nodeParticleSystemSet.js +494 -473
  645. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  646. package/Particles/gpuParticleSystem.d.ts +0 -1
  647. package/Particles/gpuParticleSystem.js +0 -1
  648. package/Particles/gpuParticleSystem.js.map +1 -1
  649. package/Particles/gpuParticleSystem.pure.d.ts +4 -3
  650. package/Particles/gpuParticleSystem.pure.js +27 -16
  651. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  652. package/Particles/particleSystem.pure.js +57 -2
  653. package/Particles/particleSystem.pure.js.map +1 -1
  654. package/Particles/thinParticleSystem.d.ts +0 -1
  655. package/Particles/thinParticleSystem.js +0 -1
  656. package/Particles/thinParticleSystem.js.map +1 -1
  657. package/Particles/thinParticleSystem.pure.js +2 -0
  658. package/Particles/thinParticleSystem.pure.js.map +1 -1
  659. package/Particles/webgl2ParticleSystem.pure.js +2 -0
  660. package/Particles/webgl2ParticleSystem.pure.js.map +1 -1
  661. package/Physics/v1/physicsImpostor.pure.js +4 -4
  662. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js +675 -656
  663. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js.map +1 -1
  664. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.d.ts +0 -1
  665. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +0 -1
  666. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
  667. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js +521 -486
  668. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js.map +1 -1
  669. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +0 -1
  670. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +0 -1
  671. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  672. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js +241 -220
  673. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
  674. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js +852 -835
  675. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js.map +1 -1
  676. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js +1135 -1073
  677. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js.map +1 -1
  678. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js +319 -303
  679. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js.map +1 -1
  680. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +212 -199
  681. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  682. package/PostProcesses/blackAndWhitePostProcess.pure.js +67 -55
  683. package/PostProcesses/blackAndWhitePostProcess.pure.js.map +1 -1
  684. package/PostProcesses/bloomMergePostProcess.pure.js +74 -62
  685. package/PostProcesses/bloomMergePostProcess.pure.js.map +1 -1
  686. package/PostProcesses/blurPostProcess.pure.js +127 -115
  687. package/PostProcesses/blurPostProcess.pure.js.map +1 -1
  688. package/PostProcesses/chromaticAberrationPostProcess.pure.js +130 -118
  689. package/PostProcesses/chromaticAberrationPostProcess.pure.js.map +1 -1
  690. package/PostProcesses/circleOfConfusionPostProcess.pure.js +115 -104
  691. package/PostProcesses/circleOfConfusionPostProcess.pure.js.map +1 -1
  692. package/PostProcesses/colorCorrectionPostProcess.pure.js +55 -43
  693. package/PostProcesses/colorCorrectionPostProcess.pure.js.map +1 -1
  694. package/PostProcesses/convolutionPostProcess.pure.js +96 -84
  695. package/PostProcesses/convolutionPostProcess.pure.js.map +1 -1
  696. package/PostProcesses/extractHighlightsPostProcess.pure.js +68 -57
  697. package/PostProcesses/extractHighlightsPostProcess.pure.js.map +1 -1
  698. package/PostProcesses/filterPostProcess.pure.js +66 -54
  699. package/PostProcesses/filterPostProcess.pure.js.map +1 -1
  700. package/PostProcesses/fxaaPostProcess.pure.js.map +1 -1
  701. package/PostProcesses/grainPostProcess.pure.js +82 -70
  702. package/PostProcesses/grainPostProcess.pure.js.map +1 -1
  703. package/PostProcesses/imageProcessingPostProcess.js +334 -322
  704. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  705. package/PostProcesses/motionBlurPostProcess.pure.js +246 -235
  706. package/PostProcesses/motionBlurPostProcess.pure.js.map +1 -1
  707. package/PostProcesses/passPostProcess.pure.js +75 -63
  708. package/PostProcesses/passPostProcess.pure.js.map +1 -1
  709. package/PostProcesses/postProcess.pure.js +899 -835
  710. package/PostProcesses/postProcess.pure.js.map +1 -1
  711. package/PostProcesses/refractionPostProcess.pure.js +114 -87
  712. package/PostProcesses/refractionPostProcess.pure.js.map +1 -1
  713. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js +108 -96
  714. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js.map +1 -1
  715. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js +241 -220
  716. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js.map +1 -1
  717. package/PostProcesses/sharpenPostProcess.pure.js +86 -74
  718. package/PostProcesses/sharpenPostProcess.pure.js.map +1 -1
  719. package/PostProcesses/tonemapPostProcess.pure.js +82 -70
  720. package/PostProcesses/tonemapPostProcess.pure.js.map +1 -1
  721. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +500 -465
  722. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
  723. package/PostProcesses/vrMultiviewToSingleviewPostProcess.d.ts +0 -1
  724. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +0 -1
  725. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  726. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js +2 -0
  727. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js.map +1 -1
  728. package/Probes/reflectionProbe.pure.js +238 -224
  729. package/Probes/reflectionProbe.pure.js.map +1 -1
  730. package/Rendering/GlobalIllumination/giRSMManager.pure.d.ts +1 -1
  731. package/Rendering/GlobalIllumination/giRSMManager.pure.js +138 -105
  732. package/Rendering/GlobalIllumination/giRSMManager.pure.js.map +1 -1
  733. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.d.ts +1 -1
  734. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js +155 -138
  735. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js.map +1 -1
  736. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +0 -2
  737. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +0 -2
  738. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  739. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +5 -0
  740. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  741. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +0 -1
  742. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +0 -1
  743. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  744. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +1 -0
  745. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +34 -0
  746. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  747. package/Rendering/edgesRenderer.pure.js.map +1 -1
  748. package/Rendering/prePassRenderer.d.ts +0 -2
  749. package/Rendering/prePassRenderer.js +0 -2
  750. package/Rendering/prePassRenderer.js.map +1 -1
  751. package/Rendering/prePassRenderer.pure.js +2 -0
  752. package/Rendering/prePassRenderer.pure.js.map +1 -1
  753. package/Rendering/reflectiveShadowMap.pure.d.ts +1 -1
  754. package/Rendering/reflectiveShadowMap.pure.js +151 -130
  755. package/Rendering/reflectiveShadowMap.pure.js.map +1 -1
  756. package/Rendering/thinDepthPeelingRenderer.d.ts +0 -1
  757. package/Rendering/thinDepthPeelingRenderer.js +0 -1
  758. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  759. package/Shaders/ShadersInclude/gaussianSplatting.js +1 -0
  760. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  761. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +35 -5
  762. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  763. package/Shaders/gaussianSplatting.fragment.js +17 -1
  764. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  765. package/Shaders/gaussianSplatting.vertex.js +1 -1
  766. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  767. package/Shaders/gaussianSplattingDepth.vertex.js +1 -1
  768. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  769. package/Shaders/picking.fragment.js +39 -3
  770. package/Shaders/picking.fragment.js.map +1 -1
  771. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +3 -1
  772. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  773. package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
  774. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  775. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +39 -7
  776. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  777. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +4 -3
  778. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  779. package/ShadersWGSL/gaussianSplatting.fragment.js +14 -1
  780. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
  781. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
  782. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  783. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  784. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  785. package/ShadersWGSL/lightingVolume.compute.js +2 -2
  786. package/ShadersWGSL/lightingVolume.compute.js.map +1 -1
  787. package/ShadersWGSL/picking.fragment.js +22 -1
  788. package/ShadersWGSL/picking.fragment.js.map +1 -1
  789. package/XR/features/Layers/WebXRCompositionLayer.d.ts +3 -2
  790. package/XR/features/Layers/WebXRCompositionLayer.js +2 -2
  791. package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
  792. package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +59 -0
  793. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +120 -0
  794. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -0
  795. package/XR/features/Layers/WebXRWebGPUProjectionLayer.d.ts +25 -0
  796. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js +69 -0
  797. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js.map +1 -0
  798. package/XR/features/WebXRLayers.pure.d.ts +8 -0
  799. package/XR/features/WebXRLayers.pure.js +43 -6
  800. package/XR/features/WebXRLayers.pure.js.map +1 -1
  801. package/XR/native/nativeXRRenderTarget.d.ts +2 -2
  802. package/XR/native/nativeXRRenderTarget.js +2 -2
  803. package/XR/native/nativeXRRenderTarget.js.map +1 -1
  804. package/XR/webXRExperienceHelper.js +10 -1
  805. package/XR/webXRExperienceHelper.js.map +1 -1
  806. package/XR/webXRGraphicsBinding.d.ts +90 -0
  807. package/XR/webXRGraphicsBinding.js +85 -0
  808. package/XR/webXRGraphicsBinding.js.map +1 -0
  809. package/XR/webXRLayerRenderTargetTexture.d.ts +24 -0
  810. package/XR/webXRLayerRenderTargetTexture.js +30 -0
  811. package/XR/webXRLayerRenderTargetTexture.js.map +1 -0
  812. package/XR/webXRManagedOutputCanvas.d.ts +14 -0
  813. package/XR/webXRManagedOutputCanvas.js +24 -5
  814. package/XR/webXRManagedOutputCanvas.js.map +1 -1
  815. package/XR/webXRRenderTargetTextureProvider.d.ts +25 -4
  816. package/XR/webXRRenderTargetTextureProvider.js +33 -35
  817. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  818. package/XR/webXRSessionManager.d.ts +11 -0
  819. package/XR/webXRSessionManager.js +37 -0
  820. package/XR/webXRSessionManager.js.map +1 -1
  821. package/XR/webXRTypes.d.ts +9 -6
  822. package/XR/webXRTypes.js.map +1 -1
  823. package/XR/webXRWebGLLayer.d.ts +2 -2
  824. package/XR/webXRWebGLLayer.js +2 -2
  825. package/XR/webXRWebGLLayer.js.map +1 -1
  826. package/XR/webXRWebGLRenderTargetTextureProvider.d.ts +12 -0
  827. package/XR/webXRWebGLRenderTargetTextureProvider.js +58 -0
  828. package/XR/webXRWebGLRenderTargetTextureProvider.js.map +1 -0
  829. package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +69 -0
  830. package/XR/webXRWebGPURenderTargetTextureProvider.js +148 -0
  831. package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -0
  832. package/index.d.ts +1 -0
  833. package/index.js +1 -0
  834. package/index.js.map +1 -1
  835. package/node.js +878 -845
  836. package/node.js.map +1 -1
  837. package/package.json +8 -14
  838. package/scene.pure.d.ts +12 -0
  839. package/scene.pure.js +36 -0
  840. package/scene.pure.js.map +1 -1
  841. package/tslib.es6.js +304 -150
@@ -1,6 +1,6 @@
1
1
  /** This file must only contain pure code and pure imports */
2
2
  var _a, _b, _c, _d;
3
- import { __decorate } from "../tslib.es6.js";
3
+ import { __esDecorate, __runInitializers } from "../tslib.es6.js";
4
4
  import { serialize, serializeAsVector3, serializeAsQuaternion } from "../Misc/decorators.js";
5
5
  import { SerializationHelper } from "../Misc/decorators.serialization.js";
6
6
  import { Observable } from "../Misc/observable.pure.js";
@@ -11,1420 +11,1448 @@ import { GetClass } from "../Misc/typeStore.js";
11
11
  * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
12
12
  * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/parent_pivot/transform_node
13
13
  */
14
- export class TransformNode extends Node {
15
- /**
16
- * Gets or sets the billboard mode. Default is 0.
17
- *
18
- * | Value | Type | Description |
19
- * | --- | --- | --- |
20
- * | 0 | BILLBOARDMODE_NONE | |
21
- * | 1 | BILLBOARDMODE_X | |
22
- * | 2 | BILLBOARDMODE_Y | |
23
- * | 4 | BILLBOARDMODE_Z | |
24
- * | 7 | BILLBOARDMODE_ALL | |
25
- *
26
- */
27
- get billboardMode() {
28
- return this._billboardMode;
29
- }
30
- set billboardMode(value) {
31
- if (this._billboardMode === value) {
32
- return;
33
- }
34
- this._billboardMode = value;
35
- this._cache.useBillboardPosition = (this._billboardMode & TransformNode.BILLBOARDMODE_USE_POSITION) !== 0;
36
- }
37
- /**
38
- * Gets or sets the distance of the object to max, often used by skybox
39
- */
40
- get infiniteDistance() {
41
- return this._infiniteDistance;
42
- }
43
- set infiniteDistance(value) {
44
- if (this._infiniteDistance === value) {
45
- return;
46
- }
47
- this._infiniteDistance = value;
48
- }
49
- /** @internal */
50
- constructor(name, scene = null, isPure = true) {
51
- super(name, scene, false);
52
- this._forward = new Vector3(0, 0, 1);
53
- this._up = new Vector3(0, 1, 0);
54
- this._right = new Vector3(1, 0, 0);
55
- // Properties
56
- this._position = Vector3.Zero();
57
- this._rotation = Vector3.Zero();
58
- this._rotationQuaternion = null;
59
- this._scaling = Vector3.One();
60
- this._transformToBoneReferal = null;
61
- this._isAbsoluteSynced = false;
62
- this._billboardMode = TransformNode.BILLBOARDMODE_NONE;
63
- /**
64
- * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
65
- */
66
- this.scalingDeterminant = 1;
67
- this._infiniteDistance = false;
68
- /**
69
- * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
70
- * By default the system will update normals to compensate
71
- */
72
- this.ignoreNonUniformScaling = false;
73
- /**
74
- * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
75
- */
76
- this.reIntegrateRotationIntoRotationQuaternion = false;
77
- // Cache
78
- /** @internal */
79
- this._poseMatrix = null;
80
- /** @internal */
81
- this._localMatrix = Matrix.Zero();
82
- this._usePivotMatrix = false;
83
- this._absolutePosition = Vector3.Zero();
84
- this._absoluteScaling = Vector3.Zero();
85
- this._absoluteRotationQuaternion = Quaternion.Identity();
86
- this._pivotMatrix = Matrix.Identity();
87
- /** @internal */
88
- this._eulerCacheRotation = new Vector3(0, 0, 0, (res, vector) => {
89
- if (this._rotationQuaternion) {
90
- if ("x" in res) {
91
- vector._x = res.x;
92
- }
93
- if ("y" in res) {
94
- vector._y = res.y;
95
- }
96
- if ("z" in res) {
97
- vector._z = res.z;
98
- }
99
- Quaternion.FromEulerVectorToRef(vector, this._rotationQuaternion);
14
+ let TransformNode = (() => {
15
+ var _a;
16
+ let _classSuper = Node;
17
+ let __position_decorators;
18
+ let __position_initializers = [];
19
+ let __position_extraInitializers = [];
20
+ let __rotation_decorators;
21
+ let __rotation_initializers = [];
22
+ let __rotation_extraInitializers = [];
23
+ let __rotationQuaternion_decorators;
24
+ let __rotationQuaternion_initializers = [];
25
+ let __rotationQuaternion_extraInitializers = [];
26
+ let __scaling_decorators;
27
+ let __scaling_initializers = [];
28
+ let __scaling_extraInitializers = [];
29
+ let __billboardMode_decorators;
30
+ let __billboardMode_initializers = [];
31
+ let __billboardMode_extraInitializers = [];
32
+ let _scalingDeterminant_decorators;
33
+ let _scalingDeterminant_initializers = [];
34
+ let _scalingDeterminant_extraInitializers = [];
35
+ let __infiniteDistance_decorators;
36
+ let __infiniteDistance_initializers = [];
37
+ let __infiniteDistance_extraInitializers = [];
38
+ let _ignoreNonUniformScaling_decorators;
39
+ let _ignoreNonUniformScaling_initializers = [];
40
+ let _ignoreNonUniformScaling_extraInitializers = [];
41
+ let _reIntegrateRotationIntoRotationQuaternion_decorators;
42
+ let _reIntegrateRotationIntoRotationQuaternion_initializers = [];
43
+ let _reIntegrateRotationIntoRotationQuaternion_extraInitializers = [];
44
+ return _a = class TransformNode extends _classSuper {
45
+ /**
46
+ * Gets or sets the billboard mode. Default is 0.
47
+ *
48
+ * | Value | Type | Description |
49
+ * | --- | --- | --- |
50
+ * | 0 | BILLBOARDMODE_NONE | |
51
+ * | 1 | BILLBOARDMODE_X | |
52
+ * | 2 | BILLBOARDMODE_Y | |
53
+ * | 4 | BILLBOARDMODE_Z | |
54
+ * | 7 | BILLBOARDMODE_ALL | |
55
+ *
56
+ */
57
+ get billboardMode() {
58
+ return this._billboardMode;
59
+ }
60
+ set billboardMode(value) {
61
+ if (this._billboardMode === value) {
62
+ return;
63
+ }
64
+ this._billboardMode = value;
65
+ this._cache.useBillboardPosition = (this._billboardMode & _a.BILLBOARDMODE_USE_POSITION) !== 0;
66
+ }
67
+ /**
68
+ * Gets or sets the distance of the object to max, often used by skybox
69
+ */
70
+ get infiniteDistance() {
71
+ return this._infiniteDistance;
72
+ }
73
+ set infiniteDistance(value) {
74
+ if (this._infiniteDistance === value) {
75
+ return;
76
+ }
77
+ this._infiniteDistance = value;
78
+ }
79
+ /** @internal */
80
+ constructor(name, scene = null, isPure = true) {
81
+ super(name, scene, false);
82
+ this._forward = new Vector3(0, 0, 1);
83
+ this._up = new Vector3(0, 1, 0);
84
+ this._right = new Vector3(1, 0, 0);
85
+ // Properties
86
+ this._position = __runInitializers(this, __position_initializers, Vector3.Zero());
87
+ this._rotation = (__runInitializers(this, __position_extraInitializers), __runInitializers(this, __rotation_initializers, Vector3.Zero()));
88
+ this._rotationQuaternion = (__runInitializers(this, __rotation_extraInitializers), __runInitializers(this, __rotationQuaternion_initializers, null));
89
+ this._scaling = (__runInitializers(this, __rotationQuaternion_extraInitializers), __runInitializers(this, __scaling_initializers, Vector3.One()));
90
+ this._transformToBoneReferal = (__runInitializers(this, __scaling_extraInitializers), null);
91
+ this._isAbsoluteSynced = false;
92
+ this._billboardMode = __runInitializers(this, __billboardMode_initializers, _a.BILLBOARDMODE_NONE);
93
+ /**
94
+ * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
95
+ */
96
+ this.scalingDeterminant = (__runInitializers(this, __billboardMode_extraInitializers), __runInitializers(this, _scalingDeterminant_initializers, 1));
97
+ this._infiniteDistance = (__runInitializers(this, _scalingDeterminant_extraInitializers), __runInitializers(this, __infiniteDistance_initializers, false));
98
+ /**
99
+ * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
100
+ * By default the system will update normals to compensate
101
+ */
102
+ this.ignoreNonUniformScaling = (__runInitializers(this, __infiniteDistance_extraInitializers), __runInitializers(this, _ignoreNonUniformScaling_initializers, false));
103
+ /**
104
+ * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
105
+ */
106
+ this.reIntegrateRotationIntoRotationQuaternion = (__runInitializers(this, _ignoreNonUniformScaling_extraInitializers), __runInitializers(this, _reIntegrateRotationIntoRotationQuaternion_initializers, false));
107
+ // Cache
108
+ /** @internal */
109
+ this._poseMatrix = (__runInitializers(this, _reIntegrateRotationIntoRotationQuaternion_extraInitializers), null);
110
+ /** @internal */
111
+ this._localMatrix = Matrix.Zero();
112
+ this._usePivotMatrix = false;
113
+ this._absolutePosition = Vector3.Zero();
114
+ this._absoluteScaling = Vector3.Zero();
115
+ this._absoluteRotationQuaternion = Quaternion.Identity();
116
+ this._pivotMatrix = Matrix.Identity();
117
+ /** @internal */
118
+ this._eulerCacheRotation = new Vector3(0, 0, 0, (res, vector) => {
119
+ if (this._rotationQuaternion) {
120
+ if ("x" in res) {
121
+ vector._x = res.x;
122
+ }
123
+ if ("y" in res) {
124
+ vector._y = res.y;
125
+ }
126
+ if ("z" in res) {
127
+ vector._z = res.z;
128
+ }
129
+ Quaternion.FromEulerVectorToRef(vector, this._rotationQuaternion);
130
+ return true;
131
+ }
132
+ return false;
133
+ });
134
+ /** @internal */
135
+ this._postMultiplyPivotMatrix = false;
136
+ this._isWorldMatrixFrozen = false;
137
+ /** @internal */
138
+ this._indexInSceneTransformNodesArray = -1;
139
+ /**
140
+ * An event triggered after the world matrix is updated
141
+ */
142
+ this.onAfterWorldMatrixUpdateObservable = new Observable();
143
+ this._nonUniformScaling = false;
144
+ if (isPure) {
145
+ this.getScene().addTransformNode(this);
146
+ }
147
+ }
148
+ /**
149
+ * Gets a string identifying the name of the class
150
+ * @returns "TransformNode" string
151
+ */
152
+ getClassName() {
153
+ return "TransformNode";
154
+ }
155
+ /**
156
+ * Gets or set the node position (default is (0.0, 0.0, 0.0))
157
+ */
158
+ get position() {
159
+ return this._position;
160
+ }
161
+ set position(newPosition) {
162
+ this._position = newPosition;
163
+ this._markAsDirtyInternal();
164
+ }
165
+ /**
166
+ * return true if a pivot has been set
167
+ * @returns true if a pivot matrix is used
168
+ */
169
+ isUsingPivotMatrix() {
170
+ return this._usePivotMatrix;
171
+ }
172
+ /**
173
+ * @returns true if pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect.
174
+ */
175
+ isUsingPostMultiplyPivotMatrix() {
176
+ return this._postMultiplyPivotMatrix;
177
+ }
178
+ /**
179
+ * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
180
+ * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
181
+ */
182
+ get rotation() {
183
+ if (this._rotationQuaternion) {
184
+ this._rotationQuaternion.toEulerAnglesToRef(this._eulerCacheRotation);
185
+ return this._eulerCacheRotation;
186
+ }
187
+ return this._rotation;
188
+ }
189
+ set rotation(newRotation) {
190
+ if (this._rotationQuaternion) {
191
+ Quaternion.FromEulerVectorToRef(newRotation, this._rotationQuaternion);
192
+ this._eulerCacheRotation.copyFrom(newRotation);
193
+ return;
194
+ }
195
+ this._rotation = newRotation;
196
+ this._rotationQuaternion = null;
197
+ this._markAsDirtyInternal();
198
+ }
199
+ /**
200
+ * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (1.0, 1.0, 1.0)).
201
+ */
202
+ get scaling() {
203
+ return this._scaling;
204
+ }
205
+ set scaling(newScaling) {
206
+ this._scaling = newScaling;
207
+ this._markAsDirtyInternal();
208
+ }
209
+ /**
210
+ * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
211
+ * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
212
+ */
213
+ get rotationQuaternion() {
214
+ return this._rotationQuaternion;
215
+ }
216
+ set rotationQuaternion(quaternion) {
217
+ this._rotationQuaternion = quaternion;
218
+ //reset the rotation vector.
219
+ if (quaternion) {
220
+ this._rotation.setAll(0.0);
221
+ quaternion.toEulerAnglesToRef(this._eulerCacheRotation);
222
+ this._eulerCacheRotation._isDirty = false;
223
+ }
224
+ this._markAsDirtyInternal();
225
+ }
226
+ _markAsDirtyInternal() {
227
+ if (this._isDirty) {
228
+ return;
229
+ }
230
+ this._isDirty = true;
231
+ if (this.customMarkAsDirty) {
232
+ this.customMarkAsDirty();
233
+ }
234
+ }
235
+ /**
236
+ * The forward direction of that transform in world space.
237
+ */
238
+ get forward() {
239
+ Vector3.TransformNormalFromFloatsToRef(0, 0, this.getScene().useRightHandedSystem ? -1.0 : 1.0, this.getWorldMatrix(), this._forward);
240
+ return this._forward.normalize();
241
+ }
242
+ /**
243
+ * The up direction of that transform in world space.
244
+ */
245
+ get up() {
246
+ Vector3.TransformNormalFromFloatsToRef(0, 1, 0, this.getWorldMatrix(), this._up);
247
+ return this._up.normalize();
248
+ }
249
+ /**
250
+ * The right direction of that transform in world space.
251
+ */
252
+ get right() {
253
+ Vector3.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem ? -1.0 : 1.0, 0, 0, this.getWorldMatrix(), this._right);
254
+ return this._right.normalize();
255
+ }
256
+ /**
257
+ * Copies the parameter passed Matrix into the mesh Pose matrix.
258
+ * @param matrix the matrix to copy the pose from
259
+ * @returns this TransformNode.
260
+ */
261
+ updatePoseMatrix(matrix) {
262
+ if (!this._poseMatrix) {
263
+ this._poseMatrix = matrix.clone();
264
+ return this;
265
+ }
266
+ this._poseMatrix.copyFrom(matrix);
267
+ return this;
268
+ }
269
+ /**
270
+ * Returns the mesh Pose matrix.
271
+ * @returns the pose matrix
272
+ */
273
+ getPoseMatrix() {
274
+ if (!this._poseMatrix) {
275
+ this._poseMatrix = Matrix.Identity();
276
+ }
277
+ return this._poseMatrix;
278
+ }
279
+ /** @internal */
280
+ _isSynchronized() {
281
+ const cache = this._cache;
282
+ if (this._billboardMode !== cache.billboardMode || this._billboardMode !== _a.BILLBOARDMODE_NONE) {
283
+ return false;
284
+ }
285
+ if (cache.pivotMatrixUpdated) {
286
+ return false;
287
+ }
288
+ if (this._infiniteDistance) {
289
+ return false;
290
+ }
291
+ if (this._position._isDirty) {
292
+ return false;
293
+ }
294
+ if (this._scaling._isDirty) {
295
+ return false;
296
+ }
297
+ if ((this._rotationQuaternion && this._rotationQuaternion._isDirty) || this._rotation._isDirty) {
298
+ return false;
299
+ }
100
300
  return true;
101
301
  }
102
- return false;
103
- });
104
- /** @internal */
105
- this._postMultiplyPivotMatrix = false;
106
- this._isWorldMatrixFrozen = false;
107
- /** @internal */
108
- this._indexInSceneTransformNodesArray = -1;
109
- /**
110
- * An event triggered after the world matrix is updated
111
- */
112
- this.onAfterWorldMatrixUpdateObservable = new Observable();
113
- this._nonUniformScaling = false;
114
- if (isPure) {
115
- this.getScene().addTransformNode(this);
116
- }
117
- }
118
- /**
119
- * Gets a string identifying the name of the class
120
- * @returns "TransformNode" string
121
- */
122
- getClassName() {
123
- return "TransformNode";
124
- }
125
- /**
126
- * Gets or set the node position (default is (0.0, 0.0, 0.0))
127
- */
128
- get position() {
129
- return this._position;
130
- }
131
- set position(newPosition) {
132
- this._position = newPosition;
133
- this._markAsDirtyInternal();
134
- }
135
- /**
136
- * return true if a pivot has been set
137
- * @returns true if a pivot matrix is used
138
- */
139
- isUsingPivotMatrix() {
140
- return this._usePivotMatrix;
141
- }
142
- /**
143
- * @returns true if pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect.
144
- */
145
- isUsingPostMultiplyPivotMatrix() {
146
- return this._postMultiplyPivotMatrix;
147
- }
148
- /**
149
- * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
150
- * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
151
- */
152
- get rotation() {
153
- if (this._rotationQuaternion) {
154
- this._rotationQuaternion.toEulerAnglesToRef(this._eulerCacheRotation);
155
- return this._eulerCacheRotation;
156
- }
157
- return this._rotation;
158
- }
159
- set rotation(newRotation) {
160
- if (this._rotationQuaternion) {
161
- Quaternion.FromEulerVectorToRef(newRotation, this._rotationQuaternion);
162
- this._eulerCacheRotation.copyFrom(newRotation);
163
- return;
164
- }
165
- this._rotation = newRotation;
166
- this._rotationQuaternion = null;
167
- this._markAsDirtyInternal();
168
- }
169
- /**
170
- * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (1.0, 1.0, 1.0)).
171
- */
172
- get scaling() {
173
- return this._scaling;
174
- }
175
- set scaling(newScaling) {
176
- this._scaling = newScaling;
177
- this._markAsDirtyInternal();
178
- }
179
- /**
180
- * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
181
- * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
182
- */
183
- get rotationQuaternion() {
184
- return this._rotationQuaternion;
185
- }
186
- set rotationQuaternion(quaternion) {
187
- this._rotationQuaternion = quaternion;
188
- //reset the rotation vector.
189
- if (quaternion) {
190
- this._rotation.setAll(0.0);
191
- quaternion.toEulerAnglesToRef(this._eulerCacheRotation);
192
- this._eulerCacheRotation._isDirty = false;
193
- }
194
- this._markAsDirtyInternal();
195
- }
196
- _markAsDirtyInternal() {
197
- if (this._isDirty) {
198
- return;
199
- }
200
- this._isDirty = true;
201
- if (this.customMarkAsDirty) {
202
- this.customMarkAsDirty();
203
- }
204
- }
205
- /**
206
- * The forward direction of that transform in world space.
207
- */
208
- get forward() {
209
- Vector3.TransformNormalFromFloatsToRef(0, 0, this.getScene().useRightHandedSystem ? -1.0 : 1.0, this.getWorldMatrix(), this._forward);
210
- return this._forward.normalize();
211
- }
212
- /**
213
- * The up direction of that transform in world space.
214
- */
215
- get up() {
216
- Vector3.TransformNormalFromFloatsToRef(0, 1, 0, this.getWorldMatrix(), this._up);
217
- return this._up.normalize();
218
- }
219
- /**
220
- * The right direction of that transform in world space.
221
- */
222
- get right() {
223
- Vector3.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem ? -1.0 : 1.0, 0, 0, this.getWorldMatrix(), this._right);
224
- return this._right.normalize();
225
- }
226
- /**
227
- * Copies the parameter passed Matrix into the mesh Pose matrix.
228
- * @param matrix the matrix to copy the pose from
229
- * @returns this TransformNode.
230
- */
231
- updatePoseMatrix(matrix) {
232
- if (!this._poseMatrix) {
233
- this._poseMatrix = matrix.clone();
234
- return this;
235
- }
236
- this._poseMatrix.copyFrom(matrix);
237
- return this;
238
- }
239
- /**
240
- * Returns the mesh Pose matrix.
241
- * @returns the pose matrix
242
- */
243
- getPoseMatrix() {
244
- if (!this._poseMatrix) {
245
- this._poseMatrix = Matrix.Identity();
246
- }
247
- return this._poseMatrix;
248
- }
249
- /** @internal */
250
- _isSynchronized() {
251
- const cache = this._cache;
252
- if (this._billboardMode !== cache.billboardMode || this._billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
253
- return false;
254
- }
255
- if (cache.pivotMatrixUpdated) {
256
- return false;
257
- }
258
- if (this._infiniteDistance) {
259
- return false;
260
- }
261
- if (this._position._isDirty) {
262
- return false;
263
- }
264
- if (this._scaling._isDirty) {
265
- return false;
266
- }
267
- if ((this._rotationQuaternion && this._rotationQuaternion._isDirty) || this._rotation._isDirty) {
268
- return false;
269
- }
270
- return true;
271
- }
272
- /** @internal */
273
- _initCache() {
274
- super._initCache();
275
- const cache = this._cache;
276
- cache.localMatrixUpdated = false;
277
- cache.billboardMode = -1;
278
- cache.infiniteDistance = false;
279
- cache.useBillboardPosition = false;
280
- }
281
- /**
282
- * Returns the current mesh absolute position.
283
- * Returns a Vector3.
284
- */
285
- get absolutePosition() {
286
- return this.getAbsolutePosition();
287
- }
288
- /**
289
- * Returns the current mesh absolute scaling.
290
- * Returns a Vector3.
291
- */
292
- get absoluteScaling() {
293
- this._syncAbsoluteScalingAndRotation();
294
- return this._absoluteScaling;
295
- }
296
- /**
297
- * Returns the current mesh absolute rotation.
298
- * Returns a Quaternion.
299
- */
300
- get absoluteRotationQuaternion() {
301
- this._syncAbsoluteScalingAndRotation();
302
- return this._absoluteRotationQuaternion;
303
- }
304
- /**
305
- * Sets a new matrix to apply before all other transformation
306
- * @param matrix defines the transform matrix
307
- * @returns the current TransformNode
308
- */
309
- setPreTransformMatrix(matrix) {
310
- return this.setPivotMatrix(matrix, false);
311
- }
312
- /**
313
- * Sets a new pivot matrix to the current node
314
- * @param matrix defines the new pivot matrix to use
315
- * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
316
- * @returns the current TransformNode
317
- */
318
- setPivotMatrix(matrix, postMultiplyPivotMatrix = true) {
319
- this._pivotMatrix.copyFrom(matrix);
320
- this._usePivotMatrix = !this._pivotMatrix.isIdentity();
321
- this._cache.pivotMatrixUpdated = true;
322
- this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
323
- if (this._postMultiplyPivotMatrix) {
324
- if (!this._pivotMatrixInverse) {
325
- this._pivotMatrixInverse = Matrix.Invert(this._pivotMatrix);
326
- }
327
- else {
328
- this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
302
+ /** @internal */
303
+ _initCache() {
304
+ super._initCache();
305
+ const cache = this._cache;
306
+ cache.localMatrixUpdated = false;
307
+ cache.billboardMode = -1;
308
+ cache.infiniteDistance = false;
309
+ cache.useBillboardPosition = false;
329
310
  }
330
- }
331
- return this;
332
- }
333
- /**
334
- * Returns the mesh pivot matrix.
335
- * Default : Identity.
336
- * @returns the matrix
337
- */
338
- getPivotMatrix() {
339
- return this._pivotMatrix;
340
- }
341
- /**
342
- * Instantiate (when possible) or clone that node with its hierarchy
343
- * @param newParent defines the new parent to use for the instance (or clone)
344
- * @param options defines options to configure how copy is done
345
- * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
346
- * @returns an instance (or a clone) of the current node with its hierarchy
347
- */
348
- instantiateHierarchy(newParent = null, options, onNewNodeCreated) {
349
- const clone = this.clone("Clone of " + (this.name || this.id), newParent || this.parent, true);
350
- if (clone) {
351
- if (onNewNodeCreated) {
352
- onNewNodeCreated(this, clone);
311
+ /**
312
+ * Returns the current mesh absolute position.
313
+ * Returns a Vector3.
314
+ */
315
+ get absolutePosition() {
316
+ return this.getAbsolutePosition();
353
317
  }
354
- }
355
- for (const child of this.getChildTransformNodes(true)) {
356
- child.instantiateHierarchy(clone, options, onNewNodeCreated);
357
- }
358
- return clone;
359
- }
360
- /**
361
- * Prevents the World matrix to be computed any longer.
362
- * Please note that the "moral" contract is that the world matrix is not going to be updated anymore. It is up to the developer to force updates.
363
- * You trade flexibility for performance. If you want to update it, you have to unfreeze it first.
364
- * @param newWorldMatrix defines an optional matrix to use as world matrix
365
- * @param decompose defines whether to decompose the given newWorldMatrix or directly assign
366
- * @returns the TransformNode.
367
- */
368
- freezeWorldMatrix(newWorldMatrix = null, decompose = false) {
369
- if (newWorldMatrix) {
370
- if (decompose) {
371
- this._rotation.setAll(0);
372
- this._rotationQuaternion = this._rotationQuaternion || Quaternion.Identity();
373
- newWorldMatrix.decompose(this._scaling, this._rotationQuaternion, this._position);
318
+ /**
319
+ * Returns the current mesh absolute scaling.
320
+ * Returns a Vector3.
321
+ */
322
+ get absoluteScaling() {
323
+ this._syncAbsoluteScalingAndRotation();
324
+ return this._absoluteScaling;
325
+ }
326
+ /**
327
+ * Returns the current mesh absolute rotation.
328
+ * Returns a Quaternion.
329
+ */
330
+ get absoluteRotationQuaternion() {
331
+ this._syncAbsoluteScalingAndRotation();
332
+ return this._absoluteRotationQuaternion;
333
+ }
334
+ /**
335
+ * Sets a new matrix to apply before all other transformation
336
+ * @param matrix defines the transform matrix
337
+ * @returns the current TransformNode
338
+ */
339
+ setPreTransformMatrix(matrix) {
340
+ return this.setPivotMatrix(matrix, false);
341
+ }
342
+ /**
343
+ * Sets a new pivot matrix to the current node
344
+ * @param matrix defines the new pivot matrix to use
345
+ * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
346
+ * @returns the current TransformNode
347
+ */
348
+ setPivotMatrix(matrix, postMultiplyPivotMatrix = true) {
349
+ this._pivotMatrix.copyFrom(matrix);
350
+ this._usePivotMatrix = !this._pivotMatrix.isIdentity();
351
+ this._cache.pivotMatrixUpdated = true;
352
+ this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
353
+ if (this._postMultiplyPivotMatrix) {
354
+ if (!this._pivotMatrixInverse) {
355
+ this._pivotMatrixInverse = Matrix.Invert(this._pivotMatrix);
356
+ }
357
+ else {
358
+ this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
359
+ }
360
+ }
361
+ return this;
362
+ }
363
+ /**
364
+ * Returns the mesh pivot matrix.
365
+ * Default : Identity.
366
+ * @returns the matrix
367
+ */
368
+ getPivotMatrix() {
369
+ return this._pivotMatrix;
370
+ }
371
+ /**
372
+ * Instantiate (when possible) or clone that node with its hierarchy
373
+ * @param newParent defines the new parent to use for the instance (or clone)
374
+ * @param options defines options to configure how copy is done
375
+ * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
376
+ * @returns an instance (or a clone) of the current node with its hierarchy
377
+ */
378
+ instantiateHierarchy(newParent = null, options, onNewNodeCreated) {
379
+ const clone = this.clone("Clone of " + (this.name || this.id), newParent || this.parent, true);
380
+ if (clone) {
381
+ if (onNewNodeCreated) {
382
+ onNewNodeCreated(this, clone);
383
+ }
384
+ }
385
+ for (const child of this.getChildTransformNodes(true)) {
386
+ child.instantiateHierarchy(clone, options, onNewNodeCreated);
387
+ }
388
+ return clone;
389
+ }
390
+ /**
391
+ * Prevents the World matrix to be computed any longer.
392
+ * Please note that the "moral" contract is that the world matrix is not going to be updated anymore. It is up to the developer to force updates.
393
+ * You trade flexibility for performance. If you want to update it, you have to unfreeze it first.
394
+ * @param newWorldMatrix defines an optional matrix to use as world matrix
395
+ * @param decompose defines whether to decompose the given newWorldMatrix or directly assign
396
+ * @returns the TransformNode.
397
+ */
398
+ freezeWorldMatrix(newWorldMatrix = null, decompose = false) {
399
+ if (newWorldMatrix) {
400
+ if (decompose) {
401
+ this._rotation.setAll(0);
402
+ this._rotationQuaternion = this._rotationQuaternion || Quaternion.Identity();
403
+ newWorldMatrix.decompose(this._scaling, this._rotationQuaternion, this._position);
404
+ this.computeWorldMatrix(true);
405
+ }
406
+ else {
407
+ this._worldMatrix = newWorldMatrix;
408
+ this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
409
+ this._afterComputeWorldMatrix();
410
+ }
411
+ }
412
+ else {
413
+ this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
414
+ this.computeWorldMatrix(true);
415
+ }
416
+ this._isDirty = false;
417
+ this._isWorldMatrixFrozen = true;
418
+ return this;
419
+ }
420
+ /**
421
+ * Allows back the World matrix computation.
422
+ * @returns the TransformNode.
423
+ */
424
+ unfreezeWorldMatrix() {
425
+ this._isWorldMatrixFrozen = false;
374
426
  this.computeWorldMatrix(true);
427
+ return this;
375
428
  }
376
- else {
377
- this._worldMatrix = newWorldMatrix;
378
- this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
379
- this._afterComputeWorldMatrix();
429
+ /**
430
+ * True if the World matrix has been frozen.
431
+ */
432
+ get isWorldMatrixFrozen() {
433
+ return this._isWorldMatrixFrozen;
380
434
  }
381
- }
382
- else {
383
- this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
384
- this.computeWorldMatrix(true);
385
- }
386
- this._isDirty = false;
387
- this._isWorldMatrixFrozen = true;
388
- return this;
389
- }
390
- /**
391
- * Allows back the World matrix computation.
392
- * @returns the TransformNode.
393
- */
394
- unfreezeWorldMatrix() {
395
- this._isWorldMatrixFrozen = false;
396
- this.computeWorldMatrix(true);
397
- return this;
398
- }
399
- /**
400
- * True if the World matrix has been frozen.
401
- */
402
- get isWorldMatrixFrozen() {
403
- return this._isWorldMatrixFrozen;
404
- }
405
- /**
406
- * Returns the mesh absolute position in the World.
407
- * @returns a Vector3.
408
- */
409
- getAbsolutePosition() {
410
- this.computeWorldMatrix();
411
- return this._absolutePosition;
412
- }
413
- /**
414
- * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
415
- * @param absolutePosition the absolute position to set
416
- * @returns the TransformNode.
417
- */
418
- setAbsolutePosition(absolutePosition) {
419
- if (!absolutePosition) {
420
- return this;
421
- }
422
- let absolutePositionX;
423
- let absolutePositionY;
424
- let absolutePositionZ;
425
- if (absolutePosition.x === undefined) {
426
- if (arguments.length < 3) {
435
+ /**
436
+ * Returns the mesh absolute position in the World.
437
+ * @returns a Vector3.
438
+ */
439
+ getAbsolutePosition() {
440
+ this.computeWorldMatrix();
441
+ return this._absolutePosition;
442
+ }
443
+ /**
444
+ * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
445
+ * @param absolutePosition the absolute position to set
446
+ * @returns the TransformNode.
447
+ */
448
+ setAbsolutePosition(absolutePosition) {
449
+ if (!absolutePosition) {
450
+ return this;
451
+ }
452
+ let absolutePositionX;
453
+ let absolutePositionY;
454
+ let absolutePositionZ;
455
+ if (absolutePosition.x === undefined) {
456
+ if (arguments.length < 3) {
457
+ return this;
458
+ }
459
+ absolutePositionX = arguments[0];
460
+ absolutePositionY = arguments[1];
461
+ absolutePositionZ = arguments[2];
462
+ }
463
+ else {
464
+ absolutePositionX = absolutePosition.x;
465
+ absolutePositionY = absolutePosition.y;
466
+ absolutePositionZ = absolutePosition.z;
467
+ }
468
+ if (this.parent) {
469
+ const invertParentWorldMatrix = TmpVectors.Matrix[0];
470
+ this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
471
+ Vector3.TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
472
+ }
473
+ else {
474
+ this.position.x = absolutePositionX;
475
+ this.position.y = absolutePositionY;
476
+ this.position.z = absolutePositionZ;
477
+ }
478
+ this._absolutePosition.copyFrom(absolutePosition);
427
479
  return this;
428
480
  }
429
- absolutePositionX = arguments[0];
430
- absolutePositionY = arguments[1];
431
- absolutePositionZ = arguments[2];
432
- }
433
- else {
434
- absolutePositionX = absolutePosition.x;
435
- absolutePositionY = absolutePosition.y;
436
- absolutePositionZ = absolutePosition.z;
437
- }
438
- if (this.parent) {
439
- const invertParentWorldMatrix = TmpVectors.Matrix[0];
440
- this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
441
- Vector3.TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
442
- }
443
- else {
444
- this.position.x = absolutePositionX;
445
- this.position.y = absolutePositionY;
446
- this.position.z = absolutePositionZ;
447
- }
448
- this._absolutePosition.copyFrom(absolutePosition);
449
- return this;
450
- }
451
- /**
452
- * Sets the mesh position in its local space.
453
- * @param vector3 the position to set in localspace
454
- * @returns the TransformNode.
455
- */
456
- setPositionWithLocalVector(vector3) {
457
- this.computeWorldMatrix();
458
- this.position = Vector3.TransformNormal(vector3, this._localMatrix);
459
- return this;
460
- }
461
- /**
462
- * Returns the mesh position in the local space from the current World matrix values.
463
- * @returns a new Vector3.
464
- */
465
- getPositionExpressedInLocalSpace() {
466
- this.computeWorldMatrix();
467
- const invLocalWorldMatrix = TmpVectors.Matrix[0];
468
- this._localMatrix.invertToRef(invLocalWorldMatrix);
469
- return Vector3.TransformNormal(this.position, invLocalWorldMatrix);
470
- }
471
- /**
472
- * Translates the mesh along the passed Vector3 in its local space.
473
- * @param vector3 the distance to translate in localspace
474
- * @returns the TransformNode.
475
- */
476
- locallyTranslate(vector3) {
477
- this.computeWorldMatrix(true);
478
- this.position = Vector3.TransformCoordinates(vector3, this._localMatrix);
479
- return this;
480
- }
481
- /**
482
- * Orients a mesh towards a target point. Mesh must be drawn facing user.
483
- * @param targetPoint the position (must be in same space as current mesh) to look at
484
- * @param yawCor optional yaw (y-axis) correction in radians
485
- * @param pitchCor optional pitch (x-axis) correction in radians
486
- * @param rollCor optional roll (z-axis) correction in radians
487
- * @param space the chosen space of the target
488
- * @returns the TransformNode.
489
- */
490
- lookAt(targetPoint, yawCor = 0, pitchCor = 0, rollCor = 0, space = 0 /* Space.LOCAL */) {
491
- const dv = TransformNode._LookAtVectorCache;
492
- const pos = space === 0 /* Space.LOCAL */ ? this.position : this.getAbsolutePosition();
493
- targetPoint.subtractToRef(pos, dv);
494
- this.setDirection(dv, yawCor, pitchCor, rollCor);
495
- // Correct for parent's rotation offset
496
- if (space === 1 /* Space.WORLD */ && this.parent) {
497
- if (this.rotationQuaternion) {
498
- // Get local rotation matrix of the looking object
499
- const rotationMatrix = TmpVectors.Matrix[0];
500
- this.rotationQuaternion.toRotationMatrix(rotationMatrix);
501
- // Offset rotation by parent's inverted rotation matrix to correct in world space
502
- const parentRotationMatrix = TmpVectors.Matrix[1];
503
- this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
504
- parentRotationMatrix.invert();
505
- rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
506
- this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
507
- }
508
- else {
509
- // Get local rotation matrix of the looking object
510
- const quaternionRotation = TmpVectors.Quaternion[0];
511
- Quaternion.FromEulerVectorToRef(this.rotation, quaternionRotation);
512
- const rotationMatrix = TmpVectors.Matrix[0];
513
- quaternionRotation.toRotationMatrix(rotationMatrix);
514
- // Offset rotation by parent's inverted rotation matrix to correct in world space
515
- const parentRotationMatrix = TmpVectors.Matrix[1];
516
- this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
517
- parentRotationMatrix.invert();
518
- rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
519
- quaternionRotation.fromRotationMatrix(rotationMatrix);
520
- quaternionRotation.toEulerAnglesToRef(this.rotation);
481
+ /**
482
+ * Sets the mesh position in its local space.
483
+ * @param vector3 the position to set in localspace
484
+ * @returns the TransformNode.
485
+ */
486
+ setPositionWithLocalVector(vector3) {
487
+ this.computeWorldMatrix();
488
+ this.position = Vector3.TransformNormal(vector3, this._localMatrix);
489
+ return this;
521
490
  }
522
- }
523
- return this;
524
- }
525
- /**
526
- * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
527
- * This Vector3 is expressed in the World space.
528
- * @param localAxis axis to rotate
529
- * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
530
- */
531
- getDirection(localAxis) {
532
- const result = Vector3.Zero();
533
- this.getDirectionToRef(localAxis, result);
534
- return result;
535
- }
536
- /**
537
- * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
538
- * localAxis is expressed in the mesh local space.
539
- * result is computed in the World space from the mesh World matrix.
540
- * @param localAxis axis to rotate
541
- * @param result the resulting transformnode
542
- * @returns this TransformNode.
543
- */
544
- getDirectionToRef(localAxis, result) {
545
- Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
546
- return this;
547
- }
548
- /**
549
- * Sets this transform node rotation to the given local axis.
550
- * @param localAxis the axis in local space
551
- * @param yawCor optional yaw (y-axis) correction in radians
552
- * @param pitchCor optional pitch (x-axis) correction in radians
553
- * @param rollCor optional roll (z-axis) correction in radians
554
- * @returns this TransformNode
555
- */
556
- setDirection(localAxis, yawCor = 0, pitchCor = 0, rollCor = 0) {
557
- const yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
558
- const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
559
- const pitch = -Math.atan2(localAxis.y, len);
560
- if (this.rotationQuaternion) {
561
- Quaternion.RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
562
- }
563
- else {
564
- this.rotation.x = pitch + pitchCor;
565
- this.rotation.y = yaw + yawCor;
566
- this.rotation.z = rollCor;
567
- }
568
- return this;
569
- }
570
- /**
571
- * Sets a new pivot point to the current node
572
- * @param point defines the new pivot point to use
573
- * @param space defines if the point is in world or local space (local by default)
574
- * @returns the current TransformNode
575
- */
576
- setPivotPoint(point, space = 0 /* Space.LOCAL */) {
577
- if (this.getScene().getRenderId() == 0) {
578
- this.computeWorldMatrix(true);
579
- }
580
- const wm = this.getWorldMatrix();
581
- if (space == 1 /* Space.WORLD */) {
582
- const tmat = TmpVectors.Matrix[0];
583
- wm.invertToRef(tmat);
584
- point = Vector3.TransformCoordinates(point, tmat);
585
- }
586
- return this.setPivotMatrix(Matrix.Translation(-point.x, -point.y, -point.z), true);
587
- }
588
- /**
589
- * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
590
- * @returns the pivot point
591
- */
592
- getPivotPoint() {
593
- const point = Vector3.Zero();
594
- this.getPivotPointToRef(point);
595
- return point;
596
- }
597
- /**
598
- * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
599
- * @param result the vector3 to store the result
600
- * @returns this TransformNode.
601
- */
602
- getPivotPointToRef(result) {
603
- result.x = -this._pivotMatrix.m[12];
604
- result.y = -this._pivotMatrix.m[13];
605
- result.z = -this._pivotMatrix.m[14];
606
- return this;
607
- }
608
- /**
609
- * Returns a new Vector3 set with the mesh pivot point World coordinates.
610
- * @returns a new Vector3 set with the mesh pivot point World coordinates.
611
- */
612
- getAbsolutePivotPoint() {
613
- const point = Vector3.Zero();
614
- this.getAbsolutePivotPointToRef(point);
615
- return point;
616
- }
617
- /**
618
- * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
619
- * @param result vector3 to store the result
620
- * @returns this TransformNode.
621
- */
622
- getAbsolutePivotPointToRef(result) {
623
- this.getPivotPointToRef(result);
624
- Vector3.TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
625
- return this;
626
- }
627
- /**
628
- * Flag the transform node as dirty (Forcing it to update everything)
629
- * @param property if set to "rotation" the objects rotationQuaternion will be set to null
630
- * @returns this node
631
- */
632
- markAsDirty(property) {
633
- if (this._isDirty) {
634
- return this;
635
- }
636
- // We need to explicitly update the children
637
- // as the scene.evaluateActiveMeshes will not poll the transform nodes
638
- if (this._children) {
639
- for (const child of this._children) {
640
- child.markAsDirty(property);
491
+ /**
492
+ * Returns the mesh position in the local space from the current World matrix values.
493
+ * @returns a new Vector3.
494
+ */
495
+ getPositionExpressedInLocalSpace() {
496
+ this.computeWorldMatrix();
497
+ const invLocalWorldMatrix = TmpVectors.Matrix[0];
498
+ this._localMatrix.invertToRef(invLocalWorldMatrix);
499
+ return Vector3.TransformNormal(this.position, invLocalWorldMatrix);
641
500
  }
642
- }
643
- return super.markAsDirty(property);
644
- }
645
- /**
646
- * Defines the passed node as the parent of the current node.
647
- * The node will remain exactly where it is and its position / rotation will be updated accordingly.
648
- * If you don't want to preserve the current rotation / position, assign the parent through parent accessor.
649
- * Note that if the mesh has a pivot matrix / point defined it will be applied after the parent was updated.
650
- * In that case the node will not remain in the same space as it is, as the pivot will be applied.
651
- * To avoid this, you can set updatePivot to true and the pivot will be updated to identity
652
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/parent_pivot/parent
653
- * @param node the node ot set as the parent
654
- * @param preserveScalingSign if true, keep scaling sign of child. Otherwise, scaling sign might change.
655
- * @param updatePivot if true, update the pivot matrix to keep the node in the same space as before
656
- * @param useAbsoluteScaling if false,will keep the node original scaling
657
- * @returns this TransformNode.
658
- */
659
- setParent(node, preserveScalingSign = false, updatePivot = false, useAbsoluteScaling = true) {
660
- if (!node && !this.parent) {
661
- return this;
662
- }
663
- const quatRotation = TmpVectors.Quaternion[0];
664
- const position = TmpVectors.Vector3[0];
665
- const scale = TmpVectors.Vector3[1];
666
- const invParentMatrix = TmpVectors.Matrix[1];
667
- Matrix.IdentityToRef(invParentMatrix);
668
- const composedMatrix = TmpVectors.Matrix[0];
669
- this.computeWorldMatrix(true);
670
- let currentRotation = this.rotationQuaternion;
671
- if (!currentRotation) {
672
- currentRotation = TransformNode._TmpRotation;
673
- Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, currentRotation);
674
- }
675
- // current global transformation without pivot
676
- Matrix.ComposeToRef(this.scaling, currentRotation, this.position, composedMatrix);
677
- if (this.parent) {
678
- composedMatrix.multiplyToRef(this.parent.computeWorldMatrix(true), composedMatrix);
679
- }
680
- // is a node was set, calculate the difference between this and the node
681
- if (node) {
682
- node.computeWorldMatrix(true).invertToRef(invParentMatrix);
683
- composedMatrix.multiplyToRef(invParentMatrix, composedMatrix);
684
- }
685
- composedMatrix.decompose(scale, quatRotation, position, preserveScalingSign ? this : undefined, useAbsoluteScaling);
686
- if (this.rotationQuaternion) {
687
- this.rotationQuaternion.copyFrom(quatRotation);
688
- }
689
- else {
690
- quatRotation.toEulerAnglesToRef(this.rotation);
691
- }
692
- this.scaling.copyFrom(scale);
693
- this.position.copyFrom(position);
694
- this.parent = node;
695
- if (updatePivot) {
696
- this.setPivotMatrix(Matrix.Identity());
697
- }
698
- return this;
699
- }
700
- /**
701
- * Adds the passed mesh as a child to the current mesh.
702
- * The node will remain exactly where it is and its position / rotation will be updated accordingly.
703
- * This method is equivalent to calling setParent().
704
- * @param mesh defines the child mesh
705
- * @param preserveScalingSign if true, keep scaling sign of child. Otherwise, scaling sign might change.
706
- * @returns the current mesh
707
- */
708
- addChild(mesh, preserveScalingSign = false) {
709
- mesh.setParent(this, preserveScalingSign);
710
- return this;
711
- }
712
- /**
713
- * Removes the passed mesh from the current mesh children list
714
- * @param mesh defines the child mesh
715
- * @param preserveScalingSign if true, keep scaling sign of child. Otherwise, scaling sign might change.
716
- * @returns the current mesh
717
- */
718
- removeChild(mesh, preserveScalingSign = false) {
719
- if (mesh.parent !== this) {
720
- return this;
721
- }
722
- mesh.setParent(null, preserveScalingSign);
723
- return this;
724
- }
725
- /**
726
- * True if the scaling property of this object is non uniform eg. (1,2,1)
727
- */
728
- get nonUniformScaling() {
729
- return this._nonUniformScaling;
730
- }
731
- /**
732
- * @internal
733
- */
734
- _updateNonUniformScalingState(value) {
735
- if (this._nonUniformScaling === value) {
736
- return false;
737
- }
738
- this._nonUniformScaling = value;
739
- return true;
740
- }
741
- /**
742
- * Attach the current TransformNode to another TransformNode associated with a bone
743
- * @param bone Bone affecting the TransformNode
744
- * @param affectedTransformNode TransformNode associated with the bone
745
- * @returns this object
746
- */
747
- attachToBone(bone, affectedTransformNode) {
748
- this._currentParentWhenAttachingToBone = this.parent;
749
- this._transformToBoneReferal = affectedTransformNode;
750
- this.parent = bone;
751
- bone.getSkeleton().prepare(true); // make sure bone.getFinalMatrix() is up to date
752
- if (bone.getFinalMatrix().determinant() < 0) {
753
- this.scalingDeterminant *= -1;
754
- }
755
- return this;
756
- }
757
- /**
758
- * Detach the transform node if its associated with a bone
759
- * @param resetToPreviousParent Indicates if the parent that was in effect when attachToBone was called should be set back or if we should set parent to null instead (defaults to the latter)
760
- * @returns this object
761
- */
762
- detachFromBone(resetToPreviousParent = false) {
763
- if (!this.parent) {
764
- if (resetToPreviousParent) {
765
- this.parent = this._currentParentWhenAttachingToBone;
766
- }
767
- return this;
768
- }
769
- if (this.parent.getWorldMatrix().determinant() < 0) {
770
- this.scalingDeterminant *= -1;
771
- }
772
- this._transformToBoneReferal = null;
773
- if (resetToPreviousParent) {
774
- this.parent = this._currentParentWhenAttachingToBone;
775
- }
776
- else {
777
- this.parent = null;
778
- }
779
- return this;
780
- }
781
- /**
782
- * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
783
- * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
784
- * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
785
- * The passed axis is also normalized.
786
- * @param axis the axis to rotate around
787
- * @param amount the amount to rotate in radians
788
- * @param space Space to rotate in (Default: local)
789
- * @returns the TransformNode.
790
- */
791
- rotate(axis, amount, space) {
792
- axis.normalize();
793
- if (!this.rotationQuaternion) {
794
- this.rotationQuaternion = this.rotation.toQuaternion();
795
- this.rotation.setAll(0);
796
- }
797
- let rotationQuaternion;
798
- if (!space || space === 0 /* Space.LOCAL */) {
799
- rotationQuaternion = Quaternion.RotationAxisToRef(axis, amount, TransformNode._RotationAxisCache);
800
- this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
801
- }
802
- else {
803
- if (this.parent) {
804
- const parentWorldMatrix = this.parent.getWorldMatrix();
805
- const invertParentWorldMatrix = TmpVectors.Matrix[0];
806
- parentWorldMatrix.invertToRef(invertParentWorldMatrix);
807
- axis = Vector3.TransformNormal(axis, invertParentWorldMatrix);
808
- if (parentWorldMatrix.determinant() < 0) {
809
- amount *= -1;
810
- }
811
- }
812
- rotationQuaternion = Quaternion.RotationAxisToRef(axis, amount, TransformNode._RotationAxisCache);
813
- rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
814
- }
815
- return this;
816
- }
817
- /**
818
- * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
819
- * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
820
- * The passed axis is also normalized. .
821
- * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
822
- * @param point the point to rotate around
823
- * @param axis the axis to rotate around
824
- * @param amount the amount to rotate in radians
825
- * @returns the TransformNode
826
- */
827
- rotateAround(point, axis, amount) {
828
- axis.normalize();
829
- if (!this.rotationQuaternion) {
830
- this.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
831
- this.rotation.setAll(0);
832
- }
833
- const tmpVector = TmpVectors.Vector3[0];
834
- const finalScale = TmpVectors.Vector3[1];
835
- const finalTranslation = TmpVectors.Vector3[2];
836
- const finalRotation = TmpVectors.Quaternion[0];
837
- const translationMatrix = TmpVectors.Matrix[0]; // T
838
- const translationMatrixInv = TmpVectors.Matrix[1]; // T'
839
- const rotationMatrix = TmpVectors.Matrix[2]; // R
840
- const finalMatrix = TmpVectors.Matrix[3]; // T' x R x T
841
- point.subtractToRef(this.position, tmpVector);
842
- Matrix.TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
843
- Matrix.TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
844
- Matrix.RotationAxisToRef(axis, amount, rotationMatrix); // R
845
- translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
846
- finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
847
- finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
848
- this.position.addInPlace(finalTranslation);
849
- finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
850
- return this;
851
- }
852
- /**
853
- * Translates the mesh along the axis vector for the passed distance in the given space.
854
- * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
855
- * @param axis the axis to translate in
856
- * @param distance the distance to translate
857
- * @param space Space to rotate in (Default: local)
858
- * @returns the TransformNode.
859
- */
860
- translate(axis, distance, space) {
861
- const displacementVector = axis.scale(distance);
862
- if (!space || space === 0 /* Space.LOCAL */) {
863
- const tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
864
- this.setPositionWithLocalVector(tempV3);
865
- }
866
- else {
867
- this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
868
- }
869
- return this;
870
- }
871
- /**
872
- * Adds a rotation step to the mesh current rotation.
873
- * x, y, z are Euler angles expressed in radians.
874
- * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
875
- * This means this rotation is made in the mesh local space only.
876
- * It's useful to set a custom rotation order different from the BJS standard one YXZ.
877
- * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
878
- * ```javascript
879
- * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
880
- * ```
881
- * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
882
- * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
883
- * @param x Rotation to add
884
- * @param y Rotation to add
885
- * @param z Rotation to add
886
- * @returns the TransformNode.
887
- */
888
- addRotation(x, y, z) {
889
- let rotationQuaternion;
890
- if (this.rotationQuaternion) {
891
- rotationQuaternion = this.rotationQuaternion;
892
- }
893
- else {
894
- rotationQuaternion = TmpVectors.Quaternion[1];
895
- Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
896
- }
897
- const accumulation = TmpVectors.Quaternion[0];
898
- Quaternion.RotationYawPitchRollToRef(y, x, z, accumulation);
899
- rotationQuaternion.multiplyInPlace(accumulation);
900
- if (!this.rotationQuaternion) {
901
- rotationQuaternion.toEulerAnglesToRef(this.rotation);
902
- }
903
- return this;
904
- }
905
- /**
906
- * @internal
907
- */
908
- _getEffectiveParent() {
909
- return this.parent;
910
- }
911
- /**
912
- * Returns whether the transform node world matrix computation needs the camera information to be computed.
913
- * This is the case when the node is a billboard or has an infinite distance for instance.
914
- * @returns true if the world matrix computation needs the camera information to be computed
915
- */
916
- isWorldMatrixCameraDependent() {
917
- return (this._infiniteDistance && !this.parent) || this._billboardMode !== TransformNode.BILLBOARDMODE_NONE;
918
- }
919
- /**
920
- * Computes the world matrix of the node
921
- * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
922
- * @param camera defines the camera used if different from the scene active camera (This is used with modes like Billboard or infinite distance)
923
- * @returns the world matrix
924
- */
925
- computeWorldMatrix(force = false, camera = null) {
926
- if (this._isWorldMatrixFrozen && !this._isDirty) {
927
- return this._worldMatrix;
928
- }
929
- const currentRenderId = this.getScene().getRenderId();
930
- if (!this._isDirty && !force && (this._currentRenderId === currentRenderId || this.isSynchronized())) {
931
- this._currentRenderId = currentRenderId;
932
- return this._worldMatrix;
933
- }
934
- camera = camera || this.getScene().activeCamera;
935
- this._updateCache();
936
- const cache = this._cache;
937
- cache.pivotMatrixUpdated = false;
938
- cache.billboardMode = this.billboardMode;
939
- cache.infiniteDistance = this.infiniteDistance;
940
- cache.parent = this._parentNode;
941
- this._currentRenderId = currentRenderId;
942
- this._childUpdateId += 1;
943
- this._isDirty = false;
944
- this._position._isDirty = false;
945
- this._rotation._isDirty = false;
946
- this._scaling._isDirty = false;
947
- const parent = this._getEffectiveParent();
948
- // Scaling
949
- const scaling = TransformNode._TmpScaling;
950
- let translation = this._position;
951
- // Translation
952
- if (this._infiniteDistance) {
953
- if (!this.parent && camera) {
954
- const cameraWorldMatrix = camera.getWorldMatrix();
955
- const m = cameraWorldMatrix.m;
956
- translation = TransformNode._TmpTranslation;
957
- translation.copyFromFloats(this._position.x + m[12], this._position.y + m[13], this._position.z + m[14]);
501
+ /**
502
+ * Translates the mesh along the passed Vector3 in its local space.
503
+ * @param vector3 the distance to translate in localspace
504
+ * @returns the TransformNode.
505
+ */
506
+ locallyTranslate(vector3) {
507
+ this.computeWorldMatrix(true);
508
+ this.position = Vector3.TransformCoordinates(vector3, this._localMatrix);
509
+ return this;
958
510
  }
959
- }
960
- // Scaling
961
- scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
962
- // Rotation
963
- let rotation;
964
- if (this._rotationQuaternion) {
965
- const isDirty = this._rotationQuaternion._isDirty;
966
- this._rotationQuaternion._isDirty = false;
967
- rotation = this._rotationQuaternion;
968
- if (this.reIntegrateRotationIntoRotationQuaternion) {
969
- const len = this.rotation.lengthSquared();
970
- if (len) {
971
- this._rotationQuaternion.multiplyInPlace(Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
972
- this._rotation.copyFromFloats(0, 0, 0);
973
- }
974
- }
975
- if (isDirty) {
976
- this._rotationQuaternion.toEulerAnglesToRef(this._eulerCacheRotation);
977
- this._eulerCacheRotation._isDirty = false;
511
+ /**
512
+ * Orients a mesh towards a target point. Mesh must be drawn facing user.
513
+ * @param targetPoint the position (must be in same space as current mesh) to look at
514
+ * @param yawCor optional yaw (y-axis) correction in radians
515
+ * @param pitchCor optional pitch (x-axis) correction in radians
516
+ * @param rollCor optional roll (z-axis) correction in radians
517
+ * @param space the chosen space of the target
518
+ * @returns the TransformNode.
519
+ */
520
+ lookAt(targetPoint, yawCor = 0, pitchCor = 0, rollCor = 0, space = 0 /* Space.LOCAL */) {
521
+ const dv = _a._LookAtVectorCache;
522
+ const pos = space === 0 /* Space.LOCAL */ ? this.position : this.getAbsolutePosition();
523
+ targetPoint.subtractToRef(pos, dv);
524
+ this.setDirection(dv, yawCor, pitchCor, rollCor);
525
+ // Correct for parent's rotation offset
526
+ if (space === 1 /* Space.WORLD */ && this.parent) {
527
+ if (this.rotationQuaternion) {
528
+ // Get local rotation matrix of the looking object
529
+ const rotationMatrix = TmpVectors.Matrix[0];
530
+ this.rotationQuaternion.toRotationMatrix(rotationMatrix);
531
+ // Offset rotation by parent's inverted rotation matrix to correct in world space
532
+ const parentRotationMatrix = TmpVectors.Matrix[1];
533
+ this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
534
+ parentRotationMatrix.invert();
535
+ rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
536
+ this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
537
+ }
538
+ else {
539
+ // Get local rotation matrix of the looking object
540
+ const quaternionRotation = TmpVectors.Quaternion[0];
541
+ Quaternion.FromEulerVectorToRef(this.rotation, quaternionRotation);
542
+ const rotationMatrix = TmpVectors.Matrix[0];
543
+ quaternionRotation.toRotationMatrix(rotationMatrix);
544
+ // Offset rotation by parent's inverted rotation matrix to correct in world space
545
+ const parentRotationMatrix = TmpVectors.Matrix[1];
546
+ this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
547
+ parentRotationMatrix.invert();
548
+ rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
549
+ quaternionRotation.fromRotationMatrix(rotationMatrix);
550
+ quaternionRotation.toEulerAnglesToRef(this.rotation);
551
+ }
552
+ }
553
+ return this;
978
554
  }
979
- }
980
- else {
981
- rotation = TransformNode._TmpRotation;
982
- Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
983
- }
984
- // Compose
985
- if (this._usePivotMatrix) {
986
- const scaleMatrix = TmpVectors.Matrix[1];
987
- Matrix.ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
988
- // Rotation
989
- const rotationMatrix = TmpVectors.Matrix[0];
990
- rotation.toRotationMatrix(rotationMatrix);
991
- // Composing transformations
992
- this._pivotMatrix.multiplyToRef(scaleMatrix, TmpVectors.Matrix[4]);
993
- TmpVectors.Matrix[4].multiplyToRef(rotationMatrix, this._localMatrix);
994
- // Post multiply inverse of pivotMatrix
995
- if (this._postMultiplyPivotMatrix) {
996
- this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix);
997
- }
998
- this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
999
- }
1000
- else {
1001
- Matrix.ComposeToRef(scaling, rotation, translation, this._localMatrix);
1002
- }
1003
- // Parent
1004
- if (parent && parent.getWorldMatrix) {
1005
- if (force) {
1006
- parent.computeWorldMatrix(force);
555
+ /**
556
+ * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
557
+ * This Vector3 is expressed in the World space.
558
+ * @param localAxis axis to rotate
559
+ * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
560
+ */
561
+ getDirection(localAxis) {
562
+ const result = Vector3.Zero();
563
+ this.getDirectionToRef(localAxis, result);
564
+ return result;
565
+ }
566
+ /**
567
+ * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
568
+ * localAxis is expressed in the mesh local space.
569
+ * result is computed in the World space from the mesh World matrix.
570
+ * @param localAxis axis to rotate
571
+ * @param result the resulting transformnode
572
+ * @returns this TransformNode.
573
+ */
574
+ getDirectionToRef(localAxis, result) {
575
+ Vector3.TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
576
+ return this;
1007
577
  }
1008
- if (this.billboardMode) {
1009
- if (this._transformToBoneReferal) {
1010
- const bone = this.parent;
1011
- bone.getSkeleton().prepare();
1012
- bone.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), TmpVectors.Matrix[7]);
578
+ /**
579
+ * Sets this transform node rotation to the given local axis.
580
+ * @param localAxis the axis in local space
581
+ * @param yawCor optional yaw (y-axis) correction in radians
582
+ * @param pitchCor optional pitch (x-axis) correction in radians
583
+ * @param rollCor optional roll (z-axis) correction in radians
584
+ * @returns this TransformNode
585
+ */
586
+ setDirection(localAxis, yawCor = 0, pitchCor = 0, rollCor = 0) {
587
+ const yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
588
+ const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
589
+ const pitch = -Math.atan2(localAxis.y, len);
590
+ if (this.rotationQuaternion) {
591
+ Quaternion.RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
1013
592
  }
1014
593
  else {
1015
- TmpVectors.Matrix[7].copyFrom(parent.getWorldMatrix());
1016
- }
1017
- // Extract scaling and translation from parent
1018
- const translation = TmpVectors.Vector3[5];
1019
- const scale = TmpVectors.Vector3[6];
1020
- const orientation = TmpVectors.Quaternion[0];
1021
- TmpVectors.Matrix[7].decompose(scale, orientation, translation);
1022
- Matrix.ScalingToRef(scale.x, scale.y, scale.z, TmpVectors.Matrix[7]);
1023
- TmpVectors.Matrix[7].setTranslation(translation);
1024
- if (TransformNode.BillboardUseParentOrientation) {
1025
- // set localMatrix translation to be transformed against parent's orientation.
1026
- this._position.applyRotationQuaternionToRef(orientation, translation);
1027
- this._localMatrix.setTranslation(translation);
1028
- }
1029
- this._localMatrix.multiplyToRef(TmpVectors.Matrix[7], this._worldMatrix);
1030
- }
1031
- else {
1032
- if (this._transformToBoneReferal) {
1033
- const bone = this.parent;
1034
- bone.getSkeleton().prepare();
1035
- this._localMatrix.multiplyToRef(bone.getFinalMatrix(), TmpVectors.Matrix[6]);
1036
- TmpVectors.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
594
+ this.rotation.x = pitch + pitchCor;
595
+ this.rotation.y = yaw + yawCor;
596
+ this.rotation.z = rollCor;
597
+ }
598
+ return this;
599
+ }
600
+ /**
601
+ * Sets a new pivot point to the current node
602
+ * @param point defines the new pivot point to use
603
+ * @param space defines if the point is in world or local space (local by default)
604
+ * @returns the current TransformNode
605
+ */
606
+ setPivotPoint(point, space = 0 /* Space.LOCAL */) {
607
+ if (this.getScene().getRenderId() == 0) {
608
+ this.computeWorldMatrix(true);
609
+ }
610
+ const wm = this.getWorldMatrix();
611
+ if (space == 1 /* Space.WORLD */) {
612
+ const tmat = TmpVectors.Matrix[0];
613
+ wm.invertToRef(tmat);
614
+ point = Vector3.TransformCoordinates(point, tmat);
615
+ }
616
+ return this.setPivotMatrix(Matrix.Translation(-point.x, -point.y, -point.z), true);
617
+ }
618
+ /**
619
+ * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
620
+ * @returns the pivot point
621
+ */
622
+ getPivotPoint() {
623
+ const point = Vector3.Zero();
624
+ this.getPivotPointToRef(point);
625
+ return point;
626
+ }
627
+ /**
628
+ * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
629
+ * @param result the vector3 to store the result
630
+ * @returns this TransformNode.
631
+ */
632
+ getPivotPointToRef(result) {
633
+ result.x = -this._pivotMatrix.m[12];
634
+ result.y = -this._pivotMatrix.m[13];
635
+ result.z = -this._pivotMatrix.m[14];
636
+ return this;
637
+ }
638
+ /**
639
+ * Returns a new Vector3 set with the mesh pivot point World coordinates.
640
+ * @returns a new Vector3 set with the mesh pivot point World coordinates.
641
+ */
642
+ getAbsolutePivotPoint() {
643
+ const point = Vector3.Zero();
644
+ this.getAbsolutePivotPointToRef(point);
645
+ return point;
646
+ }
647
+ /**
648
+ * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
649
+ * @param result vector3 to store the result
650
+ * @returns this TransformNode.
651
+ */
652
+ getAbsolutePivotPointToRef(result) {
653
+ this.getPivotPointToRef(result);
654
+ Vector3.TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
655
+ return this;
656
+ }
657
+ /**
658
+ * Flag the transform node as dirty (Forcing it to update everything)
659
+ * @param property if set to "rotation" the objects rotationQuaternion will be set to null
660
+ * @returns this node
661
+ */
662
+ markAsDirty(property) {
663
+ if (this._isDirty) {
664
+ return this;
665
+ }
666
+ // We need to explicitly update the children
667
+ // as the scene.evaluateActiveMeshes will not poll the transform nodes
668
+ if (this._children) {
669
+ for (const child of this._children) {
670
+ child.markAsDirty(property);
671
+ }
672
+ }
673
+ return super.markAsDirty(property);
674
+ }
675
+ /**
676
+ * Defines the passed node as the parent of the current node.
677
+ * The node will remain exactly where it is and its position / rotation will be updated accordingly.
678
+ * If you don't want to preserve the current rotation / position, assign the parent through parent accessor.
679
+ * Note that if the mesh has a pivot matrix / point defined it will be applied after the parent was updated.
680
+ * In that case the node will not remain in the same space as it is, as the pivot will be applied.
681
+ * To avoid this, you can set updatePivot to true and the pivot will be updated to identity
682
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/parent_pivot/parent
683
+ * @param node the node ot set as the parent
684
+ * @param preserveScalingSign if true, keep scaling sign of child. Otherwise, scaling sign might change.
685
+ * @param updatePivot if true, update the pivot matrix to keep the node in the same space as before
686
+ * @param useAbsoluteScaling if false,will keep the node original scaling
687
+ * @returns this TransformNode.
688
+ */
689
+ setParent(node, preserveScalingSign = false, updatePivot = false, useAbsoluteScaling = true) {
690
+ if (!node && !this.parent) {
691
+ return this;
692
+ }
693
+ const quatRotation = TmpVectors.Quaternion[0];
694
+ const position = TmpVectors.Vector3[0];
695
+ const scale = TmpVectors.Vector3[1];
696
+ const invParentMatrix = TmpVectors.Matrix[1];
697
+ Matrix.IdentityToRef(invParentMatrix);
698
+ const composedMatrix = TmpVectors.Matrix[0];
699
+ this.computeWorldMatrix(true);
700
+ let currentRotation = this.rotationQuaternion;
701
+ if (!currentRotation) {
702
+ currentRotation = _a._TmpRotation;
703
+ Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, currentRotation);
704
+ }
705
+ // current global transformation without pivot
706
+ Matrix.ComposeToRef(this.scaling, currentRotation, this.position, composedMatrix);
707
+ if (this.parent) {
708
+ composedMatrix.multiplyToRef(this.parent.computeWorldMatrix(true), composedMatrix);
709
+ }
710
+ // is a node was set, calculate the difference between this and the node
711
+ if (node) {
712
+ node.computeWorldMatrix(true).invertToRef(invParentMatrix);
713
+ composedMatrix.multiplyToRef(invParentMatrix, composedMatrix);
714
+ }
715
+ composedMatrix.decompose(scale, quatRotation, position, preserveScalingSign ? this : undefined, useAbsoluteScaling);
716
+ if (this.rotationQuaternion) {
717
+ this.rotationQuaternion.copyFrom(quatRotation);
1037
718
  }
1038
719
  else {
1039
- this._localMatrix.multiplyToRef(parent.getWorldMatrix(), this._worldMatrix);
720
+ quatRotation.toEulerAnglesToRef(this.rotation);
721
+ }
722
+ this.scaling.copyFrom(scale);
723
+ this.position.copyFrom(position);
724
+ this.parent = node;
725
+ if (updatePivot) {
726
+ this.setPivotMatrix(Matrix.Identity());
1040
727
  }
728
+ return this;
1041
729
  }
1042
- this._markSyncedWithParent();
1043
- }
1044
- else {
1045
- this._worldMatrix.copyFrom(this._localMatrix);
1046
- }
1047
- if (camera && this.billboardMode) {
1048
- // Billboarding based on camera orientation (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
1049
- if (!cache.useBillboardPosition) {
1050
- const storedTranslation = TmpVectors.Vector3[0];
1051
- this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
1052
- // Get camera view matrix
1053
- TmpVectors.Matrix[1].copyFrom(camera.getViewMatrix());
1054
- const isRH = this.getScene().useRightHandedSystem;
1055
- if (isRH) {
1056
- // This operation is necessary to cancel out the scaling component of the matrix without decomposing it.
1057
- // It's a trick to extract only the rotation part.
1058
- TmpVectors.Matrix[1].multiplyToRef(TransformNode._TmpRHRestore, TmpVectors.Matrix[1]);
1059
- }
1060
- // This will cancel the camera rotation
1061
- TmpVectors.Matrix[1].setTranslationFromFloats(0, 0, 0);
1062
- TmpVectors.Matrix[1].invertToRef(TmpVectors.Matrix[0]);
1063
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
1064
- TmpVectors.Matrix[0].decompose(undefined, TmpVectors.Quaternion[0], undefined);
1065
- const eulerAngles = TmpVectors.Vector3[1];
1066
- TmpVectors.Quaternion[0].toEulerAnglesToRef(eulerAngles);
1067
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
1068
- eulerAngles.x = 0;
730
+ /**
731
+ * Adds the passed mesh as a child to the current mesh.
732
+ * The node will remain exactly where it is and its position / rotation will be updated accordingly.
733
+ * This method is equivalent to calling setParent().
734
+ * @param mesh defines the child mesh
735
+ * @param preserveScalingSign if true, keep scaling sign of child. Otherwise, scaling sign might change.
736
+ * @returns the current mesh
737
+ */
738
+ addChild(mesh, preserveScalingSign = false) {
739
+ mesh.setParent(this, preserveScalingSign);
740
+ return this;
741
+ }
742
+ /**
743
+ * Removes the passed mesh from the current mesh children list
744
+ * @param mesh defines the child mesh
745
+ * @param preserveScalingSign if true, keep scaling sign of child. Otherwise, scaling sign might change.
746
+ * @returns the current mesh
747
+ */
748
+ removeChild(mesh, preserveScalingSign = false) {
749
+ if (mesh.parent !== this) {
750
+ return this;
751
+ }
752
+ mesh.setParent(null, preserveScalingSign);
753
+ return this;
754
+ }
755
+ /**
756
+ * True if the scaling property of this object is non uniform eg. (1,2,1)
757
+ */
758
+ get nonUniformScaling() {
759
+ return this._nonUniformScaling;
760
+ }
761
+ /**
762
+ * @internal
763
+ */
764
+ _updateNonUniformScalingState(value) {
765
+ if (this._nonUniformScaling === value) {
766
+ return false;
767
+ }
768
+ this._nonUniformScaling = value;
769
+ return true;
770
+ }
771
+ /**
772
+ * Attach the current TransformNode to another TransformNode associated with a bone
773
+ * @param bone Bone affecting the TransformNode
774
+ * @param affectedTransformNode TransformNode associated with the bone
775
+ * @returns this object
776
+ */
777
+ attachToBone(bone, affectedTransformNode) {
778
+ this._currentParentWhenAttachingToBone = this.parent;
779
+ this._transformToBoneReferal = affectedTransformNode;
780
+ this.parent = bone;
781
+ bone.getSkeleton().prepare(true); // make sure bone.getFinalMatrix() is up to date
782
+ if (bone.getFinalMatrix().determinant() < 0) {
783
+ this.scalingDeterminant *= -1;
784
+ }
785
+ return this;
786
+ }
787
+ /**
788
+ * Detach the transform node if its associated with a bone
789
+ * @param resetToPreviousParent Indicates if the parent that was in effect when attachToBone was called should be set back or if we should set parent to null instead (defaults to the latter)
790
+ * @returns this object
791
+ */
792
+ detachFromBone(resetToPreviousParent = false) {
793
+ if (!this.parent) {
794
+ if (resetToPreviousParent) {
795
+ this.parent = this._currentParentWhenAttachingToBone;
796
+ }
797
+ return this;
798
+ }
799
+ if (this.parent.getWorldMatrix().determinant() < 0) {
800
+ this.scalingDeterminant *= -1;
801
+ }
802
+ this._transformToBoneReferal = null;
803
+ if (resetToPreviousParent) {
804
+ this.parent = this._currentParentWhenAttachingToBone;
805
+ }
806
+ else {
807
+ this.parent = null;
808
+ }
809
+ return this;
810
+ }
811
+ /**
812
+ * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
813
+ * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
814
+ * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
815
+ * The passed axis is also normalized.
816
+ * @param axis the axis to rotate around
817
+ * @param amount the amount to rotate in radians
818
+ * @param space Space to rotate in (Default: local)
819
+ * @returns the TransformNode.
820
+ */
821
+ rotate(axis, amount, space) {
822
+ axis.normalize();
823
+ if (!this.rotationQuaternion) {
824
+ this.rotationQuaternion = this.rotation.toQuaternion();
825
+ this.rotation.setAll(0);
826
+ }
827
+ let rotationQuaternion;
828
+ if (!space || space === 0 /* Space.LOCAL */) {
829
+ rotationQuaternion = Quaternion.RotationAxisToRef(axis, amount, _a._RotationAxisCache);
830
+ this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
831
+ }
832
+ else {
833
+ if (this.parent) {
834
+ const parentWorldMatrix = this.parent.getWorldMatrix();
835
+ const invertParentWorldMatrix = TmpVectors.Matrix[0];
836
+ parentWorldMatrix.invertToRef(invertParentWorldMatrix);
837
+ axis = Vector3.TransformNormal(axis, invertParentWorldMatrix);
838
+ if (parentWorldMatrix.determinant() < 0) {
839
+ amount *= -1;
840
+ }
841
+ }
842
+ rotationQuaternion = Quaternion.RotationAxisToRef(axis, amount, _a._RotationAxisCache);
843
+ rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
844
+ }
845
+ return this;
846
+ }
847
+ /**
848
+ * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
849
+ * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
850
+ * The passed axis is also normalized. .
851
+ * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
852
+ * @param point the point to rotate around
853
+ * @param axis the axis to rotate around
854
+ * @param amount the amount to rotate in radians
855
+ * @returns the TransformNode
856
+ */
857
+ rotateAround(point, axis, amount) {
858
+ axis.normalize();
859
+ if (!this.rotationQuaternion) {
860
+ this.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
861
+ this.rotation.setAll(0);
862
+ }
863
+ const tmpVector = TmpVectors.Vector3[0];
864
+ const finalScale = TmpVectors.Vector3[1];
865
+ const finalTranslation = TmpVectors.Vector3[2];
866
+ const finalRotation = TmpVectors.Quaternion[0];
867
+ const translationMatrix = TmpVectors.Matrix[0]; // T
868
+ const translationMatrixInv = TmpVectors.Matrix[1]; // T'
869
+ const rotationMatrix = TmpVectors.Matrix[2]; // R
870
+ const finalMatrix = TmpVectors.Matrix[3]; // T' x R x T
871
+ point.subtractToRef(this.position, tmpVector);
872
+ Matrix.TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
873
+ Matrix.TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
874
+ Matrix.RotationAxisToRef(axis, amount, rotationMatrix); // R
875
+ translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
876
+ finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
877
+ finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
878
+ this.position.addInPlace(finalTranslation);
879
+ finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
880
+ return this;
881
+ }
882
+ /**
883
+ * Translates the mesh along the axis vector for the passed distance in the given space.
884
+ * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
885
+ * @param axis the axis to translate in
886
+ * @param distance the distance to translate
887
+ * @param space Space to rotate in (Default: local)
888
+ * @returns the TransformNode.
889
+ */
890
+ translate(axis, distance, space) {
891
+ const displacementVector = axis.scale(distance);
892
+ if (!space || space === 0 /* Space.LOCAL */) {
893
+ const tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
894
+ this.setPositionWithLocalVector(tempV3);
895
+ }
896
+ else {
897
+ this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
898
+ }
899
+ return this;
900
+ }
901
+ /**
902
+ * Adds a rotation step to the mesh current rotation.
903
+ * x, y, z are Euler angles expressed in radians.
904
+ * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
905
+ * This means this rotation is made in the mesh local space only.
906
+ * It's useful to set a custom rotation order different from the BJS standard one YXZ.
907
+ * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
908
+ * ```javascript
909
+ * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
910
+ * ```
911
+ * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
912
+ * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
913
+ * @param x Rotation to add
914
+ * @param y Rotation to add
915
+ * @param z Rotation to add
916
+ * @returns the TransformNode.
917
+ */
918
+ addRotation(x, y, z) {
919
+ let rotationQuaternion;
920
+ if (this.rotationQuaternion) {
921
+ rotationQuaternion = this.rotationQuaternion;
922
+ }
923
+ else {
924
+ rotationQuaternion = TmpVectors.Quaternion[1];
925
+ Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
926
+ }
927
+ const accumulation = TmpVectors.Quaternion[0];
928
+ Quaternion.RotationYawPitchRollToRef(y, x, z, accumulation);
929
+ rotationQuaternion.multiplyInPlace(accumulation);
930
+ if (!this.rotationQuaternion) {
931
+ rotationQuaternion.toEulerAnglesToRef(this.rotation);
932
+ }
933
+ return this;
934
+ }
935
+ /**
936
+ * @internal
937
+ */
938
+ _getEffectiveParent() {
939
+ return this.parent;
940
+ }
941
+ /**
942
+ * Returns whether the transform node world matrix computation needs the camera information to be computed.
943
+ * This is the case when the node is a billboard or has an infinite distance for instance.
944
+ * @returns true if the world matrix computation needs the camera information to be computed
945
+ */
946
+ isWorldMatrixCameraDependent() {
947
+ return (this._infiniteDistance && !this.parent) || this._billboardMode !== _a.BILLBOARDMODE_NONE;
948
+ }
949
+ /**
950
+ * Computes the world matrix of the node
951
+ * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
952
+ * @param camera defines the camera used if different from the scene active camera (This is used with modes like Billboard or infinite distance)
953
+ * @returns the world matrix
954
+ */
955
+ computeWorldMatrix(force = false, camera = null) {
956
+ if (this._isWorldMatrixFrozen && !this._isDirty) {
957
+ return this._worldMatrix;
958
+ }
959
+ const currentRenderId = this.getScene().getRenderId();
960
+ if (!this._isDirty && !force && (this._currentRenderId === currentRenderId || this.isSynchronized())) {
961
+ this._currentRenderId = currentRenderId;
962
+ return this._worldMatrix;
963
+ }
964
+ camera = camera || this.getScene().activeCamera;
965
+ this._updateCache();
966
+ const cache = this._cache;
967
+ cache.pivotMatrixUpdated = false;
968
+ cache.billboardMode = this.billboardMode;
969
+ cache.infiniteDistance = this.infiniteDistance;
970
+ cache.parent = this._parentNode;
971
+ this._currentRenderId = currentRenderId;
972
+ this._childUpdateId += 1;
973
+ this._isDirty = false;
974
+ this._position._isDirty = false;
975
+ this._rotation._isDirty = false;
976
+ this._scaling._isDirty = false;
977
+ const parent = this._getEffectiveParent();
978
+ // Scaling
979
+ const scaling = _a._TmpScaling;
980
+ let translation = this._position;
981
+ // Translation
982
+ if (this._infiniteDistance) {
983
+ if (!this.parent && camera) {
984
+ const cameraWorldMatrix = camera.getWorldMatrix();
985
+ const m = cameraWorldMatrix.m;
986
+ translation = _a._TmpTranslation;
987
+ translation.copyFromFloats(this._position.x + m[12], this._position.y + m[13], this._position.z + m[14]);
988
+ }
989
+ }
990
+ // Scaling
991
+ scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
992
+ // Rotation
993
+ let rotation;
994
+ if (this._rotationQuaternion) {
995
+ const isDirty = this._rotationQuaternion._isDirty;
996
+ this._rotationQuaternion._isDirty = false;
997
+ rotation = this._rotationQuaternion;
998
+ if (this.reIntegrateRotationIntoRotationQuaternion) {
999
+ const len = this.rotation.lengthSquared();
1000
+ if (len) {
1001
+ this._rotationQuaternion.multiplyInPlace(Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
1002
+ this._rotation.copyFromFloats(0, 0, 0);
1003
+ }
1004
+ }
1005
+ if (isDirty) {
1006
+ this._rotationQuaternion.toEulerAnglesToRef(this._eulerCacheRotation);
1007
+ this._eulerCacheRotation._isDirty = false;
1008
+ }
1009
+ }
1010
+ else {
1011
+ rotation = _a._TmpRotation;
1012
+ Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
1013
+ }
1014
+ // Compose
1015
+ if (this._usePivotMatrix) {
1016
+ const scaleMatrix = TmpVectors.Matrix[1];
1017
+ Matrix.ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
1018
+ // Rotation
1019
+ const rotationMatrix = TmpVectors.Matrix[0];
1020
+ rotation.toRotationMatrix(rotationMatrix);
1021
+ // Composing transformations
1022
+ this._pivotMatrix.multiplyToRef(scaleMatrix, TmpVectors.Matrix[4]);
1023
+ TmpVectors.Matrix[4].multiplyToRef(rotationMatrix, this._localMatrix);
1024
+ // Post multiply inverse of pivotMatrix
1025
+ if (this._postMultiplyPivotMatrix) {
1026
+ this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix);
1027
+ }
1028
+ this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
1029
+ }
1030
+ else {
1031
+ Matrix.ComposeToRef(scaling, rotation, translation, this._localMatrix);
1032
+ }
1033
+ // Parent
1034
+ if (parent && parent.getWorldMatrix) {
1035
+ if (force) {
1036
+ parent.computeWorldMatrix(force);
1069
1037
  }
1070
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
1071
- eulerAngles.y = 0;
1038
+ if (this.billboardMode) {
1039
+ if (this._transformToBoneReferal) {
1040
+ const bone = this.parent;
1041
+ bone.getSkeleton().prepare();
1042
+ bone.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), TmpVectors.Matrix[7]);
1043
+ }
1044
+ else {
1045
+ TmpVectors.Matrix[7].copyFrom(parent.getWorldMatrix());
1046
+ }
1047
+ // Extract scaling and translation from parent
1048
+ const translation = TmpVectors.Vector3[5];
1049
+ const scale = TmpVectors.Vector3[6];
1050
+ const orientation = TmpVectors.Quaternion[0];
1051
+ TmpVectors.Matrix[7].decompose(scale, orientation, translation);
1052
+ Matrix.ScalingToRef(scale.x, scale.y, scale.z, TmpVectors.Matrix[7]);
1053
+ TmpVectors.Matrix[7].setTranslation(translation);
1054
+ if (_a.BillboardUseParentOrientation) {
1055
+ // set localMatrix translation to be transformed against parent's orientation.
1056
+ this._position.applyRotationQuaternionToRef(orientation, translation);
1057
+ this._localMatrix.setTranslation(translation);
1058
+ }
1059
+ this._localMatrix.multiplyToRef(TmpVectors.Matrix[7], this._worldMatrix);
1072
1060
  }
1073
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
1074
- eulerAngles.z = 0;
1061
+ else {
1062
+ if (this._transformToBoneReferal) {
1063
+ const bone = this.parent;
1064
+ bone.getSkeleton().prepare();
1065
+ this._localMatrix.multiplyToRef(bone.getFinalMatrix(), TmpVectors.Matrix[6]);
1066
+ TmpVectors.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
1067
+ }
1068
+ else {
1069
+ this._localMatrix.multiplyToRef(parent.getWorldMatrix(), this._worldMatrix);
1070
+ }
1075
1071
  }
1076
- if (isRH) {
1077
- eulerAngles.y += Math.PI; // Yaw correction
1072
+ this._markSyncedWithParent();
1073
+ }
1074
+ else {
1075
+ this._worldMatrix.copyFrom(this._localMatrix);
1076
+ }
1077
+ if (camera && this.billboardMode) {
1078
+ // Billboarding based on camera orientation (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
1079
+ if (!cache.useBillboardPosition) {
1080
+ const storedTranslation = TmpVectors.Vector3[0];
1081
+ this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
1082
+ // Get camera view matrix
1083
+ TmpVectors.Matrix[1].copyFrom(camera.getViewMatrix());
1084
+ const isRH = this.getScene().useRightHandedSystem;
1085
+ if (isRH) {
1086
+ // This operation is necessary to cancel out the scaling component of the matrix without decomposing it.
1087
+ // It's a trick to extract only the rotation part.
1088
+ TmpVectors.Matrix[1].multiplyToRef(_a._TmpRHRestore, TmpVectors.Matrix[1]);
1089
+ }
1090
+ // This will cancel the camera rotation
1091
+ TmpVectors.Matrix[1].setTranslationFromFloats(0, 0, 0);
1092
+ TmpVectors.Matrix[1].invertToRef(TmpVectors.Matrix[0]);
1093
+ if ((this.billboardMode & _a.BILLBOARDMODE_ALL) !== _a.BILLBOARDMODE_ALL) {
1094
+ TmpVectors.Matrix[0].decompose(undefined, TmpVectors.Quaternion[0], undefined);
1095
+ const eulerAngles = TmpVectors.Vector3[1];
1096
+ TmpVectors.Quaternion[0].toEulerAnglesToRef(eulerAngles);
1097
+ if ((this.billboardMode & _a.BILLBOARDMODE_X) !== _a.BILLBOARDMODE_X) {
1098
+ eulerAngles.x = 0;
1099
+ }
1100
+ if ((this.billboardMode & _a.BILLBOARDMODE_Y) !== _a.BILLBOARDMODE_Y) {
1101
+ eulerAngles.y = 0;
1102
+ }
1103
+ if ((this.billboardMode & _a.BILLBOARDMODE_Z) !== _a.BILLBOARDMODE_Z) {
1104
+ eulerAngles.z = 0;
1105
+ }
1106
+ if (isRH) {
1107
+ eulerAngles.y += Math.PI; // Yaw correction
1108
+ }
1109
+ Matrix.RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, TmpVectors.Matrix[0]);
1110
+ }
1111
+ this._worldMatrix.setTranslationFromFloats(0, 0, 0);
1112
+ this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix);
1113
+ // Restore translation
1114
+ this._worldMatrix.setTranslation(TmpVectors.Vector3[0]);
1078
1115
  }
1079
- Matrix.RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, TmpVectors.Matrix[0]);
1080
- }
1081
- this._worldMatrix.setTranslationFromFloats(0, 0, 0);
1082
- this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix);
1083
- // Restore translation
1084
- this._worldMatrix.setTranslation(TmpVectors.Vector3[0]);
1085
- }
1086
- // Billboarding based on camera position
1087
- else {
1088
- const storedTranslation = TmpVectors.Vector3[0];
1089
- // Save translation
1090
- this._worldMatrix.getTranslationToRef(storedTranslation);
1091
- // Compute camera position in local space
1092
- const cameraPosition = camera.globalPosition;
1093
- this._worldMatrix.invertToRef(TmpVectors.Matrix[1]);
1094
- const camInObjSpace = TmpVectors.Vector3[1];
1095
- Vector3.TransformCoordinatesToRef(cameraPosition, TmpVectors.Matrix[1], camInObjSpace);
1096
- camInObjSpace.normalize();
1097
- // Find the lookAt info in local space
1098
- const yaw = -Math.atan2(camInObjSpace.z, camInObjSpace.x) + Math.PI / 2;
1099
- const len = Math.sqrt(camInObjSpace.x * camInObjSpace.x + camInObjSpace.z * camInObjSpace.z);
1100
- const pitch = -Math.atan2(camInObjSpace.y, len);
1101
- Quaternion.RotationYawPitchRollToRef(yaw, pitch, 0, TmpVectors.Quaternion[0]);
1102
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
1103
- const eulerAngles = TmpVectors.Vector3[1];
1104
- TmpVectors.Quaternion[0].toEulerAnglesToRef(eulerAngles);
1105
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
1106
- eulerAngles.x = 0;
1116
+ // Billboarding based on camera position
1117
+ else {
1118
+ const storedTranslation = TmpVectors.Vector3[0];
1119
+ // Save translation
1120
+ this._worldMatrix.getTranslationToRef(storedTranslation);
1121
+ // Compute camera position in local space
1122
+ const cameraPosition = camera.globalPosition;
1123
+ this._worldMatrix.invertToRef(TmpVectors.Matrix[1]);
1124
+ const camInObjSpace = TmpVectors.Vector3[1];
1125
+ Vector3.TransformCoordinatesToRef(cameraPosition, TmpVectors.Matrix[1], camInObjSpace);
1126
+ camInObjSpace.normalize();
1127
+ // Find the lookAt info in local space
1128
+ const yaw = -Math.atan2(camInObjSpace.z, camInObjSpace.x) + Math.PI / 2;
1129
+ const len = Math.sqrt(camInObjSpace.x * camInObjSpace.x + camInObjSpace.z * camInObjSpace.z);
1130
+ const pitch = -Math.atan2(camInObjSpace.y, len);
1131
+ Quaternion.RotationYawPitchRollToRef(yaw, pitch, 0, TmpVectors.Quaternion[0]);
1132
+ if ((this.billboardMode & _a.BILLBOARDMODE_ALL) !== _a.BILLBOARDMODE_ALL) {
1133
+ const eulerAngles = TmpVectors.Vector3[1];
1134
+ TmpVectors.Quaternion[0].toEulerAnglesToRef(eulerAngles);
1135
+ if ((this.billboardMode & _a.BILLBOARDMODE_X) !== _a.BILLBOARDMODE_X) {
1136
+ eulerAngles.x = 0;
1137
+ }
1138
+ if ((this.billboardMode & _a.BILLBOARDMODE_Y) !== _a.BILLBOARDMODE_Y) {
1139
+ eulerAngles.y = 0;
1140
+ }
1141
+ if ((this.billboardMode & _a.BILLBOARDMODE_Z) !== _a.BILLBOARDMODE_Z) {
1142
+ eulerAngles.z = 0;
1143
+ }
1144
+ Matrix.RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, TmpVectors.Matrix[0]);
1145
+ }
1146
+ else {
1147
+ Matrix.FromQuaternionToRef(TmpVectors.Quaternion[0], TmpVectors.Matrix[0]);
1148
+ }
1149
+ // Cancel translation
1150
+ this._worldMatrix.setTranslationFromFloats(0, 0, 0);
1151
+ // Rotate according to lookat (diff from local to lookat)
1152
+ this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix);
1153
+ // Restore translation
1154
+ this._worldMatrix.setTranslation(TmpVectors.Vector3[0]);
1107
1155
  }
1108
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
1109
- eulerAngles.y = 0;
1156
+ }
1157
+ // Normal matrix
1158
+ if (!this.ignoreNonUniformScaling) {
1159
+ if (this._scaling.isNonUniformWithinEpsilon(0.000001)) {
1160
+ this._updateNonUniformScalingState(true);
1110
1161
  }
1111
- if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
1112
- eulerAngles.z = 0;
1162
+ else if (parent && parent._nonUniformScaling) {
1163
+ this._updateNonUniformScalingState(parent._nonUniformScaling);
1164
+ }
1165
+ else {
1166
+ this._updateNonUniformScalingState(false);
1113
1167
  }
1114
- Matrix.RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, TmpVectors.Matrix[0]);
1115
1168
  }
1116
1169
  else {
1117
- Matrix.FromQuaternionToRef(TmpVectors.Quaternion[0], TmpVectors.Matrix[0]);
1170
+ this._updateNonUniformScalingState(false);
1171
+ }
1172
+ this._afterComputeWorldMatrix();
1173
+ // Absolute position
1174
+ this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
1175
+ this._isAbsoluteSynced = false;
1176
+ // Callbacks
1177
+ this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
1178
+ if (!this._poseMatrix) {
1179
+ this._poseMatrix = Matrix.Invert(this._worldMatrix);
1118
1180
  }
1119
- // Cancel translation
1120
- this._worldMatrix.setTranslationFromFloats(0, 0, 0);
1121
- // Rotate according to lookat (diff from local to lookat)
1122
- this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix);
1123
- // Restore translation
1124
- this._worldMatrix.setTranslation(TmpVectors.Vector3[0]);
1181
+ // Cache the determinant
1182
+ this._worldMatrixDeterminantIsDirty = true;
1183
+ return this._worldMatrix;
1125
1184
  }
1126
- }
1127
- // Normal matrix
1128
- if (!this.ignoreNonUniformScaling) {
1129
- if (this._scaling.isNonUniformWithinEpsilon(0.000001)) {
1130
- this._updateNonUniformScalingState(true);
1185
+ /**
1186
+ * Resets this nodeTransform's local matrix to Matrix.Identity().
1187
+ * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
1188
+ */
1189
+ resetLocalMatrix(independentOfChildren = true) {
1190
+ this.computeWorldMatrix();
1191
+ if (independentOfChildren) {
1192
+ const children = this.getChildren();
1193
+ for (let i = 0; i < children.length; ++i) {
1194
+ const child = children[i];
1195
+ if (child) {
1196
+ child.computeWorldMatrix();
1197
+ const bakedMatrix = TmpVectors.Matrix[0];
1198
+ child._localMatrix.multiplyToRef(this._localMatrix, bakedMatrix);
1199
+ const tmpRotationQuaternion = TmpVectors.Quaternion[0];
1200
+ bakedMatrix.decompose(child.scaling, tmpRotationQuaternion, child.position);
1201
+ if (child.rotationQuaternion) {
1202
+ child.rotationQuaternion.copyFrom(tmpRotationQuaternion);
1203
+ }
1204
+ else {
1205
+ tmpRotationQuaternion.toEulerAnglesToRef(child.rotation);
1206
+ }
1207
+ }
1208
+ }
1209
+ }
1210
+ this.scaling.copyFromFloats(1, 1, 1);
1211
+ this.position.copyFromFloats(0, 0, 0);
1212
+ this.rotation.copyFromFloats(0, 0, 0);
1213
+ //only if quaternion is already set
1214
+ if (this.rotationQuaternion) {
1215
+ this.rotationQuaternion = Quaternion.Identity();
1216
+ }
1217
+ this._worldMatrix = Matrix.Identity();
1131
1218
  }
1132
- else if (parent && parent._nonUniformScaling) {
1133
- this._updateNonUniformScalingState(parent._nonUniformScaling);
1219
+ _afterComputeWorldMatrix() { }
1220
+ /**
1221
+ * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
1222
+ * @param func callback function to add
1223
+ *
1224
+ * @returns the TransformNode.
1225
+ */
1226
+ registerAfterWorldMatrixUpdate(func) {
1227
+ this.onAfterWorldMatrixUpdateObservable.add(func);
1228
+ return this;
1134
1229
  }
1135
- else {
1136
- this._updateNonUniformScalingState(false);
1230
+ /**
1231
+ * Removes a registered callback function.
1232
+ * @param func callback function to remove
1233
+ * @returns the TransformNode.
1234
+ */
1235
+ unregisterAfterWorldMatrixUpdate(func) {
1236
+ this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
1237
+ return this;
1137
1238
  }
1138
- }
1139
- else {
1140
- this._updateNonUniformScalingState(false);
1141
- }
1142
- this._afterComputeWorldMatrix();
1143
- // Absolute position
1144
- this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
1145
- this._isAbsoluteSynced = false;
1146
- // Callbacks
1147
- this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
1148
- if (!this._poseMatrix) {
1149
- this._poseMatrix = Matrix.Invert(this._worldMatrix);
1150
- }
1151
- // Cache the determinant
1152
- this._worldMatrixDeterminantIsDirty = true;
1153
- return this._worldMatrix;
1154
- }
1155
- /**
1156
- * Resets this nodeTransform's local matrix to Matrix.Identity().
1157
- * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
1158
- */
1159
- resetLocalMatrix(independentOfChildren = true) {
1160
- this.computeWorldMatrix();
1161
- if (independentOfChildren) {
1162
- const children = this.getChildren();
1163
- for (let i = 0; i < children.length; ++i) {
1164
- const child = children[i];
1165
- if (child) {
1166
- child.computeWorldMatrix();
1167
- const bakedMatrix = TmpVectors.Matrix[0];
1168
- child._localMatrix.multiplyToRef(this._localMatrix, bakedMatrix);
1169
- const tmpRotationQuaternion = TmpVectors.Quaternion[0];
1170
- bakedMatrix.decompose(child.scaling, tmpRotationQuaternion, child.position);
1171
- if (child.rotationQuaternion) {
1172
- child.rotationQuaternion.copyFrom(tmpRotationQuaternion);
1173
- }
1174
- else {
1175
- tmpRotationQuaternion.toEulerAnglesToRef(child.rotation);
1239
+ /**
1240
+ * Gets the position of the current mesh in camera space
1241
+ * @param camera defines the camera to use
1242
+ * @returns a position
1243
+ */
1244
+ getPositionInCameraSpace(camera = null) {
1245
+ if (!camera) {
1246
+ camera = this.getScene().activeCamera;
1247
+ }
1248
+ return Vector3.TransformCoordinates(this.getAbsolutePosition(), camera.getViewMatrix());
1249
+ }
1250
+ /**
1251
+ * Returns the distance from the mesh to the active camera
1252
+ * @param camera defines the camera to use
1253
+ * @returns the distance
1254
+ */
1255
+ getDistanceToCamera(camera = null) {
1256
+ if (!camera) {
1257
+ camera = this.getScene().activeCamera;
1258
+ }
1259
+ return this.getAbsolutePosition().subtract(camera.globalPosition).length();
1260
+ }
1261
+ /**
1262
+ * Clone the current transform node
1263
+ * @param name Name of the new clone
1264
+ * @param newParent New parent for the clone
1265
+ * @param doNotCloneChildren Do not clone children hierarchy
1266
+ * @returns the new transform node
1267
+ */
1268
+ clone(name, newParent, doNotCloneChildren) {
1269
+ const result = SerializationHelper.Clone(() => new _a(name, this.getScene()), this);
1270
+ result.name = name;
1271
+ result.id = name;
1272
+ if (newParent) {
1273
+ result.parent = newParent;
1274
+ }
1275
+ if (!doNotCloneChildren) {
1276
+ // Children
1277
+ const directDescendants = this.getDescendants(true);
1278
+ for (let index = 0; index < directDescendants.length; index++) {
1279
+ const child = directDescendants[index];
1280
+ if (child.clone) {
1281
+ child.clone(name + "." + child.name, result);
1282
+ }
1176
1283
  }
1177
1284
  }
1285
+ return result;
1178
1286
  }
1179
- }
1180
- this.scaling.copyFromFloats(1, 1, 1);
1181
- this.position.copyFromFloats(0, 0, 0);
1182
- this.rotation.copyFromFloats(0, 0, 0);
1183
- //only if quaternion is already set
1184
- if (this.rotationQuaternion) {
1185
- this.rotationQuaternion = Quaternion.Identity();
1186
- }
1187
- this._worldMatrix = Matrix.Identity();
1188
- }
1189
- _afterComputeWorldMatrix() { }
1190
- /**
1191
- * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
1192
- * @param func callback function to add
1193
- *
1194
- * @returns the TransformNode.
1195
- */
1196
- registerAfterWorldMatrixUpdate(func) {
1197
- this.onAfterWorldMatrixUpdateObservable.add(func);
1198
- return this;
1199
- }
1200
- /**
1201
- * Removes a registered callback function.
1202
- * @param func callback function to remove
1203
- * @returns the TransformNode.
1204
- */
1205
- unregisterAfterWorldMatrixUpdate(func) {
1206
- this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
1207
- return this;
1208
- }
1209
- /**
1210
- * Gets the position of the current mesh in camera space
1211
- * @param camera defines the camera to use
1212
- * @returns a position
1213
- */
1214
- getPositionInCameraSpace(camera = null) {
1215
- if (!camera) {
1216
- camera = this.getScene().activeCamera;
1217
- }
1218
- return Vector3.TransformCoordinates(this.getAbsolutePosition(), camera.getViewMatrix());
1219
- }
1220
- /**
1221
- * Returns the distance from the mesh to the active camera
1222
- * @param camera defines the camera to use
1223
- * @returns the distance
1224
- */
1225
- getDistanceToCamera(camera = null) {
1226
- if (!camera) {
1227
- camera = this.getScene().activeCamera;
1228
- }
1229
- return this.getAbsolutePosition().subtract(camera.globalPosition).length();
1230
- }
1231
- /**
1232
- * Clone the current transform node
1233
- * @param name Name of the new clone
1234
- * @param newParent New parent for the clone
1235
- * @param doNotCloneChildren Do not clone children hierarchy
1236
- * @returns the new transform node
1237
- */
1238
- clone(name, newParent, doNotCloneChildren) {
1239
- const result = SerializationHelper.Clone(() => new TransformNode(name, this.getScene()), this);
1240
- result.name = name;
1241
- result.id = name;
1242
- if (newParent) {
1243
- result.parent = newParent;
1244
- }
1245
- if (!doNotCloneChildren) {
1246
- // Children
1247
- const directDescendants = this.getDescendants(true);
1248
- for (let index = 0; index < directDescendants.length; index++) {
1249
- const child = directDescendants[index];
1250
- if (child.clone) {
1251
- child.clone(name + "." + child.name, result);
1287
+ /**
1288
+ * Serializes the objects information.
1289
+ * @param currentSerializationObject defines the object to serialize in
1290
+ * @returns the serialized object
1291
+ */
1292
+ serialize(currentSerializationObject) {
1293
+ const serializationObject = SerializationHelper.Serialize(this, currentSerializationObject);
1294
+ serializationObject.type = this.getClassName();
1295
+ serializationObject.uniqueId = this.uniqueId;
1296
+ // Parent
1297
+ if (this.parent) {
1298
+ this.parent._serializeAsParent(serializationObject);
1299
+ }
1300
+ serializationObject.localMatrix = this.getPivotMatrix().asArray();
1301
+ serializationObject.isEnabled = this.isEnabled();
1302
+ if (this._isWorldMatrixFrozen) {
1303
+ serializationObject.freezeWorldMatrix = true;
1252
1304
  }
1305
+ // Animations
1306
+ SerializationHelper.AppendSerializedAnimations(this, serializationObject);
1307
+ serializationObject.ranges = this.serializeAnimationRanges();
1308
+ return serializationObject;
1253
1309
  }
1254
- }
1255
- return result;
1256
- }
1257
- /**
1258
- * Serializes the objects information.
1259
- * @param currentSerializationObject defines the object to serialize in
1260
- * @returns the serialized object
1261
- */
1262
- serialize(currentSerializationObject) {
1263
- const serializationObject = SerializationHelper.Serialize(this, currentSerializationObject);
1264
- serializationObject.type = this.getClassName();
1265
- serializationObject.uniqueId = this.uniqueId;
1266
- // Parent
1267
- if (this.parent) {
1268
- this.parent._serializeAsParent(serializationObject);
1269
- }
1270
- serializationObject.localMatrix = this.getPivotMatrix().asArray();
1271
- serializationObject.isEnabled = this.isEnabled();
1272
- if (this._isWorldMatrixFrozen) {
1273
- serializationObject.freezeWorldMatrix = true;
1274
- }
1275
- // Animations
1276
- SerializationHelper.AppendSerializedAnimations(this, serializationObject);
1277
- serializationObject.ranges = this.serializeAnimationRanges();
1278
- return serializationObject;
1279
- }
1280
- /**
1281
- * Get all child-transformNodes of this node
1282
- * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
1283
- * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
1284
- * @returns an array of TransformNode
1285
- */
1286
- getChildTransformNodes(directDescendantsOnly, predicate) {
1287
- const results = [];
1288
- this._getDescendants(results, directDescendantsOnly, (node) => {
1289
- return (!predicate || predicate(node)) && node instanceof TransformNode;
1290
- });
1291
- return results;
1292
- }
1293
- /**
1294
- * Releases resources associated with this transform node.
1295
- * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
1296
- * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
1297
- */
1298
- dispose(doNotRecurse, disposeMaterialAndTextures = false) {
1299
- // Animations
1300
- this.getScene().stopAnimation(this);
1301
- // Remove from scene
1302
- this.getScene().removeTransformNode(this);
1303
- if (this._parentContainer) {
1304
- const index = this._parentContainer.transformNodes.indexOf(this);
1305
- if (index > -1) {
1306
- this._parentContainer.transformNodes.splice(index, 1);
1307
- }
1308
- this._parentContainer = null;
1309
- }
1310
- this.onAfterWorldMatrixUpdateObservable.clear();
1311
- if (doNotRecurse) {
1312
- const transformNodes = this.getChildTransformNodes(true);
1313
- for (const transformNode of transformNodes) {
1314
- transformNode.parent = null;
1315
- transformNode.computeWorldMatrix(true);
1310
+ /**
1311
+ * Get all child-transformNodes of this node
1312
+ * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
1313
+ * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
1314
+ * @returns an array of TransformNode
1315
+ */
1316
+ getChildTransformNodes(directDescendantsOnly, predicate) {
1317
+ const results = [];
1318
+ this._getDescendants(results, directDescendantsOnly, (node) => {
1319
+ return (!predicate || predicate(node)) && node instanceof _a;
1320
+ });
1321
+ return results;
1316
1322
  }
1317
- }
1318
- super.dispose(doNotRecurse, disposeMaterialAndTextures);
1319
- }
1320
- /**
1321
- * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
1322
- * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
1323
- * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
1324
- * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
1325
- * @returns the current mesh
1326
- */
1327
- normalizeToUnitCube(includeDescendants = true, ignoreRotation = false, predicate) {
1328
- let storedRotation = null;
1329
- let storedRotationQuaternion = null;
1330
- if (ignoreRotation) {
1331
- if (this.rotationQuaternion) {
1332
- storedRotationQuaternion = this.rotationQuaternion.clone();
1333
- this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
1334
- }
1335
- else if (this.rotation) {
1336
- storedRotation = this.rotation.clone();
1337
- this.rotation.copyFromFloats(0, 0, 0);
1323
+ /**
1324
+ * Releases resources associated with this transform node.
1325
+ * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
1326
+ * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
1327
+ */
1328
+ dispose(doNotRecurse, disposeMaterialAndTextures = false) {
1329
+ // Animations
1330
+ this.getScene().stopAnimation(this);
1331
+ // Remove from scene
1332
+ this.getScene().removeTransformNode(this);
1333
+ if (this._parentContainer) {
1334
+ const index = this._parentContainer.transformNodes.indexOf(this);
1335
+ if (index > -1) {
1336
+ this._parentContainer.transformNodes.splice(index, 1);
1337
+ }
1338
+ this._parentContainer = null;
1339
+ }
1340
+ this.onAfterWorldMatrixUpdateObservable.clear();
1341
+ if (doNotRecurse) {
1342
+ const transformNodes = this.getChildTransformNodes(true);
1343
+ for (const transformNode of transformNodes) {
1344
+ transformNode.parent = null;
1345
+ transformNode.computeWorldMatrix(true);
1346
+ }
1347
+ }
1348
+ super.dispose(doNotRecurse, disposeMaterialAndTextures);
1338
1349
  }
1339
- }
1340
- const boundingVectors = this.getHierarchyBoundingVectors(includeDescendants, predicate);
1341
- const sizeVec = boundingVectors.max.subtract(boundingVectors.min);
1342
- const maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
1343
- if (maxDimension === 0) {
1344
- return this;
1345
- }
1346
- const scale = 1 / maxDimension;
1347
- this.scaling.scaleInPlace(scale);
1348
- if (ignoreRotation) {
1349
- if (this.rotationQuaternion && storedRotationQuaternion) {
1350
- this.rotationQuaternion.copyFrom(storedRotationQuaternion);
1350
+ /**
1351
+ * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
1352
+ * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
1353
+ * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
1354
+ * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
1355
+ * @returns the current mesh
1356
+ */
1357
+ normalizeToUnitCube(includeDescendants = true, ignoreRotation = false, predicate) {
1358
+ let storedRotation = null;
1359
+ let storedRotationQuaternion = null;
1360
+ if (ignoreRotation) {
1361
+ if (this.rotationQuaternion) {
1362
+ storedRotationQuaternion = this.rotationQuaternion.clone();
1363
+ this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
1364
+ }
1365
+ else if (this.rotation) {
1366
+ storedRotation = this.rotation.clone();
1367
+ this.rotation.copyFromFloats(0, 0, 0);
1368
+ }
1369
+ }
1370
+ const boundingVectors = this.getHierarchyBoundingVectors(includeDescendants, predicate);
1371
+ const sizeVec = boundingVectors.max.subtract(boundingVectors.min);
1372
+ const maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
1373
+ if (maxDimension === 0) {
1374
+ return this;
1375
+ }
1376
+ const scale = 1 / maxDimension;
1377
+ this.scaling.scaleInPlace(scale);
1378
+ if (ignoreRotation) {
1379
+ if (this.rotationQuaternion && storedRotationQuaternion) {
1380
+ this.rotationQuaternion.copyFrom(storedRotationQuaternion);
1381
+ }
1382
+ else if (this.rotation && storedRotation) {
1383
+ this.rotation.copyFrom(storedRotation);
1384
+ }
1385
+ }
1386
+ return this;
1351
1387
  }
1352
- else if (this.rotation && storedRotation) {
1353
- this.rotation.copyFrom(storedRotation);
1388
+ _syncAbsoluteScalingAndRotation() {
1389
+ if (!this._isAbsoluteSynced) {
1390
+ this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion);
1391
+ this._isAbsoluteSynced = true;
1392
+ }
1354
1393
  }
1355
- }
1356
- return this;
1357
- }
1358
- _syncAbsoluteScalingAndRotation() {
1359
- if (!this._isAbsoluteSynced) {
1360
- this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion);
1361
- this._isAbsoluteSynced = true;
1362
- }
1363
- }
1364
- }
1365
- // Statics
1366
- /**
1367
- * Object will not rotate to face the camera
1368
- */
1369
- TransformNode.BILLBOARDMODE_NONE = 0;
1370
- /**
1371
- * Object will rotate to face the camera but only on the x axis
1372
- */
1373
- TransformNode.BILLBOARDMODE_X = 1;
1374
- /**
1375
- * Object will rotate to face the camera but only on the y axis
1376
- */
1377
- TransformNode.BILLBOARDMODE_Y = 2;
1378
- /**
1379
- * Object will rotate to face the camera but only on the z axis
1380
- */
1381
- TransformNode.BILLBOARDMODE_Z = 4;
1382
- /**
1383
- * Object will rotate to face the camera
1384
- */
1385
- TransformNode.BILLBOARDMODE_ALL = 7;
1386
- /**
1387
- * Object will rotate to face the camera's position instead of orientation
1388
- */
1389
- TransformNode.BILLBOARDMODE_USE_POSITION = 128;
1390
- /**
1391
- * Child transform with Billboard flags should or should not apply parent rotation (default if off)
1392
- */
1393
- TransformNode.BillboardUseParentOrientation = false;
1394
- TransformNode._TmpRotation = Quaternion.Zero();
1395
- TransformNode._TmpScaling = Vector3.Zero();
1396
- TransformNode._TmpTranslation = Vector3.Zero();
1397
- // eslint-disable-next-line @typescript-eslint/naming-convention
1398
- TransformNode._TmpRHRestore = Matrix.Scaling(1, 1, -1);
1399
- TransformNode._LookAtVectorCache = new Vector3(0, 0, 0);
1400
- TransformNode._RotationAxisCache = new Quaternion();
1401
- __decorate([
1402
- serializeAsVector3("position")
1403
- ], TransformNode.prototype, "_position", void 0);
1404
- __decorate([
1405
- serializeAsVector3("rotation")
1406
- ], TransformNode.prototype, "_rotation", void 0);
1407
- __decorate([
1408
- serializeAsQuaternion("rotationQuaternion")
1409
- ], TransformNode.prototype, "_rotationQuaternion", void 0);
1410
- __decorate([
1411
- serializeAsVector3("scaling")
1412
- ], TransformNode.prototype, "_scaling", void 0);
1413
- __decorate([
1414
- serialize("billboardMode")
1415
- ], TransformNode.prototype, "_billboardMode", void 0);
1416
- __decorate([
1417
- serialize()
1418
- ], TransformNode.prototype, "scalingDeterminant", void 0);
1419
- __decorate([
1420
- serialize("infiniteDistance")
1421
- ], TransformNode.prototype, "_infiniteDistance", void 0);
1422
- __decorate([
1423
- serialize()
1424
- ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
1425
- __decorate([
1426
- serialize()
1427
- ], TransformNode.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0);
1394
+ },
1395
+ (() => {
1396
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1397
+ __position_decorators = [serializeAsVector3("position")];
1398
+ __rotation_decorators = [serializeAsVector3("rotation")];
1399
+ __rotationQuaternion_decorators = [serializeAsQuaternion("rotationQuaternion")];
1400
+ __scaling_decorators = [serializeAsVector3("scaling")];
1401
+ __billboardMode_decorators = [serialize("billboardMode")];
1402
+ _scalingDeterminant_decorators = [serialize()];
1403
+ __infiniteDistance_decorators = [serialize("infiniteDistance")];
1404
+ _ignoreNonUniformScaling_decorators = [serialize()];
1405
+ _reIntegrateRotationIntoRotationQuaternion_decorators = [serialize()];
1406
+ __esDecorate(null, null, __position_decorators, { kind: "field", name: "_position", static: false, private: false, access: { has: obj => "_position" in obj, get: obj => obj._position, set: (obj, value) => { obj._position = value; } }, metadata: _metadata }, __position_initializers, __position_extraInitializers);
1407
+ __esDecorate(null, null, __rotation_decorators, { kind: "field", name: "_rotation", static: false, private: false, access: { has: obj => "_rotation" in obj, get: obj => obj._rotation, set: (obj, value) => { obj._rotation = value; } }, metadata: _metadata }, __rotation_initializers, __rotation_extraInitializers);
1408
+ __esDecorate(null, null, __rotationQuaternion_decorators, { kind: "field", name: "_rotationQuaternion", static: false, private: false, access: { has: obj => "_rotationQuaternion" in obj, get: obj => obj._rotationQuaternion, set: (obj, value) => { obj._rotationQuaternion = value; } }, metadata: _metadata }, __rotationQuaternion_initializers, __rotationQuaternion_extraInitializers);
1409
+ __esDecorate(null, null, __scaling_decorators, { kind: "field", name: "_scaling", static: false, private: false, access: { has: obj => "_scaling" in obj, get: obj => obj._scaling, set: (obj, value) => { obj._scaling = value; } }, metadata: _metadata }, __scaling_initializers, __scaling_extraInitializers);
1410
+ __esDecorate(null, null, __billboardMode_decorators, { kind: "field", name: "_billboardMode", static: false, private: false, access: { has: obj => "_billboardMode" in obj, get: obj => obj._billboardMode, set: (obj, value) => { obj._billboardMode = value; } }, metadata: _metadata }, __billboardMode_initializers, __billboardMode_extraInitializers);
1411
+ __esDecorate(null, null, _scalingDeterminant_decorators, { kind: "field", name: "scalingDeterminant", static: false, private: false, access: { has: obj => "scalingDeterminant" in obj, get: obj => obj.scalingDeterminant, set: (obj, value) => { obj.scalingDeterminant = value; } }, metadata: _metadata }, _scalingDeterminant_initializers, _scalingDeterminant_extraInitializers);
1412
+ __esDecorate(null, null, __infiniteDistance_decorators, { kind: "field", name: "_infiniteDistance", static: false, private: false, access: { has: obj => "_infiniteDistance" in obj, get: obj => obj._infiniteDistance, set: (obj, value) => { obj._infiniteDistance = value; } }, metadata: _metadata }, __infiniteDistance_initializers, __infiniteDistance_extraInitializers);
1413
+ __esDecorate(null, null, _ignoreNonUniformScaling_decorators, { kind: "field", name: "ignoreNonUniformScaling", static: false, private: false, access: { has: obj => "ignoreNonUniformScaling" in obj, get: obj => obj.ignoreNonUniformScaling, set: (obj, value) => { obj.ignoreNonUniformScaling = value; } }, metadata: _metadata }, _ignoreNonUniformScaling_initializers, _ignoreNonUniformScaling_extraInitializers);
1414
+ __esDecorate(null, null, _reIntegrateRotationIntoRotationQuaternion_decorators, { kind: "field", name: "reIntegrateRotationIntoRotationQuaternion", static: false, private: false, access: { has: obj => "reIntegrateRotationIntoRotationQuaternion" in obj, get: obj => obj.reIntegrateRotationIntoRotationQuaternion, set: (obj, value) => { obj.reIntegrateRotationIntoRotationQuaternion = value; } }, metadata: _metadata }, _reIntegrateRotationIntoRotationQuaternion_initializers, _reIntegrateRotationIntoRotationQuaternion_extraInitializers);
1415
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1416
+ })(),
1417
+ // Statics
1418
+ /**
1419
+ * Object will not rotate to face the camera
1420
+ */
1421
+ _a.BILLBOARDMODE_NONE = 0,
1422
+ /**
1423
+ * Object will rotate to face the camera but only on the x axis
1424
+ */
1425
+ _a.BILLBOARDMODE_X = 1,
1426
+ /**
1427
+ * Object will rotate to face the camera but only on the y axis
1428
+ */
1429
+ _a.BILLBOARDMODE_Y = 2,
1430
+ /**
1431
+ * Object will rotate to face the camera but only on the z axis
1432
+ */
1433
+ _a.BILLBOARDMODE_Z = 4,
1434
+ /**
1435
+ * Object will rotate to face the camera
1436
+ */
1437
+ _a.BILLBOARDMODE_ALL = 7,
1438
+ /**
1439
+ * Object will rotate to face the camera's position instead of orientation
1440
+ */
1441
+ _a.BILLBOARDMODE_USE_POSITION = 128,
1442
+ /**
1443
+ * Child transform with Billboard flags should or should not apply parent rotation (default if off)
1444
+ */
1445
+ _a.BillboardUseParentOrientation = false,
1446
+ _a._TmpRotation = Quaternion.Zero(),
1447
+ _a._TmpScaling = Vector3.Zero(),
1448
+ _a._TmpTranslation = Vector3.Zero(),
1449
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1450
+ _a._TmpRHRestore = Matrix.Scaling(1, 1, -1),
1451
+ _a._LookAtVectorCache = new Vector3(0, 0, 0),
1452
+ _a._RotationAxisCache = new Quaternion(),
1453
+ _a;
1454
+ })();
1455
+ export { TransformNode };
1428
1456
  /**
1429
1457
  * Returns a new TransformNode object parsed from the source provided.
1430
1458
  * @param parsedTransformNode is the source.