@babylonjs/core 5.26.1 → 5.27.1

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 (433) hide show
  1. package/Animations/animatable.js +2 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/runtimeAnimation.js +1 -1
  4. package/Animations/runtimeAnimation.js.map +1 -1
  5. package/Audio/audioSceneComponent.js +2 -1
  6. package/Audio/audioSceneComponent.js.map +1 -1
  7. package/Audio/sound.js +70 -45
  8. package/Audio/sound.js.map +1 -1
  9. package/Audio/soundTrack.js +12 -6
  10. package/Audio/soundTrack.js.map +1 -1
  11. package/BakedVertexAnimation/bakedVertexAnimationManager.js +2 -1
  12. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  13. package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
  14. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  15. package/Behaviors/Meshes/followBehavior.js +2 -1
  16. package/Behaviors/Meshes/followBehavior.js.map +1 -1
  17. package/Behaviors/Meshes/handConstraintBehavior.js +2 -2
  18. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  19. package/Bones/bone.js +2 -1
  20. package/Bones/bone.js.map +1 -1
  21. package/Bones/skeleton.js +3 -2
  22. package/Bones/skeleton.js.map +1 -1
  23. package/Cameras/Inputs/BaseCameraPointersInput.js +2 -2
  24. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  25. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +5 -3
  26. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  27. package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
  28. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  29. package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
  30. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  31. package/Cameras/arcRotateCamera.js +2 -1
  32. package/Cameras/arcRotateCamera.js.map +1 -1
  33. package/Cameras/camera.js +6 -4
  34. package/Cameras/camera.js.map +1 -1
  35. package/Compute/computeEffect.js +8 -5
  36. package/Compute/computeEffect.js.map +1 -1
  37. package/Compute/computeShader.js +12 -11
  38. package/Compute/computeShader.js.map +1 -1
  39. package/Culling/Octrees/octreeSceneComponent.js +2 -1
  40. package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
  41. package/Culling/boundingBox.js +3 -2
  42. package/Culling/boundingBox.js.map +1 -1
  43. package/Culling/ray.js +2 -1
  44. package/Culling/ray.js.map +1 -1
  45. package/Debug/debugLayer.d.ts +3 -3
  46. package/Debug/debugLayer.js +2 -2
  47. package/Debug/debugLayer.js.map +1 -1
  48. package/Debug/directionalLightFrustumViewer.js +9 -7
  49. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  50. package/Debug/rayHelper.js +2 -1
  51. package/Debug/rayHelper.js.map +1 -1
  52. package/Debug/skeletonViewer.js +29 -24
  53. package/Debug/skeletonViewer.js.map +1 -1
  54. package/DeviceInput/InputDevices/deviceSourceManager.js +5 -3
  55. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  56. package/DeviceInput/internalDeviceSourceManager.js +2 -1
  57. package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
  58. package/DeviceInput/webDeviceInputSystem.js +12 -9
  59. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  60. package/Engines/Extensions/engine.rawTexture.js +4 -4
  61. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  62. package/Engines/Extensions/engine.readTexture.js +3 -2
  63. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  64. package/Engines/Extensions/engine.views.js +2 -1
  65. package/Engines/Extensions/engine.views.js.map +1 -1
  66. package/Engines/Processors/shaderProcessor.js +11 -6
  67. package/Engines/Processors/shaderProcessor.js.map +1 -1
  68. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +1 -1
  69. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  70. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +2 -1
  71. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
  72. package/Engines/WebGPU/Extensions/engine.multiRender.js +2 -1
  73. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  74. package/Engines/WebGPU/Extensions/engine.query.js +4 -2
  75. package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
  76. package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
  77. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  78. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -1
  79. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  80. package/Engines/WebGPU/Extensions/engine.storageBuffer.js +3 -2
  81. package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
  82. package/Engines/WebGPU/Extensions/engine.textureSampler.js +2 -1
  83. package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
  84. package/Engines/WebGPU/Extensions/engine.videoTexture.js +2 -1
  85. package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
  86. package/Engines/WebGPU/webgpuCacheBindGroups.js +7 -6
  87. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  88. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +18 -14
  89. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  90. package/Engines/WebGPU/webgpuCacheSampler.js +4 -3
  91. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  92. package/Engines/WebGPU/webgpuClearQuad.js +3 -2
  93. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  94. package/Engines/WebGPU/webgpuComputePipelineContext.js +2 -1
  95. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  96. package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
  97. package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
  98. package/Engines/WebGPU/webgpuDrawContext.js +2 -1
  99. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  100. package/Engines/WebGPU/webgpuHardwareTexture.js +4 -3
  101. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  102. package/Engines/WebGPU/webgpuMaterialContext.js +5 -4
  103. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  104. package/Engines/WebGPU/webgpuOcclusionQuery.js +5 -3
  105. package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
  106. package/Engines/WebGPU/webgpuPipelineContext.js +4 -2
  107. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  108. package/Engines/WebGPU/webgpuShaderProcessingContext.js +4 -2
  109. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  110. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -1
  111. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  112. package/Engines/WebGPU/webgpuSnapshotRendering.js +3 -2
  113. package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
  114. package/Engines/WebGPU/webgpuStencilStateComposer.js +2 -1
  115. package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
  116. package/Engines/WebGPU/webgpuTextureHelper.js +40 -38
  117. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  118. package/Engines/engine.js +5 -3
  119. package/Engines/engine.js.map +1 -1
  120. package/Engines/nativeEngine.js +7 -5
  121. package/Engines/nativeEngine.js.map +1 -1
  122. package/Engines/renderTargetWrapper.js +14 -9
  123. package/Engines/renderTargetWrapper.js.map +1 -1
  124. package/Engines/thinEngine.js +29 -20
  125. package/Engines/thinEngine.js.map +1 -1
  126. package/Engines/webgpuEngine.js +87 -61
  127. package/Engines/webgpuEngine.js.map +1 -1
  128. package/Gamepads/gamepadManager.js +1 -1
  129. package/Gamepads/gamepadManager.js.map +1 -1
  130. package/Gizmos/axisDragGizmo.js +4 -2
  131. package/Gizmos/axisDragGizmo.js.map +1 -1
  132. package/Gizmos/axisScaleGizmo.js +6 -4
  133. package/Gizmos/axisScaleGizmo.js.map +1 -1
  134. package/Gizmos/gizmo.js +21 -6
  135. package/Gizmos/gizmo.js.map +1 -1
  136. package/Gizmos/gizmoManager.js +3 -2
  137. package/Gizmos/gizmoManager.js.map +1 -1
  138. package/Gizmos/planeDragGizmo.js +4 -2
  139. package/Gizmos/planeDragGizmo.js.map +1 -1
  140. package/Gizmos/planeRotationGizmo.js +4 -2
  141. package/Gizmos/planeRotationGizmo.js.map +1 -1
  142. package/Helpers/videoDome.js +2 -1
  143. package/Helpers/videoDome.js.map +1 -1
  144. package/Inputs/scene.inputManager.js +1 -1
  145. package/Inputs/scene.inputManager.js.map +1 -1
  146. package/Layers/effectLayer.js +5 -3
  147. package/Layers/effectLayer.js.map +1 -1
  148. package/Layers/glowLayer.d.ts +5 -0
  149. package/Layers/glowLayer.js +25 -11
  150. package/Layers/glowLayer.js.map +1 -1
  151. package/Layers/highlightLayer.js +2 -1
  152. package/Layers/highlightLayer.js.map +1 -1
  153. package/LensFlares/lensFlareSystem.js +2 -1
  154. package/LensFlares/lensFlareSystem.js.map +1 -1
  155. package/Lights/Shadows/cascadedShadowGenerator.js +25 -21
  156. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  157. package/Lights/Shadows/shadowGenerator.js +13 -8
  158. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  159. package/Loading/Plugins/babylonFileLoader.js +5 -4
  160. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  161. package/Loading/sceneLoader.js +1 -1
  162. package/Loading/sceneLoader.js.map +1 -1
  163. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +2 -1
  164. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  165. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +2 -1
  166. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  167. package/Materials/Node/Blocks/Dual/textureBlock.js +10 -6
  168. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  169. package/Materials/Node/Blocks/Fragment/TBNBlock.js +3 -2
  170. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  171. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -1
  172. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  173. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -1
  174. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  175. package/Materials/Node/Blocks/Input/inputBlock.js +2 -1
  176. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  177. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +26 -24
  178. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  179. package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
  180. package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
  181. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +48 -44
  182. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  183. package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -1
  184. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  185. package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -1
  186. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  187. package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
  188. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  189. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -26
  190. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  191. package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
  192. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  193. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +6 -6
  194. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  195. package/Materials/Node/Blocks/cloudBlock.js +3 -2
  196. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  197. package/Materials/Node/Blocks/colorMergerBlock.js +5 -4
  198. package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
  199. package/Materials/Node/Blocks/customBlock.js +4 -3
  200. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  201. package/Materials/Node/Blocks/vectorMergerBlock.js +5 -4
  202. package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
  203. package/Materials/Node/nodeMaterial.js +7 -6
  204. package/Materials/Node/nodeMaterial.js.map +1 -1
  205. package/Materials/Node/nodeMaterialBlock.js +4 -3
  206. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  207. package/Materials/Node/nodeMaterialDecorator.js +1 -1
  208. package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
  209. package/Materials/PBR/pbrAnisotropicConfiguration.js +2 -0
  210. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  211. package/Materials/PBR/pbrBaseMaterial.js +25 -19
  212. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  213. package/Materials/PBR/pbrClearCoatConfiguration.js +16 -6
  214. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  215. package/Materials/PBR/pbrIridescenceConfiguration.js +9 -4
  216. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  217. package/Materials/PBR/pbrSheenConfiguration.js +10 -4
  218. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  219. package/Materials/PBR/pbrSubSurfaceConfiguration.js +22 -0
  220. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  221. package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
  222. package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
  223. package/Materials/Textures/Packer/packer.js +14 -13
  224. package/Materials/Textures/Packer/packer.js.map +1 -1
  225. package/Materials/Textures/Procedurals/customProceduralTexture.d.ts +2 -1
  226. package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
  227. package/Materials/Textures/Procedurals/noiseProceduralTexture.js +2 -1
  228. package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
  229. package/Materials/Textures/Procedurals/proceduralTexture.js +7 -4
  230. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  231. package/Materials/Textures/cubeTexture.js +8 -4
  232. package/Materials/Textures/cubeTexture.js.map +1 -1
  233. package/Materials/Textures/hdrCubeTexture.js +4 -2
  234. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  235. package/Materials/Textures/internalTexture.js +4 -2
  236. package/Materials/Textures/internalTexture.js.map +1 -1
  237. package/Materials/Textures/mirrorTexture.js +6 -3
  238. package/Materials/Textures/mirrorTexture.js.map +1 -1
  239. package/Materials/Textures/multiRenderTarget.js +6 -4
  240. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  241. package/Materials/Textures/rawTexture.js +1 -1
  242. package/Materials/Textures/rawTexture.js.map +1 -1
  243. package/Materials/Textures/renderTargetTexture.js +26 -15
  244. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  245. package/Materials/Textures/texture.d.ts +7 -2
  246. package/Materials/Textures/texture.js +49 -41
  247. package/Materials/Textures/texture.js.map +1 -1
  248. package/Materials/Textures/thinRenderTargetTexture.js +4 -2
  249. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  250. package/Materials/Textures/videoTexture.js +3 -3
  251. package/Materials/Textures/videoTexture.js.map +1 -1
  252. package/Materials/drawWrapper.js +4 -2
  253. package/Materials/drawWrapper.js.map +1 -1
  254. package/Materials/effect.js +15 -10
  255. package/Materials/effect.js.map +1 -1
  256. package/Materials/material.d.ts +14 -0
  257. package/Materials/material.detailMapConfiguration.js +2 -1
  258. package/Materials/material.detailMapConfiguration.js.map +1 -1
  259. package/Materials/material.js +35 -3
  260. package/Materials/material.js.map +1 -1
  261. package/Materials/materialDefines.js +6 -5
  262. package/Materials/materialDefines.js.map +1 -1
  263. package/Materials/materialHelper.js +1 -1
  264. package/Materials/materialHelper.js.map +1 -1
  265. package/Materials/materialPluginManager.js +3 -2
  266. package/Materials/materialPluginManager.js.map +1 -1
  267. package/Materials/multiMaterial.js +2 -1
  268. package/Materials/multiMaterial.js.map +1 -1
  269. package/Materials/shaderMaterial.js +12 -9
  270. package/Materials/shaderMaterial.js.map +1 -1
  271. package/Materials/shadowDepthWrapper.js +13 -8
  272. package/Materials/shadowDepthWrapper.js.map +1 -1
  273. package/Materials/standardMaterial.js +12 -10
  274. package/Materials/standardMaterial.js.map +1 -1
  275. package/Materials/uniformBuffer.js +1 -1
  276. package/Materials/uniformBuffer.js.map +1 -1
  277. package/Maths/math.polar.d.ts +2 -2
  278. package/Maths/math.polar.js +4 -4
  279. package/Maths/math.polar.js.map +1 -1
  280. package/Maths/math.vector.d.ts +69 -7
  281. package/Maths/math.vector.js +72 -9
  282. package/Maths/math.vector.js.map +1 -1
  283. package/Meshes/Builders/groundBuilder.js +1 -1
  284. package/Meshes/Builders/groundBuilder.js.map +1 -1
  285. package/Meshes/abstractMesh.d.ts +8 -0
  286. package/Meshes/abstractMesh.js +20 -5
  287. package/Meshes/abstractMesh.js.map +1 -1
  288. package/Meshes/csg.js +2 -1
  289. package/Meshes/csg.js.map +1 -1
  290. package/Meshes/instancedMesh.js +2 -1
  291. package/Meshes/instancedMesh.js.map +1 -1
  292. package/Meshes/mesh.js +25 -13
  293. package/Meshes/mesh.js.map +1 -1
  294. package/Meshes/mesh.vertexData.js +4 -3
  295. package/Meshes/mesh.vertexData.js.map +1 -1
  296. package/Meshes/subMesh.js +14 -8
  297. package/Meshes/subMesh.js.map +1 -1
  298. package/Meshes/thinInstanceMesh.js +18 -12
  299. package/Meshes/thinInstanceMesh.js.map +1 -1
  300. package/Meshes/transformNode.js +4 -3
  301. package/Meshes/transformNode.js.map +1 -1
  302. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +2 -1
  303. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  304. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +12 -8
  305. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  306. package/Misc/PerformanceViewer/performanceViewerCollector.js +3 -2
  307. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  308. package/Misc/arrayTools.js +1 -1
  309. package/Misc/arrayTools.js.map +1 -1
  310. package/Misc/computePressure.js +9 -6
  311. package/Misc/computePressure.js.map +1 -1
  312. package/Misc/dataStorage.js +1 -1
  313. package/Misc/dataStorage.js.map +1 -1
  314. package/Misc/environmentTextureTools.js +2 -1
  315. package/Misc/environmentTextureTools.js.map +1 -1
  316. package/Misc/fileTools.js +31 -8
  317. package/Misc/fileTools.js.map +1 -1
  318. package/Misc/logger.js +2 -1
  319. package/Misc/logger.js.map +1 -1
  320. package/Misc/minMaxReducer.js +3 -2
  321. package/Misc/minMaxReducer.js.map +1 -1
  322. package/Misc/sceneRecorder.js +1 -1
  323. package/Misc/sceneRecorder.js.map +1 -1
  324. package/Misc/screenshotTools.js +2 -12
  325. package/Misc/screenshotTools.js.map +1 -1
  326. package/Misc/textureTools.js +3 -3
  327. package/Misc/textureTools.js.map +1 -1
  328. package/Misc/timer.js +5 -3
  329. package/Misc/timer.js.map +1 -1
  330. package/Misc/tools.d.ts +2 -8
  331. package/Misc/tools.js +6 -6
  332. package/Misc/tools.js.map +1 -1
  333. package/Misc/trajectoryClassifier.js +3 -3
  334. package/Misc/trajectoryClassifier.js.map +1 -1
  335. package/Particles/EmitterTypes/meshParticleEmitter.js +2 -1
  336. package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
  337. package/Particles/computeShaderParticleSystem.js +6 -3
  338. package/Particles/computeShaderParticleSystem.js.map +1 -1
  339. package/Particles/gpuParticleSystem.js +13 -8
  340. package/Particles/gpuParticleSystem.js.map +1 -1
  341. package/Particles/particleSystem.js +22 -14
  342. package/Particles/particleSystem.js.map +1 -1
  343. package/Particles/particleSystemComponent.js +2 -1
  344. package/Particles/particleSystemComponent.js.map +1 -1
  345. package/Particles/pointsCloudSystem.js +7 -4
  346. package/Particles/pointsCloudSystem.js.map +1 -1
  347. package/Particles/solidParticleSystem.js +2 -2
  348. package/Particles/solidParticleSystem.js.map +1 -1
  349. package/Particles/webgl2ParticleSystem.js +2 -1
  350. package/Particles/webgl2ParticleSystem.js.map +1 -1
  351. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +5 -4
  352. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  353. package/PostProcesses/blackAndWhitePostProcess.d.ts +1 -1
  354. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  355. package/PostProcesses/colorCorrectionPostProcess.d.ts +1 -1
  356. package/PostProcesses/colorCorrectionPostProcess.js +2 -1
  357. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  358. package/PostProcesses/postProcess.js +8 -5
  359. package/PostProcesses/postProcess.js.map +1 -1
  360. package/PostProcesses/postProcessManager.js +6 -4
  361. package/PostProcesses/postProcessManager.js.map +1 -1
  362. package/PostProcesses/refractionPostProcess.d.ts +2 -1
  363. package/PostProcesses/refractionPostProcess.js.map +1 -1
  364. package/PostProcesses/screenSpaceReflectionPostProcess.js +1 -1
  365. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  366. package/PostProcesses/tonemapPostProcess.d.ts +2 -1
  367. package/PostProcesses/tonemapPostProcess.js.map +1 -1
  368. package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +2 -1
  369. package/PostProcesses/volumetricLightScatteringPostProcess.js +7 -4
  370. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  371. package/PostProcesses/vrDistortionCorrectionPostProcess.d.ts +2 -1
  372. package/PostProcesses/vrDistortionCorrectionPostProcess.js.map +1 -1
  373. package/PostProcesses/vrMultiviewToSingleviewPostProcess.d.ts +2 -1
  374. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +3 -2
  375. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  376. package/Probes/reflectionProbe.js +4 -2
  377. package/Probes/reflectionProbe.js.map +1 -1
  378. package/Rendering/boundingBoxRenderer.js +3 -2
  379. package/Rendering/boundingBoxRenderer.js.map +1 -1
  380. package/Rendering/depthPeelingRenderer.d.ts +12 -0
  381. package/Rendering/depthPeelingRenderer.js +30 -6
  382. package/Rendering/depthPeelingRenderer.js.map +1 -1
  383. package/Rendering/depthPeelingSceneComponent.js +4 -2
  384. package/Rendering/depthPeelingSceneComponent.js.map +1 -1
  385. package/Rendering/depthRenderer.js +10 -6
  386. package/Rendering/depthRenderer.js.map +1 -1
  387. package/Rendering/edgesRenderer.js +11 -8
  388. package/Rendering/edgesRenderer.js.map +1 -1
  389. package/Rendering/outlineRenderer.js +2 -2
  390. package/Rendering/outlineRenderer.js.map +1 -1
  391. package/Rendering/prePassRenderer.js +4 -2
  392. package/Rendering/prePassRenderer.js.map +1 -1
  393. package/Shaders/pbr.fragment.js +4 -1
  394. package/Shaders/pbr.fragment.js.map +1 -1
  395. package/Sprites/spriteManager.js +2 -1
  396. package/Sprites/spriteManager.js.map +1 -1
  397. package/Sprites/spriteRenderer.js +2 -1
  398. package/Sprites/spriteRenderer.js.map +1 -1
  399. package/States/stencilStateComposer.js +4 -2
  400. package/States/stencilStateComposer.js.map +1 -1
  401. package/XR/features/WebXRAnchorSystem.js +2 -1
  402. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  403. package/XR/features/WebXRControllerMovement.js +7 -6
  404. package/XR/features/WebXRControllerMovement.js.map +1 -1
  405. package/XR/features/WebXRControllerPhysics.js +6 -4
  406. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  407. package/XR/features/WebXRControllerPointerSelection.js +2 -1
  408. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  409. package/XR/features/WebXRHandTracking.js +26 -18
  410. package/XR/features/WebXRHandTracking.js.map +1 -1
  411. package/XR/features/WebXRLayers.js +1 -1
  412. package/XR/features/WebXRLayers.js.map +1 -1
  413. package/XR/features/WebXRLightEstimation.js +6 -3
  414. package/XR/features/WebXRLightEstimation.js.map +1 -1
  415. package/XR/features/WebXRMeshDetector.js +2 -1
  416. package/XR/features/WebXRMeshDetector.js.map +1 -1
  417. package/XR/features/WebXRNearInteraction.js +7 -4
  418. package/XR/features/WebXRNearInteraction.js.map +1 -1
  419. package/XR/features/WebXRPlaneDetector.js +2 -1
  420. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  421. package/XR/native/nativeXRFrame.js +2 -1
  422. package/XR/native/nativeXRFrame.js.map +1 -1
  423. package/XR/webXRCamera.js +2 -1
  424. package/XR/webXRCamera.js.map +1 -1
  425. package/XR/webXRExperienceHelper.js +7 -5
  426. package/XR/webXRExperienceHelper.js.map +1 -1
  427. package/XR/webXRInputSource.js +2 -1
  428. package/XR/webXRInputSource.js.map +1 -1
  429. package/XR/webXRSessionManager.js +27 -14
  430. package/XR/webXRSessionManager.js.map +1 -1
  431. package/package.json +1 -1
  432. package/scene.js +17 -11
  433. package/scene.js.map +1 -1
@@ -33,7 +33,7 @@ export class UniformBuffer {
33
33
  this._engine = engine;
34
34
  this._noUBO = !engine.supportsUniformBuffers || forceNoUniformBuffer;
35
35
  this._dynamic = dynamic;
36
- this._name = name ?? "no-name";
36
+ this._name = name !== null && name !== void 0 ? name : "no-name";
37
37
  this._data = data || [];
38
38
  this._uniformLocations = {};
39
39
  this._uniformSizes = {};
@@ -1 +1 @@
1
- {"version":3,"file":"uniformBuffer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Materials/uniformBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAOxC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,4CAA4C,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,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,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QACpD,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE3C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,cAAc,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAClE,cAAc,CAAC,GAAG,EAAE,CAAC;SACxB;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;gBAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAO,CAAC,CAAC;aACxC;SACJ;aAAM,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;IACL,CAAC;;AAlhCD,gBAAgB;AACF,iCAAmB,GAA+B,EAAE,CAAC;AAqBnE,iCAAiC;AAClB,+BAAiB,GAAG,GAAG,CAAC;AACxB,yBAAW,GAAG,IAAI,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAChE,kCAAoB,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Nullable, FloatArray } from \"../types\";\r\nimport type { IMatrixLike, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from \"../Maths/math.like\";\r\nimport type { Effect } from \"./effect\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Tools } from \"../Misc/tools\";\r\n\r\nimport \"../Engines/Extensions/engine.uniformBuffer\";\r\n\r\n/**\r\n * Uniform buffer objects.\r\n *\r\n * Handles blocks of uniform on the GPU.\r\n *\r\n * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.\r\n *\r\n * For more information, please refer to :\r\n * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object\r\n */\r\nexport class UniformBuffer {\r\n /** @internal */\r\n public static _UpdatedUbosInFrame: { [name: string]: number } = {};\r\n\r\n private _engine: ThinEngine;\r\n private _buffer: Nullable<DataBuffer>;\r\n private _buffers: Array<[DataBuffer, Float32Array | undefined]>;\r\n private _bufferIndex: number;\r\n private _createBufferOnWrite: boolean;\r\n private _data: number[];\r\n private _bufferData: Float32Array;\r\n private _dynamic?: boolean;\r\n private _uniformLocations: { [key: string]: number };\r\n private _uniformSizes: { [key: string]: number };\r\n private _uniformArraySizes: { [key: string]: { strideSize: number; arraySize: number } };\r\n private _uniformLocationPointer: number;\r\n private _needSync: boolean;\r\n private _noUBO: boolean;\r\n private _currentEffect: Effect;\r\n private _currentEffectName: string;\r\n private _name: string;\r\n private _currentFrameId: number;\r\n\r\n // Pool for avoiding memory leaks\r\n private static _MAX_UNIFORM_SIZE = 256;\r\n private static _TempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);\r\n private static _TempBufferInt32View = new Uint32Array(UniformBuffer._TempBuffer.buffer);\r\n\r\n /**\r\n * Lambda to Update a 3x3 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrix3x3: (name: string, matrix: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update a 2x2 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrix2x2: (name: string, matrix: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update a single float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat: (name: string, x: number) => void;\r\n\r\n /**\r\n * Lambda to Update a vec2 of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec3 of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec4 of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update an array of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloatArray: (name: string, array: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update an array of number in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateArray: (name: string, array: number[]) => void;\r\n\r\n /**\r\n * Lambda to Update an array of number in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateIntArray: (name: string, array: Int32Array) => void;\r\n\r\n /**\r\n * Lambda to Update a 4x4 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrix: (name: string, mat: IMatrixLike) => void;\r\n\r\n /**\r\n * Lambda to Update an array of 4x4 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrices: (name: string, mat: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update vec3 of float from a Vector in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateVector3: (name: string, vector: IVector3Like) => void;\r\n\r\n /**\r\n * Lambda to Update vec4 of float from a Vector in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateVector4: (name: string, vector: IVector4Like) => void;\r\n\r\n /**\r\n * Lambda to Update vec3 of float from a Color in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateColor3: (name: string, color: IColor3Like, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update vec4 of float from a Color in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateColor4: (name: string, color: IColor3Like, alpha: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update vec4 of float from a Color in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateDirectColor4: (name: string, color: IColor4Like, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a int a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt: (name: string, x: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec2 of int in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt2: (name: string, x: number, y: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec3 of int in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec4 of int in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;\r\n\r\n /**\r\n * Instantiates a new Uniform buffer objects.\r\n *\r\n * Handles blocks of uniform on the GPU.\r\n *\r\n * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.\r\n *\r\n * For more information, please refer to :\r\n * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object\r\n * @param engine Define the engine the buffer is associated with\r\n * @param data Define the data contained in the buffer\r\n * @param dynamic Define if the buffer is updatable\r\n * @param name to assign to the buffer (debugging purpose)\r\n * @param forceNoUniformBuffer define that this object must not rely on UBO objects\r\n */\r\n constructor(engine: ThinEngine, data?: number[], dynamic?: boolean, name?: string, forceNoUniformBuffer = false) {\r\n this._engine = engine;\r\n this._noUBO = !engine.supportsUniformBuffers || forceNoUniformBuffer;\r\n this._dynamic = dynamic;\r\n this._name = name ?? \"no-name\";\r\n\r\n this._data = data || [];\r\n\r\n this._uniformLocations = {};\r\n this._uniformSizes = {};\r\n this._uniformArraySizes = {};\r\n this._uniformLocationPointer = 0;\r\n this._needSync = false;\r\n\r\n if (this._engine._features.trackUbosInFrame) {\r\n this._buffers = [];\r\n this._bufferIndex = -1;\r\n this._createBufferOnWrite = false;\r\n this._currentFrameId = 0;\r\n }\r\n\r\n if (this._noUBO) {\r\n this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;\r\n this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;\r\n this.updateFloat = this._updateFloatForEffect;\r\n this.updateFloat2 = this._updateFloat2ForEffect;\r\n this.updateFloat3 = this._updateFloat3ForEffect;\r\n this.updateFloat4 = this._updateFloat4ForEffect;\r\n this.updateFloatArray = this._updateFloatArrayForEffect;\r\n this.updateArray = this._updateArrayForEffect;\r\n this.updateIntArray = this._updateIntArrayForEffect;\r\n this.updateMatrix = this._updateMatrixForEffect;\r\n this.updateMatrices = this._updateMatricesForEffect;\r\n this.updateVector3 = this._updateVector3ForEffect;\r\n this.updateVector4 = this._updateVector4ForEffect;\r\n this.updateColor3 = this._updateColor3ForEffect;\r\n this.updateColor4 = this._updateColor4ForEffect;\r\n this.updateDirectColor4 = this._updateDirectColor4ForEffect;\r\n this.updateInt = this._updateIntForEffect;\r\n this.updateInt2 = this._updateInt2ForEffect;\r\n this.updateInt3 = this._updateInt3ForEffect;\r\n this.updateInt4 = this._updateInt4ForEffect;\r\n } else {\r\n this._engine._uniformBuffers.push(this);\r\n\r\n this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;\r\n this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;\r\n this.updateFloat = this._updateFloatForUniform;\r\n this.updateFloat2 = this._updateFloat2ForUniform;\r\n this.updateFloat3 = this._updateFloat3ForUniform;\r\n this.updateFloat4 = this._updateFloat4ForUniform;\r\n this.updateFloatArray = this._updateFloatArrayForUniform;\r\n this.updateArray = this._updateArrayForUniform;\r\n this.updateIntArray = this._updateIntArrayForUniform;\r\n this.updateMatrix = this._updateMatrixForUniform;\r\n this.updateMatrices = this._updateMatricesForUniform;\r\n this.updateVector3 = this._updateVector3ForUniform;\r\n this.updateVector4 = this._updateVector4ForUniform;\r\n this.updateColor3 = this._updateColor3ForUniform;\r\n this.updateColor4 = this._updateColor4ForUniform;\r\n this.updateDirectColor4 = this._updateDirectColor4ForUniform;\r\n this.updateInt = this._updateIntForUniform;\r\n this.updateInt2 = this._updateInt2ForUniform;\r\n this.updateInt3 = this._updateInt3ForUniform;\r\n this.updateInt4 = this._updateInt4ForUniform;\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if the buffer is using the WebGL2 UBO implementation,\r\n * or just falling back on setUniformXXX calls.\r\n */\r\n public get useUbo(): boolean {\r\n return !this._noUBO;\r\n }\r\n\r\n /**\r\n * Indicates if the WebGL underlying uniform buffer is in sync\r\n * with the javascript cache data.\r\n */\r\n public get isSync(): boolean {\r\n return !this._needSync;\r\n }\r\n\r\n /**\r\n * Indicates if the WebGL underlying uniform buffer is dynamic.\r\n * Also, a dynamic UniformBuffer will disable cache verification and always\r\n * update the underlying WebGL uniform buffer to the GPU.\r\n * @returns if Dynamic, otherwise false\r\n */\r\n public isDynamic(): boolean {\r\n return this._dynamic !== undefined;\r\n }\r\n\r\n /**\r\n * The data cache on JS side.\r\n * @returns the underlying data as a float array\r\n */\r\n public getData(): Float32Array {\r\n return this._bufferData;\r\n }\r\n\r\n /**\r\n * The underlying WebGL Uniform buffer.\r\n * @returns the webgl buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * std140 layout specifies how to align data within an UBO structure.\r\n * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159\r\n * for specs.\r\n * @param size\r\n */\r\n private _fillAlignment(size: number) {\r\n // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components\r\n // and 4x4 matrices\r\n // TODO : change if other types are used\r\n\r\n let alignment;\r\n if (size <= 2) {\r\n alignment = size;\r\n } else {\r\n alignment = 4;\r\n }\r\n\r\n if (this._uniformLocationPointer % alignment !== 0) {\r\n const oldPointer = this._uniformLocationPointer;\r\n this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);\r\n const diff = this._uniformLocationPointer - oldPointer;\r\n\r\n for (let i = 0; i < diff; i++) {\r\n this._data.push(0);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Adds an uniform in the buffer.\r\n * Warning : the subsequents calls of this function must be in the same order as declared in the shader\r\n * for the layout to be correct ! The addUniform function only handles types like float, vec2, vec3, vec4, mat4,\r\n * meaning size=1,2,3,4 or 16. It does not handle struct types.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param size Data size, or data directly.\r\n * @param arraySize The number of elements in the array, 0 if not an array.\r\n */\r\n public addUniform(name: string, size: number | number[], arraySize = 0) {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n\r\n if (this._uniformLocations[name] !== undefined) {\r\n // Already existing uniform\r\n return;\r\n }\r\n // This function must be called in the order of the shader layout !\r\n // size can be the size of the uniform, or data directly\r\n let data;\r\n\r\n // std140 FTW...\r\n if (arraySize > 0) {\r\n if (size instanceof Array) {\r\n throw \"addUniform should not be use with Array in UBO: \" + name;\r\n }\r\n\r\n this._fillAlignment(4);\r\n\r\n this._uniformArraySizes[name] = { strideSize: size, arraySize };\r\n if (size == 16) {\r\n size = size * arraySize;\r\n } else {\r\n const perElementPadding = 4 - size;\r\n const totalPadding = perElementPadding * arraySize;\r\n size = size * arraySize + totalPadding;\r\n }\r\n\r\n data = [];\r\n // Fill with zeros\r\n for (let i = 0; i < size; i++) {\r\n data.push(0);\r\n }\r\n } else {\r\n if (size instanceof Array) {\r\n data = size;\r\n size = data.length;\r\n } else {\r\n size = <number>size;\r\n data = [];\r\n\r\n // Fill with zeros\r\n for (let i = 0; i < size; i++) {\r\n data.push(0);\r\n }\r\n }\r\n this._fillAlignment(<number>size);\r\n }\r\n\r\n this._uniformSizes[name] = <number>size;\r\n this._uniformLocations[name] = this._uniformLocationPointer;\r\n this._uniformLocationPointer += <number>size;\r\n\r\n for (let i = 0; i < size; i++) {\r\n this._data.push(data[i]);\r\n }\r\n\r\n this._needSync = true;\r\n }\r\n\r\n /**\r\n * Adds a Matrix 4x4 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param mat A 4x4 matrix.\r\n */\r\n public addMatrix(name: string, mat: IMatrixLike) {\r\n this.addUniform(name, Array.prototype.slice.call(mat.toArray()));\r\n }\r\n\r\n /**\r\n * Adds a vec2 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param x Define the x component value of the vec2\r\n * @param y Define the y component value of the vec2\r\n */\r\n public addFloat2(name: string, x: number, y: number) {\r\n const temp = [x, y];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param x Define the x component value of the vec3\r\n * @param y Define the y component value of the vec3\r\n * @param z Define the z component value of the vec3\r\n */\r\n public addFloat3(name: string, x: number, y: number, z: number) {\r\n const temp = [x, y, z];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param color Define the vec3 from a Color\r\n */\r\n public addColor3(name: string, color: IColor3Like) {\r\n const temp = [color.r, color.g, color.b];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec4 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param color Define the rgb components from a Color\r\n * @param alpha Define the a component of the vec4\r\n */\r\n public addColor4(name: string, color: IColor3Like, alpha: number) {\r\n const temp = [color.r, color.g, color.b, alpha];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param vector Define the vec3 components from a Vector\r\n */\r\n public addVector3(name: string, vector: IVector3Like) {\r\n const temp = [vector.x, vector.y, vector.z];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a Matrix 3x3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n */\r\n public addMatrix3x3(name: string) {\r\n this.addUniform(name, 12);\r\n }\r\n\r\n /**\r\n * Adds a Matrix 2x2 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n */\r\n public addMatrix2x2(name: string) {\r\n this.addUniform(name, 8);\r\n }\r\n\r\n /**\r\n * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.\r\n */\r\n public create(): void {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n if (this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n // See spec, alignment must be filled as a vec4\r\n this._fillAlignment(4);\r\n this._bufferData = new Float32Array(this._data);\r\n\r\n this._rebuild();\r\n\r\n this._needSync = true;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (this._noUBO || !this._bufferData) {\r\n return;\r\n }\r\n\r\n if (this._dynamic) {\r\n this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);\r\n } else {\r\n this._buffer = this._engine.createUniformBuffer(this._bufferData);\r\n }\r\n\r\n if (this._engine._features.trackUbosInFrame) {\r\n this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : undefined]);\r\n this._bufferIndex = this._buffers.length - 1;\r\n this._createBufferOnWrite = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get _numBuffers(): number {\r\n return this._buffers.length;\r\n }\r\n\r\n /** @internal */\r\n public get _indexBuffer(): number {\r\n return this._bufferIndex;\r\n }\r\n\r\n /** Gets the name of this buffer */\r\n public get name(): string {\r\n return this._name;\r\n }\r\n\r\n private _buffersEqual(buf1: Float32Array, buf2: Float32Array): boolean {\r\n for (let i = 0; i < buf1.length; ++i) {\r\n if (buf1[i] !== buf2[i]) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n private _copyBuffer(src: Float32Array, dst: Float32Array): void {\r\n for (let i = 0; i < src.length; ++i) {\r\n dst[i] = src[i];\r\n }\r\n }\r\n\r\n /**\r\n * Updates the WebGL Uniform Buffer on the GPU.\r\n * If the `dynamic` flag is set to true, no cache comparison is done.\r\n * Otherwise, the buffer will be updated only if the cache differs.\r\n */\r\n public update(): void {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n\r\n this.bindUniformBuffer();\r\n\r\n if (!this._buffer) {\r\n this.create();\r\n return;\r\n }\r\n\r\n if (!this._dynamic && !this._needSync) {\r\n this._createBufferOnWrite = this._engine._features.trackUbosInFrame;\r\n return;\r\n }\r\n\r\n if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1]) {\r\n if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1]!)) {\r\n this._needSync = false;\r\n this._createBufferOnWrite = this._engine._features.trackUbosInFrame;\r\n return;\r\n } else {\r\n this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1]!);\r\n }\r\n }\r\n\r\n this._engine.updateUniformBuffer(this._buffer, this._bufferData);\r\n\r\n if (this._engine._features._collectUbosUpdatedInFrame) {\r\n if (!UniformBuffer._UpdatedUbosInFrame[this._name]) {\r\n UniformBuffer._UpdatedUbosInFrame[this._name] = 0;\r\n }\r\n UniformBuffer._UpdatedUbosInFrame[this._name]++;\r\n }\r\n\r\n this._needSync = false;\r\n this._createBufferOnWrite = this._engine._features.trackUbosInFrame;\r\n }\r\n\r\n private _createNewBuffer() {\r\n if (this._bufferIndex + 1 < this._buffers.length) {\r\n this._bufferIndex++;\r\n this._buffer = this._buffers[this._bufferIndex][0];\r\n this._createBufferOnWrite = false;\r\n this._needSync = true;\r\n } else {\r\n this._rebuild();\r\n }\r\n }\r\n\r\n private _checkNewFrame(): void {\r\n if (this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId) {\r\n this._currentFrameId = this._engine.frameId;\r\n this._createBufferOnWrite = false;\r\n if (this._buffers && this._buffers.length > 0) {\r\n this._needSync = this._bufferIndex !== 0;\r\n this._bufferIndex = 0;\r\n this._buffer = this._buffers[this._bufferIndex][0];\r\n } else {\r\n this._bufferIndex = -1;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.\r\n * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.\r\n * @param data Define the flattened data\r\n * @param size Define the size of the data.\r\n */\r\n public updateUniform(uniformName: string, data: FloatArray, size: number) {\r\n this._checkNewFrame();\r\n\r\n let location = this._uniformLocations[uniformName];\r\n if (location === undefined) {\r\n if (this._buffer) {\r\n // Cannot add an uniform if the buffer is already created\r\n Logger.Error(\"Cannot add an uniform after UBO has been created.\");\r\n return;\r\n }\r\n this.addUniform(uniformName, size);\r\n location = this._uniformLocations[uniformName];\r\n }\r\n\r\n if (!this._buffer) {\r\n this.create();\r\n }\r\n\r\n if (!this._dynamic) {\r\n // Cache for static uniform buffers\r\n let changed = false;\r\n\r\n for (let i = 0; i < size; i++) {\r\n // We are checking the matrix cache before calling updateUniform so we do not need to check it here\r\n // Hence the test for size === 16 to simply commit the matrix values\r\n if ((size === 16 && !this._engine._features.uniformBufferHardCheckMatrix) || this._bufferData[location + i] !== Tools.FloatRound(data[i])) {\r\n changed = true;\r\n if (this._createBufferOnWrite) {\r\n this._createNewBuffer();\r\n }\r\n this._bufferData[location + i] = data[i];\r\n }\r\n }\r\n\r\n this._needSync = this._needSync || changed;\r\n } else {\r\n // No cache for dynamic\r\n for (let i = 0; i < size; i++) {\r\n this._bufferData[location + i] = data[i];\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.\r\n * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.\r\n * @param data Define the flattened data\r\n * @param size Define the size of the data.\r\n */\r\n public updateUniformArray(uniformName: string, data: FloatArray, size: number) {\r\n this._checkNewFrame();\r\n\r\n const location = this._uniformLocations[uniformName];\r\n if (location === undefined) {\r\n Logger.Error(\"Cannot add an uniform Array dynamically. Please, add it using addUniform.\");\r\n return;\r\n }\r\n\r\n if (!this._buffer) {\r\n this.create();\r\n }\r\n\r\n const arraySizes = this._uniformArraySizes[uniformName];\r\n\r\n if (!this._dynamic) {\r\n // Cache for static uniform buffers\r\n let changed = false;\r\n let countToFour = 0;\r\n let baseStride = 0;\r\n for (let i = 0; i < size; i++) {\r\n if (this._bufferData[location + baseStride * 4 + countToFour] !== Tools.FloatRound(data[i])) {\r\n changed = true;\r\n if (this._createBufferOnWrite) {\r\n this._createNewBuffer();\r\n }\r\n this._bufferData[location + baseStride * 4 + countToFour] = data[i];\r\n }\r\n countToFour++;\r\n if (countToFour === arraySizes.strideSize) {\r\n for (; countToFour < 4; countToFour++) {\r\n this._bufferData[location + baseStride * 4 + countToFour] = 0;\r\n }\r\n countToFour = 0;\r\n baseStride++;\r\n }\r\n }\r\n\r\n this._needSync = this._needSync || changed;\r\n } else {\r\n // No cache for dynamic\r\n for (let i = 0; i < size; i++) {\r\n this._bufferData[location + i] = data[i];\r\n }\r\n }\r\n }\r\n\r\n // Matrix cache\r\n private _valueCache: { [key: string]: number } = {};\r\n private _cacheMatrix(name: string, matrix: IMatrixLike): boolean {\r\n this._checkNewFrame();\r\n\r\n const cache = this._valueCache[name];\r\n const flag = matrix.updateFlag;\r\n if (cache !== undefined && cache === flag) {\r\n return false;\r\n }\r\n\r\n this._valueCache[name] = flag;\r\n return true;\r\n }\r\n\r\n // Update methods\r\n\r\n private _updateMatrix3x3ForUniform(name: string, matrix: Float32Array): void {\r\n // To match std140, matrix must be realigned\r\n for (let i = 0; i < 3; i++) {\r\n UniformBuffer._TempBuffer[i * 4] = matrix[i * 3];\r\n UniformBuffer._TempBuffer[i * 4 + 1] = matrix[i * 3 + 1];\r\n UniformBuffer._TempBuffer[i * 4 + 2] = matrix[i * 3 + 2];\r\n UniformBuffer._TempBuffer[i * 4 + 3] = 0.0;\r\n }\r\n\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 12);\r\n }\r\n\r\n private _updateMatrix3x3ForEffect(name: string, matrix: Float32Array): void {\r\n this._currentEffect.setMatrix3x3(name, matrix);\r\n }\r\n\r\n private _updateMatrix2x2ForEffect(name: string, matrix: Float32Array): void {\r\n this._currentEffect.setMatrix2x2(name, matrix);\r\n }\r\n\r\n private _updateMatrix2x2ForUniform(name: string, matrix: Float32Array): void {\r\n // To match std140, matrix must be realigned\r\n for (let i = 0; i < 2; i++) {\r\n UniformBuffer._TempBuffer[i * 4] = matrix[i * 2];\r\n UniformBuffer._TempBuffer[i * 4 + 1] = matrix[i * 2 + 1];\r\n UniformBuffer._TempBuffer[i * 4 + 2] = 0.0;\r\n UniformBuffer._TempBuffer[i * 4 + 3] = 0.0;\r\n }\r\n\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 8);\r\n }\r\n\r\n private _updateFloatForEffect(name: string, x: number) {\r\n this._currentEffect.setFloat(name, x);\r\n }\r\n\r\n private _updateFloatForUniform(name: string, x: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 1);\r\n }\r\n\r\n private _updateFloat2ForEffect(name: string, x: number, y: number, suffix = \"\") {\r\n this._currentEffect.setFloat2(name + suffix, x, y);\r\n }\r\n\r\n private _updateFloat2ForUniform(name: string, x: number, y: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n UniformBuffer._TempBuffer[1] = y;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 2);\r\n }\r\n\r\n private _updateFloat3ForEffect(name: string, x: number, y: number, z: number, suffix = \"\") {\r\n this._currentEffect.setFloat3(name + suffix, x, y, z);\r\n }\r\n\r\n private _updateFloat3ForUniform(name: string, x: number, y: number, z: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n UniformBuffer._TempBuffer[1] = y;\r\n UniformBuffer._TempBuffer[2] = z;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateFloat4ForEffect(name: string, x: number, y: number, z: number, w: number, suffix = \"\") {\r\n this._currentEffect.setFloat4(name + suffix, x, y, z, w);\r\n }\r\n\r\n private _updateFloat4ForUniform(name: string, x: number, y: number, z: number, w: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n UniformBuffer._TempBuffer[1] = y;\r\n UniformBuffer._TempBuffer[2] = z;\r\n UniformBuffer._TempBuffer[3] = w;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateFloatArrayForEffect(name: string, array: Float32Array) {\r\n this._currentEffect.setFloatArray(name, array);\r\n }\r\n\r\n private _updateFloatArrayForUniform(name: string, array: Float32Array) {\r\n this.updateUniformArray(name, array, array.length);\r\n }\r\n\r\n private _updateArrayForEffect(name: string, array: number[]) {\r\n this._currentEffect.setArray(name, array);\r\n }\r\n\r\n private _updateArrayForUniform(name: string, array: number[]) {\r\n this.updateUniformArray(name, array, array.length);\r\n }\r\n\r\n private _updateIntArrayForEffect(name: string, array: Int32Array) {\r\n this._currentEffect.setIntArray(name, array);\r\n }\r\n\r\n private _updateIntArrayForUniform(name: string, array: Int32Array) {\r\n UniformBuffer._TempBufferInt32View.set(array);\r\n this.updateUniformArray(name, UniformBuffer._TempBuffer, array.length);\r\n }\r\n\r\n private _updateMatrixForEffect(name: string, mat: IMatrixLike) {\r\n this._currentEffect.setMatrix(name, mat);\r\n }\r\n\r\n private _updateMatrixForUniform(name: string, mat: IMatrixLike) {\r\n if (this._cacheMatrix(name, mat)) {\r\n this.updateUniform(name, <any>mat.toArray(), 16);\r\n }\r\n }\r\n\r\n private _updateMatricesForEffect(name: string, mat: Float32Array) {\r\n this._currentEffect.setMatrices(name, mat);\r\n }\r\n\r\n private _updateMatricesForUniform(name: string, mat: Float32Array) {\r\n this.updateUniform(name, mat, mat.length);\r\n }\r\n\r\n private _updateVector3ForEffect(name: string, vector: IVector3Like) {\r\n this._currentEffect.setVector3(name, vector);\r\n }\r\n\r\n private _updateVector3ForUniform(name: string, vector: IVector3Like) {\r\n UniformBuffer._TempBuffer[0] = vector.x;\r\n UniformBuffer._TempBuffer[1] = vector.y;\r\n UniformBuffer._TempBuffer[2] = vector.z;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateVector4ForEffect(name: string, vector: IVector4Like) {\r\n this._currentEffect.setVector4(name, vector);\r\n }\r\n\r\n private _updateVector4ForUniform(name: string, vector: IVector4Like) {\r\n UniformBuffer._TempBuffer[0] = vector.x;\r\n UniformBuffer._TempBuffer[1] = vector.y;\r\n UniformBuffer._TempBuffer[2] = vector.z;\r\n UniformBuffer._TempBuffer[3] = vector.w;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateColor3ForEffect(name: string, color: IColor3Like, suffix = \"\") {\r\n this._currentEffect.setColor3(name + suffix, color);\r\n }\r\n\r\n private _updateColor3ForUniform(name: string, color: IColor3Like) {\r\n UniformBuffer._TempBuffer[0] = color.r;\r\n UniformBuffer._TempBuffer[1] = color.g;\r\n UniformBuffer._TempBuffer[2] = color.b;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateColor4ForEffect(name: string, color: IColor3Like, alpha: number, suffix = \"\") {\r\n this._currentEffect.setColor4(name + suffix, color, alpha);\r\n }\r\n\r\n private _updateDirectColor4ForEffect(name: string, color: IColor4Like, suffix = \"\") {\r\n this._currentEffect.setDirectColor4(name + suffix, color);\r\n }\r\n\r\n private _updateColor4ForUniform(name: string, color: IColor3Like, alpha: number) {\r\n UniformBuffer._TempBuffer[0] = color.r;\r\n UniformBuffer._TempBuffer[1] = color.g;\r\n UniformBuffer._TempBuffer[2] = color.b;\r\n UniformBuffer._TempBuffer[3] = alpha;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateDirectColor4ForUniform(name: string, color: IColor4Like) {\r\n UniformBuffer._TempBuffer[0] = color.r;\r\n UniformBuffer._TempBuffer[1] = color.g;\r\n UniformBuffer._TempBuffer[2] = color.b;\r\n UniformBuffer._TempBuffer[3] = color.a;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateIntForEffect(name: string, x: number, suffix = \"\") {\r\n this._currentEffect.setInt(name + suffix, x);\r\n }\r\n\r\n private _updateIntForUniform(name: string, x: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 1);\r\n }\r\n\r\n private _updateInt2ForEffect(name: string, x: number, y: number, suffix = \"\") {\r\n this._currentEffect.setInt2(name + suffix, x, y);\r\n }\r\n\r\n private _updateInt2ForUniform(name: string, x: number, y: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n UniformBuffer._TempBufferInt32View[1] = y;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 2);\r\n }\r\n\r\n private _updateInt3ForEffect(name: string, x: number, y: number, z: number, suffix = \"\") {\r\n this._currentEffect.setInt3(name + suffix, x, y, z);\r\n }\r\n\r\n private _updateInt3ForUniform(name: string, x: number, y: number, z: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n UniformBuffer._TempBufferInt32View[1] = y;\r\n UniformBuffer._TempBufferInt32View[2] = z;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateInt4ForEffect(name: string, x: number, y: number, z: number, w: number, suffix = \"\") {\r\n this._currentEffect.setInt4(name + suffix, x, y, z, w);\r\n }\r\n\r\n private _updateInt4ForUniform(name: string, x: number, y: number, z: number, w: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n UniformBuffer._TempBufferInt32View[1] = y;\r\n UniformBuffer._TempBufferInt32View[2] = z;\r\n UniformBuffer._TempBufferInt32View[3] = w;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n /**\r\n * Sets a sampler uniform on the effect.\r\n * @param name Define the name of the sampler.\r\n * @param texture Define the texture to set in the sampler\r\n */\r\n public setTexture(name: string, texture: Nullable<ThinTexture>) {\r\n this._currentEffect.setTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Directly updates the value of the uniform in the cache AND on the GPU.\r\n * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.\r\n * @param data Define the flattened data\r\n */\r\n public updateUniformDirectly(uniformName: string, data: FloatArray) {\r\n this.updateUniform(uniformName, data, data.length);\r\n\r\n this.update();\r\n }\r\n\r\n /**\r\n * Associates an effect to this uniform buffer\r\n * @param effect Define the effect to associate the buffer to\r\n * @param name Name of the uniform block in the shader.\r\n */\r\n public bindToEffect(effect: Effect, name: string): void {\r\n this._currentEffect = effect;\r\n this._currentEffectName = name;\r\n }\r\n\r\n /**\r\n * Binds the current (GPU) buffer to the effect\r\n */\r\n public bindUniformBuffer(): void {\r\n if (!this._noUBO && this._buffer && this._currentEffect) {\r\n this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName);\r\n }\r\n }\r\n\r\n /**\r\n * Dissociates the current effect from this uniform buffer\r\n */\r\n public unbindEffect(): void {\r\n this._currentEffect = undefined as any;\r\n this._currentEffectName = undefined as any;\r\n }\r\n\r\n /**\r\n * Sets the current state of the class (_bufferIndex, _buffer) to point to the data buffer passed in parameter if this buffer is one of the buffers handled by the class (meaning if it can be found in the _buffers array)\r\n * This method is meant to be able to update a buffer at any time: just call setDataBuffer to set the class in the right state, call some updateXXX methods and then call udpate() => that will update the GPU buffer on the graphic card\r\n * @param dataBuffer buffer to look for\r\n * @returns true if the buffer has been found and the class internal state points to it, else false\r\n */\r\n public setDataBuffer(dataBuffer: DataBuffer): boolean {\r\n if (!this._buffers) {\r\n return this._buffer === dataBuffer;\r\n }\r\n\r\n for (let b = 0; b < this._buffers.length; ++b) {\r\n const buffer = this._buffers[b];\r\n if (buffer[0] === dataBuffer) {\r\n this._bufferIndex = b;\r\n this._buffer = dataBuffer;\r\n this._createBufferOnWrite = false;\r\n this._currentEffect = undefined as any;\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Disposes the uniform buffer.\r\n */\r\n public dispose(): void {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n\r\n const uniformBuffers = this._engine._uniformBuffers;\r\n const index = uniformBuffers.indexOf(this);\r\n\r\n if (index !== -1) {\r\n uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];\r\n uniformBuffers.pop();\r\n }\r\n\r\n if (this._engine._features.trackUbosInFrame && this._buffers) {\r\n for (let i = 0; i < this._buffers.length; ++i) {\r\n const buffer = this._buffers[i][0];\r\n this._engine._releaseBuffer(buffer!);\r\n }\r\n } else if (this._buffer && this._engine._releaseBuffer(this._buffer)) {\r\n this._buffer = null;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"uniformBuffer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Materials/uniformBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAOxC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,4CAA4C,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAwKtB;;;;;;;;;;;;;;OAcG;IACH,YAAY,MAAkB,EAAE,IAAe,EAAE,OAAiB,EAAE,IAAa,EAAE,oBAAoB,GAAG,KAAK;QAkhB/G,eAAe;QACP,gBAAW,GAA8B,EAAE,CAAC;QAlhBhD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,sBAAsB,IAAI,oBAAoB,CAAC;QACrE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,SAAS,CAAC;QAE/B,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QAExB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEvB,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,EAAE;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C,EAAE;YAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;IACL,CAAC;;AAlhCD,gBAAgB;AACF,iCAAmB,GAA+B,EAAE,CAAC;AAqBnE,iCAAiC;AAClB,+BAAiB,GAAG,GAAG,CAAC;AACxB,yBAAW,GAAG,IAAI,YAAY,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAChE,kCAAoB,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport type { Nullable, FloatArray } from \"../types\";\r\nimport type { IMatrixLike, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from \"../Maths/math.like\";\r\nimport type { Effect } from \"./effect\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Tools } from \"../Misc/tools\";\r\n\r\nimport \"../Engines/Extensions/engine.uniformBuffer\";\r\n\r\n/**\r\n * Uniform buffer objects.\r\n *\r\n * Handles blocks of uniform on the GPU.\r\n *\r\n * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.\r\n *\r\n * For more information, please refer to :\r\n * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object\r\n */\r\nexport class UniformBuffer {\r\n /** @internal */\r\n public static _UpdatedUbosInFrame: { [name: string]: number } = {};\r\n\r\n private _engine: ThinEngine;\r\n private _buffer: Nullable<DataBuffer>;\r\n private _buffers: Array<[DataBuffer, Float32Array | undefined]>;\r\n private _bufferIndex: number;\r\n private _createBufferOnWrite: boolean;\r\n private _data: number[];\r\n private _bufferData: Float32Array;\r\n private _dynamic?: boolean;\r\n private _uniformLocations: { [key: string]: number };\r\n private _uniformSizes: { [key: string]: number };\r\n private _uniformArraySizes: { [key: string]: { strideSize: number; arraySize: number } };\r\n private _uniformLocationPointer: number;\r\n private _needSync: boolean;\r\n private _noUBO: boolean;\r\n private _currentEffect: Effect;\r\n private _currentEffectName: string;\r\n private _name: string;\r\n private _currentFrameId: number;\r\n\r\n // Pool for avoiding memory leaks\r\n private static _MAX_UNIFORM_SIZE = 256;\r\n private static _TempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);\r\n private static _TempBufferInt32View = new Uint32Array(UniformBuffer._TempBuffer.buffer);\r\n\r\n /**\r\n * Lambda to Update a 3x3 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrix3x3: (name: string, matrix: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update a 2x2 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrix2x2: (name: string, matrix: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update a single float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat: (name: string, x: number) => void;\r\n\r\n /**\r\n * Lambda to Update a vec2 of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec3 of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec4 of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update an array of float in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateFloatArray: (name: string, array: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update an array of number in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateArray: (name: string, array: number[]) => void;\r\n\r\n /**\r\n * Lambda to Update an array of number in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateIntArray: (name: string, array: Int32Array) => void;\r\n\r\n /**\r\n * Lambda to Update a 4x4 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrix: (name: string, mat: IMatrixLike) => void;\r\n\r\n /**\r\n * Lambda to Update an array of 4x4 Matrix in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateMatrices: (name: string, mat: Float32Array) => void;\r\n\r\n /**\r\n * Lambda to Update vec3 of float from a Vector in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateVector3: (name: string, vector: IVector3Like) => void;\r\n\r\n /**\r\n * Lambda to Update vec4 of float from a Vector in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateVector4: (name: string, vector: IVector4Like) => void;\r\n\r\n /**\r\n * Lambda to Update vec3 of float from a Color in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateColor3: (name: string, color: IColor3Like, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update vec4 of float from a Color in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateColor4: (name: string, color: IColor3Like, alpha: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update vec4 of float from a Color in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateDirectColor4: (name: string, color: IColor4Like, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a int a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt: (name: string, x: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec2 of int in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt2: (name: string, x: number, y: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec3 of int in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;\r\n\r\n /**\r\n * Lambda to Update a vec4 of int in a uniform buffer.\r\n * This is dynamic to allow compat with webgl 1 and 2.\r\n * You will need to pass the name of the uniform as well as the value.\r\n */\r\n public updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;\r\n\r\n /**\r\n * Instantiates a new Uniform buffer objects.\r\n *\r\n * Handles blocks of uniform on the GPU.\r\n *\r\n * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.\r\n *\r\n * For more information, please refer to :\r\n * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object\r\n * @param engine Define the engine the buffer is associated with\r\n * @param data Define the data contained in the buffer\r\n * @param dynamic Define if the buffer is updatable\r\n * @param name to assign to the buffer (debugging purpose)\r\n * @param forceNoUniformBuffer define that this object must not rely on UBO objects\r\n */\r\n constructor(engine: ThinEngine, data?: number[], dynamic?: boolean, name?: string, forceNoUniformBuffer = false) {\r\n this._engine = engine;\r\n this._noUBO = !engine.supportsUniformBuffers || forceNoUniformBuffer;\r\n this._dynamic = dynamic;\r\n this._name = name ?? \"no-name\";\r\n\r\n this._data = data || [];\r\n\r\n this._uniformLocations = {};\r\n this._uniformSizes = {};\r\n this._uniformArraySizes = {};\r\n this._uniformLocationPointer = 0;\r\n this._needSync = false;\r\n\r\n if (this._engine._features.trackUbosInFrame) {\r\n this._buffers = [];\r\n this._bufferIndex = -1;\r\n this._createBufferOnWrite = false;\r\n this._currentFrameId = 0;\r\n }\r\n\r\n if (this._noUBO) {\r\n this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;\r\n this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;\r\n this.updateFloat = this._updateFloatForEffect;\r\n this.updateFloat2 = this._updateFloat2ForEffect;\r\n this.updateFloat3 = this._updateFloat3ForEffect;\r\n this.updateFloat4 = this._updateFloat4ForEffect;\r\n this.updateFloatArray = this._updateFloatArrayForEffect;\r\n this.updateArray = this._updateArrayForEffect;\r\n this.updateIntArray = this._updateIntArrayForEffect;\r\n this.updateMatrix = this._updateMatrixForEffect;\r\n this.updateMatrices = this._updateMatricesForEffect;\r\n this.updateVector3 = this._updateVector3ForEffect;\r\n this.updateVector4 = this._updateVector4ForEffect;\r\n this.updateColor3 = this._updateColor3ForEffect;\r\n this.updateColor4 = this._updateColor4ForEffect;\r\n this.updateDirectColor4 = this._updateDirectColor4ForEffect;\r\n this.updateInt = this._updateIntForEffect;\r\n this.updateInt2 = this._updateInt2ForEffect;\r\n this.updateInt3 = this._updateInt3ForEffect;\r\n this.updateInt4 = this._updateInt4ForEffect;\r\n } else {\r\n this._engine._uniformBuffers.push(this);\r\n\r\n this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;\r\n this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;\r\n this.updateFloat = this._updateFloatForUniform;\r\n this.updateFloat2 = this._updateFloat2ForUniform;\r\n this.updateFloat3 = this._updateFloat3ForUniform;\r\n this.updateFloat4 = this._updateFloat4ForUniform;\r\n this.updateFloatArray = this._updateFloatArrayForUniform;\r\n this.updateArray = this._updateArrayForUniform;\r\n this.updateIntArray = this._updateIntArrayForUniform;\r\n this.updateMatrix = this._updateMatrixForUniform;\r\n this.updateMatrices = this._updateMatricesForUniform;\r\n this.updateVector3 = this._updateVector3ForUniform;\r\n this.updateVector4 = this._updateVector4ForUniform;\r\n this.updateColor3 = this._updateColor3ForUniform;\r\n this.updateColor4 = this._updateColor4ForUniform;\r\n this.updateDirectColor4 = this._updateDirectColor4ForUniform;\r\n this.updateInt = this._updateIntForUniform;\r\n this.updateInt2 = this._updateInt2ForUniform;\r\n this.updateInt3 = this._updateInt3ForUniform;\r\n this.updateInt4 = this._updateInt4ForUniform;\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if the buffer is using the WebGL2 UBO implementation,\r\n * or just falling back on setUniformXXX calls.\r\n */\r\n public get useUbo(): boolean {\r\n return !this._noUBO;\r\n }\r\n\r\n /**\r\n * Indicates if the WebGL underlying uniform buffer is in sync\r\n * with the javascript cache data.\r\n */\r\n public get isSync(): boolean {\r\n return !this._needSync;\r\n }\r\n\r\n /**\r\n * Indicates if the WebGL underlying uniform buffer is dynamic.\r\n * Also, a dynamic UniformBuffer will disable cache verification and always\r\n * update the underlying WebGL uniform buffer to the GPU.\r\n * @returns if Dynamic, otherwise false\r\n */\r\n public isDynamic(): boolean {\r\n return this._dynamic !== undefined;\r\n }\r\n\r\n /**\r\n * The data cache on JS side.\r\n * @returns the underlying data as a float array\r\n */\r\n public getData(): Float32Array {\r\n return this._bufferData;\r\n }\r\n\r\n /**\r\n * The underlying WebGL Uniform buffer.\r\n * @returns the webgl buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * std140 layout specifies how to align data within an UBO structure.\r\n * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159\r\n * for specs.\r\n * @param size\r\n */\r\n private _fillAlignment(size: number) {\r\n // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components\r\n // and 4x4 matrices\r\n // TODO : change if other types are used\r\n\r\n let alignment;\r\n if (size <= 2) {\r\n alignment = size;\r\n } else {\r\n alignment = 4;\r\n }\r\n\r\n if (this._uniformLocationPointer % alignment !== 0) {\r\n const oldPointer = this._uniformLocationPointer;\r\n this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);\r\n const diff = this._uniformLocationPointer - oldPointer;\r\n\r\n for (let i = 0; i < diff; i++) {\r\n this._data.push(0);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Adds an uniform in the buffer.\r\n * Warning : the subsequents calls of this function must be in the same order as declared in the shader\r\n * for the layout to be correct ! The addUniform function only handles types like float, vec2, vec3, vec4, mat4,\r\n * meaning size=1,2,3,4 or 16. It does not handle struct types.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param size Data size, or data directly.\r\n * @param arraySize The number of elements in the array, 0 if not an array.\r\n */\r\n public addUniform(name: string, size: number | number[], arraySize = 0) {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n\r\n if (this._uniformLocations[name] !== undefined) {\r\n // Already existing uniform\r\n return;\r\n }\r\n // This function must be called in the order of the shader layout !\r\n // size can be the size of the uniform, or data directly\r\n let data;\r\n\r\n // std140 FTW...\r\n if (arraySize > 0) {\r\n if (size instanceof Array) {\r\n throw \"addUniform should not be use with Array in UBO: \" + name;\r\n }\r\n\r\n this._fillAlignment(4);\r\n\r\n this._uniformArraySizes[name] = { strideSize: size, arraySize };\r\n if (size == 16) {\r\n size = size * arraySize;\r\n } else {\r\n const perElementPadding = 4 - size;\r\n const totalPadding = perElementPadding * arraySize;\r\n size = size * arraySize + totalPadding;\r\n }\r\n\r\n data = [];\r\n // Fill with zeros\r\n for (let i = 0; i < size; i++) {\r\n data.push(0);\r\n }\r\n } else {\r\n if (size instanceof Array) {\r\n data = size;\r\n size = data.length;\r\n } else {\r\n size = <number>size;\r\n data = [];\r\n\r\n // Fill with zeros\r\n for (let i = 0; i < size; i++) {\r\n data.push(0);\r\n }\r\n }\r\n this._fillAlignment(<number>size);\r\n }\r\n\r\n this._uniformSizes[name] = <number>size;\r\n this._uniformLocations[name] = this._uniformLocationPointer;\r\n this._uniformLocationPointer += <number>size;\r\n\r\n for (let i = 0; i < size; i++) {\r\n this._data.push(data[i]);\r\n }\r\n\r\n this._needSync = true;\r\n }\r\n\r\n /**\r\n * Adds a Matrix 4x4 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param mat A 4x4 matrix.\r\n */\r\n public addMatrix(name: string, mat: IMatrixLike) {\r\n this.addUniform(name, Array.prototype.slice.call(mat.toArray()));\r\n }\r\n\r\n /**\r\n * Adds a vec2 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param x Define the x component value of the vec2\r\n * @param y Define the y component value of the vec2\r\n */\r\n public addFloat2(name: string, x: number, y: number) {\r\n const temp = [x, y];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param x Define the x component value of the vec3\r\n * @param y Define the y component value of the vec3\r\n * @param z Define the z component value of the vec3\r\n */\r\n public addFloat3(name: string, x: number, y: number, z: number) {\r\n const temp = [x, y, z];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param color Define the vec3 from a Color\r\n */\r\n public addColor3(name: string, color: IColor3Like) {\r\n const temp = [color.r, color.g, color.b];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec4 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param color Define the rgb components from a Color\r\n * @param alpha Define the a component of the vec4\r\n */\r\n public addColor4(name: string, color: IColor3Like, alpha: number) {\r\n const temp = [color.r, color.g, color.b, alpha];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a vec3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n * @param vector Define the vec3 components from a Vector\r\n */\r\n public addVector3(name: string, vector: IVector3Like) {\r\n const temp = [vector.x, vector.y, vector.z];\r\n this.addUniform(name, temp);\r\n }\r\n\r\n /**\r\n * Adds a Matrix 3x3 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n */\r\n public addMatrix3x3(name: string) {\r\n this.addUniform(name, 12);\r\n }\r\n\r\n /**\r\n * Adds a Matrix 2x2 to the uniform buffer.\r\n * @param name Name of the uniform, as used in the uniform block in the shader.\r\n */\r\n public addMatrix2x2(name: string) {\r\n this.addUniform(name, 8);\r\n }\r\n\r\n /**\r\n * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.\r\n */\r\n public create(): void {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n if (this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n // See spec, alignment must be filled as a vec4\r\n this._fillAlignment(4);\r\n this._bufferData = new Float32Array(this._data);\r\n\r\n this._rebuild();\r\n\r\n this._needSync = true;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (this._noUBO || !this._bufferData) {\r\n return;\r\n }\r\n\r\n if (this._dynamic) {\r\n this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);\r\n } else {\r\n this._buffer = this._engine.createUniformBuffer(this._bufferData);\r\n }\r\n\r\n if (this._engine._features.trackUbosInFrame) {\r\n this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : undefined]);\r\n this._bufferIndex = this._buffers.length - 1;\r\n this._createBufferOnWrite = false;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get _numBuffers(): number {\r\n return this._buffers.length;\r\n }\r\n\r\n /** @internal */\r\n public get _indexBuffer(): number {\r\n return this._bufferIndex;\r\n }\r\n\r\n /** Gets the name of this buffer */\r\n public get name(): string {\r\n return this._name;\r\n }\r\n\r\n private _buffersEqual(buf1: Float32Array, buf2: Float32Array): boolean {\r\n for (let i = 0; i < buf1.length; ++i) {\r\n if (buf1[i] !== buf2[i]) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n private _copyBuffer(src: Float32Array, dst: Float32Array): void {\r\n for (let i = 0; i < src.length; ++i) {\r\n dst[i] = src[i];\r\n }\r\n }\r\n\r\n /**\r\n * Updates the WebGL Uniform Buffer on the GPU.\r\n * If the `dynamic` flag is set to true, no cache comparison is done.\r\n * Otherwise, the buffer will be updated only if the cache differs.\r\n */\r\n public update(): void {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n\r\n this.bindUniformBuffer();\r\n\r\n if (!this._buffer) {\r\n this.create();\r\n return;\r\n }\r\n\r\n if (!this._dynamic && !this._needSync) {\r\n this._createBufferOnWrite = this._engine._features.trackUbosInFrame;\r\n return;\r\n }\r\n\r\n if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1]) {\r\n if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1]!)) {\r\n this._needSync = false;\r\n this._createBufferOnWrite = this._engine._features.trackUbosInFrame;\r\n return;\r\n } else {\r\n this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1]!);\r\n }\r\n }\r\n\r\n this._engine.updateUniformBuffer(this._buffer, this._bufferData);\r\n\r\n if (this._engine._features._collectUbosUpdatedInFrame) {\r\n if (!UniformBuffer._UpdatedUbosInFrame[this._name]) {\r\n UniformBuffer._UpdatedUbosInFrame[this._name] = 0;\r\n }\r\n UniformBuffer._UpdatedUbosInFrame[this._name]++;\r\n }\r\n\r\n this._needSync = false;\r\n this._createBufferOnWrite = this._engine._features.trackUbosInFrame;\r\n }\r\n\r\n private _createNewBuffer() {\r\n if (this._bufferIndex + 1 < this._buffers.length) {\r\n this._bufferIndex++;\r\n this._buffer = this._buffers[this._bufferIndex][0];\r\n this._createBufferOnWrite = false;\r\n this._needSync = true;\r\n } else {\r\n this._rebuild();\r\n }\r\n }\r\n\r\n private _checkNewFrame(): void {\r\n if (this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId) {\r\n this._currentFrameId = this._engine.frameId;\r\n this._createBufferOnWrite = false;\r\n if (this._buffers && this._buffers.length > 0) {\r\n this._needSync = this._bufferIndex !== 0;\r\n this._bufferIndex = 0;\r\n this._buffer = this._buffers[this._bufferIndex][0];\r\n } else {\r\n this._bufferIndex = -1;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.\r\n * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.\r\n * @param data Define the flattened data\r\n * @param size Define the size of the data.\r\n */\r\n public updateUniform(uniformName: string, data: FloatArray, size: number) {\r\n this._checkNewFrame();\r\n\r\n let location = this._uniformLocations[uniformName];\r\n if (location === undefined) {\r\n if (this._buffer) {\r\n // Cannot add an uniform if the buffer is already created\r\n Logger.Error(\"Cannot add an uniform after UBO has been created.\");\r\n return;\r\n }\r\n this.addUniform(uniformName, size);\r\n location = this._uniformLocations[uniformName];\r\n }\r\n\r\n if (!this._buffer) {\r\n this.create();\r\n }\r\n\r\n if (!this._dynamic) {\r\n // Cache for static uniform buffers\r\n let changed = false;\r\n\r\n for (let i = 0; i < size; i++) {\r\n // We are checking the matrix cache before calling updateUniform so we do not need to check it here\r\n // Hence the test for size === 16 to simply commit the matrix values\r\n if ((size === 16 && !this._engine._features.uniformBufferHardCheckMatrix) || this._bufferData[location + i] !== Tools.FloatRound(data[i])) {\r\n changed = true;\r\n if (this._createBufferOnWrite) {\r\n this._createNewBuffer();\r\n }\r\n this._bufferData[location + i] = data[i];\r\n }\r\n }\r\n\r\n this._needSync = this._needSync || changed;\r\n } else {\r\n // No cache for dynamic\r\n for (let i = 0; i < size; i++) {\r\n this._bufferData[location + i] = data[i];\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.\r\n * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.\r\n * @param data Define the flattened data\r\n * @param size Define the size of the data.\r\n */\r\n public updateUniformArray(uniformName: string, data: FloatArray, size: number) {\r\n this._checkNewFrame();\r\n\r\n const location = this._uniformLocations[uniformName];\r\n if (location === undefined) {\r\n Logger.Error(\"Cannot add an uniform Array dynamically. Please, add it using addUniform.\");\r\n return;\r\n }\r\n\r\n if (!this._buffer) {\r\n this.create();\r\n }\r\n\r\n const arraySizes = this._uniformArraySizes[uniformName];\r\n\r\n if (!this._dynamic) {\r\n // Cache for static uniform buffers\r\n let changed = false;\r\n let countToFour = 0;\r\n let baseStride = 0;\r\n for (let i = 0; i < size; i++) {\r\n if (this._bufferData[location + baseStride * 4 + countToFour] !== Tools.FloatRound(data[i])) {\r\n changed = true;\r\n if (this._createBufferOnWrite) {\r\n this._createNewBuffer();\r\n }\r\n this._bufferData[location + baseStride * 4 + countToFour] = data[i];\r\n }\r\n countToFour++;\r\n if (countToFour === arraySizes.strideSize) {\r\n for (; countToFour < 4; countToFour++) {\r\n this._bufferData[location + baseStride * 4 + countToFour] = 0;\r\n }\r\n countToFour = 0;\r\n baseStride++;\r\n }\r\n }\r\n\r\n this._needSync = this._needSync || changed;\r\n } else {\r\n // No cache for dynamic\r\n for (let i = 0; i < size; i++) {\r\n this._bufferData[location + i] = data[i];\r\n }\r\n }\r\n }\r\n\r\n // Matrix cache\r\n private _valueCache: { [key: string]: number } = {};\r\n private _cacheMatrix(name: string, matrix: IMatrixLike): boolean {\r\n this._checkNewFrame();\r\n\r\n const cache = this._valueCache[name];\r\n const flag = matrix.updateFlag;\r\n if (cache !== undefined && cache === flag) {\r\n return false;\r\n }\r\n\r\n this._valueCache[name] = flag;\r\n return true;\r\n }\r\n\r\n // Update methods\r\n\r\n private _updateMatrix3x3ForUniform(name: string, matrix: Float32Array): void {\r\n // To match std140, matrix must be realigned\r\n for (let i = 0; i < 3; i++) {\r\n UniformBuffer._TempBuffer[i * 4] = matrix[i * 3];\r\n UniformBuffer._TempBuffer[i * 4 + 1] = matrix[i * 3 + 1];\r\n UniformBuffer._TempBuffer[i * 4 + 2] = matrix[i * 3 + 2];\r\n UniformBuffer._TempBuffer[i * 4 + 3] = 0.0;\r\n }\r\n\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 12);\r\n }\r\n\r\n private _updateMatrix3x3ForEffect(name: string, matrix: Float32Array): void {\r\n this._currentEffect.setMatrix3x3(name, matrix);\r\n }\r\n\r\n private _updateMatrix2x2ForEffect(name: string, matrix: Float32Array): void {\r\n this._currentEffect.setMatrix2x2(name, matrix);\r\n }\r\n\r\n private _updateMatrix2x2ForUniform(name: string, matrix: Float32Array): void {\r\n // To match std140, matrix must be realigned\r\n for (let i = 0; i < 2; i++) {\r\n UniformBuffer._TempBuffer[i * 4] = matrix[i * 2];\r\n UniformBuffer._TempBuffer[i * 4 + 1] = matrix[i * 2 + 1];\r\n UniformBuffer._TempBuffer[i * 4 + 2] = 0.0;\r\n UniformBuffer._TempBuffer[i * 4 + 3] = 0.0;\r\n }\r\n\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 8);\r\n }\r\n\r\n private _updateFloatForEffect(name: string, x: number) {\r\n this._currentEffect.setFloat(name, x);\r\n }\r\n\r\n private _updateFloatForUniform(name: string, x: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 1);\r\n }\r\n\r\n private _updateFloat2ForEffect(name: string, x: number, y: number, suffix = \"\") {\r\n this._currentEffect.setFloat2(name + suffix, x, y);\r\n }\r\n\r\n private _updateFloat2ForUniform(name: string, x: number, y: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n UniformBuffer._TempBuffer[1] = y;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 2);\r\n }\r\n\r\n private _updateFloat3ForEffect(name: string, x: number, y: number, z: number, suffix = \"\") {\r\n this._currentEffect.setFloat3(name + suffix, x, y, z);\r\n }\r\n\r\n private _updateFloat3ForUniform(name: string, x: number, y: number, z: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n UniformBuffer._TempBuffer[1] = y;\r\n UniformBuffer._TempBuffer[2] = z;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateFloat4ForEffect(name: string, x: number, y: number, z: number, w: number, suffix = \"\") {\r\n this._currentEffect.setFloat4(name + suffix, x, y, z, w);\r\n }\r\n\r\n private _updateFloat4ForUniform(name: string, x: number, y: number, z: number, w: number) {\r\n UniformBuffer._TempBuffer[0] = x;\r\n UniformBuffer._TempBuffer[1] = y;\r\n UniformBuffer._TempBuffer[2] = z;\r\n UniformBuffer._TempBuffer[3] = w;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateFloatArrayForEffect(name: string, array: Float32Array) {\r\n this._currentEffect.setFloatArray(name, array);\r\n }\r\n\r\n private _updateFloatArrayForUniform(name: string, array: Float32Array) {\r\n this.updateUniformArray(name, array, array.length);\r\n }\r\n\r\n private _updateArrayForEffect(name: string, array: number[]) {\r\n this._currentEffect.setArray(name, array);\r\n }\r\n\r\n private _updateArrayForUniform(name: string, array: number[]) {\r\n this.updateUniformArray(name, array, array.length);\r\n }\r\n\r\n private _updateIntArrayForEffect(name: string, array: Int32Array) {\r\n this._currentEffect.setIntArray(name, array);\r\n }\r\n\r\n private _updateIntArrayForUniform(name: string, array: Int32Array) {\r\n UniformBuffer._TempBufferInt32View.set(array);\r\n this.updateUniformArray(name, UniformBuffer._TempBuffer, array.length);\r\n }\r\n\r\n private _updateMatrixForEffect(name: string, mat: IMatrixLike) {\r\n this._currentEffect.setMatrix(name, mat);\r\n }\r\n\r\n private _updateMatrixForUniform(name: string, mat: IMatrixLike) {\r\n if (this._cacheMatrix(name, mat)) {\r\n this.updateUniform(name, <any>mat.toArray(), 16);\r\n }\r\n }\r\n\r\n private _updateMatricesForEffect(name: string, mat: Float32Array) {\r\n this._currentEffect.setMatrices(name, mat);\r\n }\r\n\r\n private _updateMatricesForUniform(name: string, mat: Float32Array) {\r\n this.updateUniform(name, mat, mat.length);\r\n }\r\n\r\n private _updateVector3ForEffect(name: string, vector: IVector3Like) {\r\n this._currentEffect.setVector3(name, vector);\r\n }\r\n\r\n private _updateVector3ForUniform(name: string, vector: IVector3Like) {\r\n UniformBuffer._TempBuffer[0] = vector.x;\r\n UniformBuffer._TempBuffer[1] = vector.y;\r\n UniformBuffer._TempBuffer[2] = vector.z;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateVector4ForEffect(name: string, vector: IVector4Like) {\r\n this._currentEffect.setVector4(name, vector);\r\n }\r\n\r\n private _updateVector4ForUniform(name: string, vector: IVector4Like) {\r\n UniformBuffer._TempBuffer[0] = vector.x;\r\n UniformBuffer._TempBuffer[1] = vector.y;\r\n UniformBuffer._TempBuffer[2] = vector.z;\r\n UniformBuffer._TempBuffer[3] = vector.w;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateColor3ForEffect(name: string, color: IColor3Like, suffix = \"\") {\r\n this._currentEffect.setColor3(name + suffix, color);\r\n }\r\n\r\n private _updateColor3ForUniform(name: string, color: IColor3Like) {\r\n UniformBuffer._TempBuffer[0] = color.r;\r\n UniformBuffer._TempBuffer[1] = color.g;\r\n UniformBuffer._TempBuffer[2] = color.b;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateColor4ForEffect(name: string, color: IColor3Like, alpha: number, suffix = \"\") {\r\n this._currentEffect.setColor4(name + suffix, color, alpha);\r\n }\r\n\r\n private _updateDirectColor4ForEffect(name: string, color: IColor4Like, suffix = \"\") {\r\n this._currentEffect.setDirectColor4(name + suffix, color);\r\n }\r\n\r\n private _updateColor4ForUniform(name: string, color: IColor3Like, alpha: number) {\r\n UniformBuffer._TempBuffer[0] = color.r;\r\n UniformBuffer._TempBuffer[1] = color.g;\r\n UniformBuffer._TempBuffer[2] = color.b;\r\n UniformBuffer._TempBuffer[3] = alpha;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateDirectColor4ForUniform(name: string, color: IColor4Like) {\r\n UniformBuffer._TempBuffer[0] = color.r;\r\n UniformBuffer._TempBuffer[1] = color.g;\r\n UniformBuffer._TempBuffer[2] = color.b;\r\n UniformBuffer._TempBuffer[3] = color.a;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n private _updateIntForEffect(name: string, x: number, suffix = \"\") {\r\n this._currentEffect.setInt(name + suffix, x);\r\n }\r\n\r\n private _updateIntForUniform(name: string, x: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 1);\r\n }\r\n\r\n private _updateInt2ForEffect(name: string, x: number, y: number, suffix = \"\") {\r\n this._currentEffect.setInt2(name + suffix, x, y);\r\n }\r\n\r\n private _updateInt2ForUniform(name: string, x: number, y: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n UniformBuffer._TempBufferInt32View[1] = y;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 2);\r\n }\r\n\r\n private _updateInt3ForEffect(name: string, x: number, y: number, z: number, suffix = \"\") {\r\n this._currentEffect.setInt3(name + suffix, x, y, z);\r\n }\r\n\r\n private _updateInt3ForUniform(name: string, x: number, y: number, z: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n UniformBuffer._TempBufferInt32View[1] = y;\r\n UniformBuffer._TempBufferInt32View[2] = z;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 3);\r\n }\r\n\r\n private _updateInt4ForEffect(name: string, x: number, y: number, z: number, w: number, suffix = \"\") {\r\n this._currentEffect.setInt4(name + suffix, x, y, z, w);\r\n }\r\n\r\n private _updateInt4ForUniform(name: string, x: number, y: number, z: number, w: number) {\r\n UniformBuffer._TempBufferInt32View[0] = x;\r\n UniformBuffer._TempBufferInt32View[1] = y;\r\n UniformBuffer._TempBufferInt32View[2] = z;\r\n UniformBuffer._TempBufferInt32View[3] = w;\r\n this.updateUniform(name, UniformBuffer._TempBuffer, 4);\r\n }\r\n\r\n /**\r\n * Sets a sampler uniform on the effect.\r\n * @param name Define the name of the sampler.\r\n * @param texture Define the texture to set in the sampler\r\n */\r\n public setTexture(name: string, texture: Nullable<ThinTexture>) {\r\n this._currentEffect.setTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Directly updates the value of the uniform in the cache AND on the GPU.\r\n * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.\r\n * @param data Define the flattened data\r\n */\r\n public updateUniformDirectly(uniformName: string, data: FloatArray) {\r\n this.updateUniform(uniformName, data, data.length);\r\n\r\n this.update();\r\n }\r\n\r\n /**\r\n * Associates an effect to this uniform buffer\r\n * @param effect Define the effect to associate the buffer to\r\n * @param name Name of the uniform block in the shader.\r\n */\r\n public bindToEffect(effect: Effect, name: string): void {\r\n this._currentEffect = effect;\r\n this._currentEffectName = name;\r\n }\r\n\r\n /**\r\n * Binds the current (GPU) buffer to the effect\r\n */\r\n public bindUniformBuffer(): void {\r\n if (!this._noUBO && this._buffer && this._currentEffect) {\r\n this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName);\r\n }\r\n }\r\n\r\n /**\r\n * Dissociates the current effect from this uniform buffer\r\n */\r\n public unbindEffect(): void {\r\n this._currentEffect = undefined as any;\r\n this._currentEffectName = undefined as any;\r\n }\r\n\r\n /**\r\n * Sets the current state of the class (_bufferIndex, _buffer) to point to the data buffer passed in parameter if this buffer is one of the buffers handled by the class (meaning if it can be found in the _buffers array)\r\n * This method is meant to be able to update a buffer at any time: just call setDataBuffer to set the class in the right state, call some updateXXX methods and then call udpate() => that will update the GPU buffer on the graphic card\r\n * @param dataBuffer buffer to look for\r\n * @returns true if the buffer has been found and the class internal state points to it, else false\r\n */\r\n public setDataBuffer(dataBuffer: DataBuffer): boolean {\r\n if (!this._buffers) {\r\n return this._buffer === dataBuffer;\r\n }\r\n\r\n for (let b = 0; b < this._buffers.length; ++b) {\r\n const buffer = this._buffers[b];\r\n if (buffer[0] === dataBuffer) {\r\n this._bufferIndex = b;\r\n this._buffer = dataBuffer;\r\n this._createBufferOnWrite = false;\r\n this._currentEffect = undefined as any;\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Disposes the uniform buffer.\r\n */\r\n public dispose(): void {\r\n if (this._noUBO) {\r\n return;\r\n }\r\n\r\n const uniformBuffers = this._engine._uniformBuffers;\r\n const index = uniformBuffers.indexOf(this);\r\n\r\n if (index !== -1) {\r\n uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];\r\n uniformBuffers.pop();\r\n }\r\n\r\n if (this._engine._features.trackUbosInFrame && this._buffers) {\r\n for (let i = 0; i < this._buffers.length; ++i) {\r\n const buffer = this._buffers[i][0];\r\n this._engine._releaseBuffer(buffer!);\r\n }\r\n } else if (this._buffer && this._engine._releaseBuffer(this._buffer)) {\r\n this._buffer = null;\r\n }\r\n }\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { DeepImmutable } from "../types";
2
- import type { Vector2, Vector3 } from "./math.vector";
2
+ import { Vector2, Vector3 } from "./math.vector";
3
3
  /**
4
4
  * Class used to store (r, theta) vector representation
5
5
  */
@@ -395,7 +395,7 @@ export declare class Spherical {
395
395
  toVector3ToRef(ref: DeepImmutable<Vector3>): Vector3;
396
396
  /**
397
397
  * Gets a Vector3 from the current spherical coordinates
398
- * @returns the Vector3
398
+ * @returns the (x, y,z) form of the current Spherical
399
399
  */
400
400
  toVector3(): Vector3;
401
401
  /**
@@ -1,4 +1,4 @@
1
- import { TmpVectors } from "./math.vector.js";
1
+ import { Vector2, Vector3 } from "./math.vector.js";
2
2
  /**
3
3
  * Class used to store (r, theta) vector representation
4
4
  */
@@ -281,7 +281,7 @@ export class Polar {
281
281
  * @returns the rectangular coordinates
282
282
  */
283
283
  toVector2() {
284
- const ref = TmpVectors.Vector2[0];
284
+ const ref = new Vector2(0, 0);
285
285
  return this.toVector2ToRef(ref);
286
286
  }
287
287
  /**
@@ -611,10 +611,10 @@ export class Spherical {
611
611
  }
612
612
  /**
613
613
  * Gets a Vector3 from the current spherical coordinates
614
- * @returns the Vector3
614
+ * @returns the (x, y,z) form of the current Spherical
615
615
  */
616
616
  toVector3() {
617
- const ref = TmpVectors.Vector3[0];
617
+ const ref = new Vector3(0, 0, 0);
618
618
  return this.toVector3ToRef(ref);
619
619
  }
620
620
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"math.polar.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.polar.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,KAAK;IAId;;;;OAIG;IACH,YAAY,MAAc,EAAE,KAAa;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,KAAY,EAAE,GAAU;QACpC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QACxC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACrC,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,GAAG,C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ACI,MAAM,CAAC,SAAS,CAAC,KAAe;QACnC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { Vector2, Vector3 } from \"./math.vector\";\r\nimport { TmpVectors } from \"./math.vector\";\r\n\r\n/**\r\n * Class used to store (r, theta) vector representation\r\n */\r\nexport class Polar {\r\n public radius: number;\r\n public theta: number;\r\n\r\n /**\r\n * Creates a new Polar object\r\n * @param radius the radius of the vector\r\n * @param theta the angle of the vector\r\n */\r\n constructor(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"Polar\"\r\n */\r\n public getClassName() {\r\n return \"Polar\";\r\n }\r\n\r\n /**\r\n * Converts the current polar to a string\r\n * @returns the current polar as a string\r\n */\r\n public toString() {\r\n return JSON.stringify(this);\r\n }\r\n\r\n /**\r\n * Converts the current polar to an array\r\n * @reutrns the current polar as an array\r\n */\r\n public asArray() {\r\n return [this.radius, this.theta];\r\n }\r\n\r\n /**\r\n * Adds the current Polar and the given Polar and stores the result\r\n * @param polar the polar to add\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public addToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius + polar.radius;\r\n ref.theta = this.theta + polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the current Polar and the given Polar\r\n * @param polar the polar to add\r\n * @returns the sum polar\r\n */\r\n public add(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.addToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the given polar to the current polar\r\n * @param polar the polar to add\r\n * @returns the current polar\r\n */\r\n public addInPlace(polar: Polar) {\r\n this.addToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds the provided values to the current polar\r\n * @param radius the amount to add to the radius\r\n * @param theta the amount to add to the theta\r\n * @returns the current polar\r\n */\r\n public addInPlaceFromFloats(radius: number, theta: number) {\r\n this.radius += radius;\r\n this.theta += theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given Polar from the current Polar and stores the result\r\n * @param polar the polar to subtract\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius - polar.radius;\r\n ref.theta = this.theta - polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Polar from the current Polar\r\n * @param polar the polar to subtract\r\n * @returns the difference polar\r\n */\r\n public subtract(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.subtractToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Polar from the current Polar\r\n * @param polar the polar to subtract\r\n * @returns the current polar\r\n */\r\n public subtractInPlace(polar: Polar) {\r\n this.subtractToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current polar\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractFromFloatsToRef(radius: number, theta: number, ref: Polar) {\r\n ref.radius = this.radius - radius;\r\n ref.theta = this.theta - theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current polar\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @returns the difference polar\r\n */\r\n public subtractFromFloats(radius: number, theta: number) {\r\n const ref = new Polar(0, 0);\r\n this.subtractFromFloatsToRef(radius, theta, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Polar with the current Polar and stores the result\r\n * @param polar the polar to multiply\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public multiplyToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius * polar.radius;\r\n ref.theta = this.theta * polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Polar with the current Polar\r\n * @param polar the polar to multiply\r\n * @returns the product polar\r\n */\r\n public multiply(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.multiplyToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Polar with the current Polar\r\n * @param polar the polar to multiply\r\n * @returns the current polar\r\n */\r\n public multiplyInPlace(polar: Polar) {\r\n this.multiplyToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Divides the current Polar by the given Polar and stores the result\r\n * @param polar the polar to divide\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public divideToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius / polar.radius;\r\n ref.theta = this.theta / polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Polar by the given Polar\r\n * @param polar the polar to divide\r\n * @returns the quotient polar\r\n */\r\n public divide(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.divideToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Polar by the given Polar\r\n * @param polar the polar to divide\r\n * @returns the current polar\r\n */\r\n public divideInPlace(polar: Polar) {\r\n this.divideToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the current polar\r\n * @returns a clone of the current polar\r\n */\r\n public clone() {\r\n return new Polar(this.radius, this.theta);\r\n }\r\n\r\n /**\r\n * Copies the source polar into the current polar\r\n * @param source the polar to copy from\r\n * @returns the current polar\r\n */\r\n public copyFrom(source: Polar) {\r\n this.radius = source.radius;\r\n this.theta = source.theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Copies the given values into the current polar\r\n * @param radius the radius to use\r\n * @param theta the theta to use\r\n * @returns the current polar\r\n */\r\n public copyFromFloats(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Scales the current polar and stores the result\r\n * @param scale defines the multiplication factor\r\n * @param ref where to store the result\r\n * @returns the updated ref\r\n */\r\n public scaleToRef(scale: number, ref: Polar) {\r\n ref.radius = this.radius * scale;\r\n ref.theta = this.theta * scale;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current polar and returns a new polar with the scaled coordinates\r\n * @param scale defines the multiplication factor\r\n * @returns the scaled polar\r\n */\r\n public scale(scale: number) {\r\n const ref = new Polar(0, 0);\r\n this.scaleToRef(scale, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current polar\r\n * @param scale defines the multiplication factor\r\n * @returns the current polar\r\n */\r\n public scaleInPlace(scale: number) {\r\n this.scaleToRef(scale, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current polar\r\n * @param radius the new radius\r\n * @param theta the new theta\r\n * @returns the current polar\r\n */\r\n public set(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current polar\r\n * @param value the new values\r\n * @returns the current polar\r\n */\r\n public setAll(value: number) {\r\n this.set(value, value);\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the rectangular coordinates of the current Polar\r\n * @param ref the reference to assign the result\r\n * @returns the updated reference\r\n */\r\n public toVector2ToRef(ref: Vector2): Vector2 {\r\n const x = this.radius * Math.cos(this.theta);\r\n const y = this.radius * Math.sin(this.theta);\r\n ref.set(x, y);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets the rectangular coordinates of the current Polar\r\n * @returns the rectangular coordinates\r\n */\r\n public toVector2(): Vector2 {\r\n const ref = TmpVectors.Vector2[0];\r\n return this.toVector2ToRef(ref);\r\n }\r\n\r\n /**\r\n * Converts a given Vector2 to its polar coordinates\r\n * @param v the Vector2 to convert\r\n * @param ref the reference to assign the result\r\n * @returns the updated reference\r\n */\r\n public static FromVector2ToRef(v: Vector2, ref: Polar): Polar {\r\n const theta = Math.sign(v.y) * Math.acos(v.x / v.length());\r\n ref.radius = v.length();\r\n ref.theta = theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Converts a given Vector2 to its polar coordinates\r\n * @param v the Vector2 to convert\r\n * @returns a Polar\r\n */\r\n public static FromVector2(v: Vector2): Polar {\r\n const polar = new Polar(0, 0);\r\n Polar.FromVector2ToRef(v, polar);\r\n return polar;\r\n }\r\n\r\n /**\r\n * Converts an array of floats to a polar\r\n * @param array the array to convert\r\n * @returns the converted polar\r\n */\r\n public static FromArray(array: number[]) {\r\n return new Polar(array[0], array[1]);\r\n }\r\n}\r\n\r\n/**\r\n * Class used for (radius, theta, phi) vector representation.\r\n */\r\nexport class Spherical {\r\n public radius: number;\r\n public theta: number;\r\n public phi: number;\r\n\r\n /**\r\n * @param radius spherical radius\r\n * @param theta angle from positive y axis to radial line from 0 to PI (vertical)\r\n * @param phi angle from positive x axis measured anticlockwise from -PI to PI (horizontal)\r\n */\r\n constructor(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"Spherical\"\r\n */\r\n public getClassName() {\r\n return \"Spherical\";\r\n }\r\n\r\n /**\r\n * Converts the current spherical to a string\r\n * @returns the current spherical as a string\r\n */\r\n public toString() {\r\n return JSON.stringify(this);\r\n }\r\n\r\n /**\r\n * Converts the current spherical to an array\r\n * @reutrns the current spherical as an array\r\n */\r\n public asArray() {\r\n return [this.radius, this.theta, this.phi];\r\n }\r\n\r\n /**\r\n * Adds the current Spherical and the given Spherical and stores the result\r\n * @param spherical the spherical to add\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public addToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius + spherical.radius;\r\n ref.theta = this.theta + spherical.theta;\r\n ref.phi = this.phi + spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the current Spherical and the given Spherical\r\n * @param spherical the spherical to add\r\n * @returns the sum spherical\r\n */\r\n public add(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.addToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the given spherical to the current spherical\r\n * @param spherical the spherical to add\r\n * @returns the current spherical\r\n */\r\n public addInPlace(spherical: Spherical) {\r\n this.addToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds the provided values to the current spherical\r\n * @param radius the amount to add to the radius\r\n * @param theta the amount to add to the theta\r\n * @param phi the amount to add to the phi\r\n * @returns the current spherical\r\n */\r\n public addInPlaceFromFloats(radius: number, theta: number, phi: number) {\r\n this.radius += radius;\r\n this.theta += theta;\r\n this.phi += phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given Spherical from the current Spherical and stores the result\r\n * @param spherical the spherical to subtract\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius - spherical.radius;\r\n ref.theta = this.theta - spherical.theta;\r\n ref.phi = this.phi - spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Spherical from the current Spherical\r\n * @param spherical the spherical to subtract\r\n * @returns the difference spherical\r\n */\r\n public subtract(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.subtractToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Spherical from the current Spherical\r\n * @param spherical the spherical to subtract\r\n * @returns the current spherical\r\n */\r\n public subtractInPlace(spherical: Spherical) {\r\n this.subtractToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current spherical\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @param phi the amount to subtract from the phi\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractFromFloatsToRef(radius: number, theta: number, phi: number, ref: Spherical) {\r\n ref.radius = this.radius - radius;\r\n ref.theta = this.theta - theta;\r\n ref.phi = this.phi - phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current spherical\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @param phi the amount to subtract from the phi\r\n * @returns the difference spherical\r\n */\r\n public subtractFromFloats(radius: number, theta: number, phi: number) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.subtractFromFloatsToRef(radius, theta, phi, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Spherical with the current Spherical and stores the result\r\n * @param spherical the spherical to multiply\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public multiplyToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius * spherical.radius;\r\n ref.theta = this.theta * spherical.theta;\r\n ref.phi = this.phi * spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Spherical with the current Spherical\r\n * @param spherical the spherical to multiply\r\n * @returns the product spherical\r\n */\r\n public multiply(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.multiplyToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Spherical with the current Spherical\r\n * @param spherical the spherical to multiply\r\n * @returns the current spherical\r\n */\r\n public multiplyInPlace(spherical: Spherical) {\r\n this.multiplyToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Divides the current Spherical by the given Spherical and stores the result\r\n * @param spherical the spherical to divide\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public divideToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius / spherical.radius;\r\n ref.theta = this.theta / spherical.theta;\r\n ref.phi = this.phi / spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Spherical by the given Spherical\r\n * @param spherical the spherical to divide\r\n * @returns the quotient spherical\r\n */\r\n public divide(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.divideToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Spherical by the given Spherical\r\n * @param spherical the spherical to divide\r\n * @returns the current spherical\r\n */\r\n public divideInPlace(spherical: Spherical) {\r\n this.divideToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the current spherical\r\n * @returns a clone of the current spherical\r\n */\r\n public clone() {\r\n return new Spherical(this.radius, this.theta, this.phi);\r\n }\r\n\r\n /**\r\n * Copies the source spherical into the current spherical\r\n * @param source the spherical to copy from\r\n * @returns the current spherical\r\n */\r\n public copyFrom(source: Spherical) {\r\n this.radius = source.radius;\r\n this.theta = source.theta;\r\n this.phi = source.phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Copies the given values into the current spherical\r\n * @param radius the radius to use\r\n * @param theta the theta to use\r\n * @param phi the phi to use\r\n * @returns the current spherical\r\n */\r\n public copyFromFloats(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Scales the current spherical and stores the result\r\n * @param scale defines the multiplication factor\r\n * @param ref where to store the result\r\n * @returns the updated ref\r\n */\r\n public scaleToRef(scale: number, ref: Spherical) {\r\n ref.radius = this.radius * scale;\r\n ref.theta = this.theta * scale;\r\n ref.phi = this.phi * scale;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current spherical and returns a new spherical with the scaled coordinates\r\n * @param scale defines the multiplication factor\r\n * @returns the scaled spherical\r\n */\r\n public scale(scale: number) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.scaleToRef(scale, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current spherical\r\n * @param scale defines the multiplication factor\r\n * @returns the current spherical\r\n */\r\n public scaleInPlace(scale: number) {\r\n this.scaleToRef(scale, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current spherical\r\n * @param radius the new radius\r\n * @param theta the new theta\r\n * @param phi the new phi\r\n * @returns the current spherical\r\n */\r\n public set(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current spherical\r\n * @param value the new values\r\n * @returns the current spherical\r\n */\r\n public setAll(value: number) {\r\n this.set(value, value, value);\r\n return this;\r\n }\r\n\r\n /**\r\n * Assigns the rectangular coordinates of the current Spherical to a Vector3\r\n * @param ref the Vector3 to update\r\n * @returns the updated Vector3\r\n */\r\n public toVector3ToRef(ref: DeepImmutable<Vector3>): Vector3 {\r\n const x = this.radius * Math.sin(this.theta) * Math.cos(this.phi);\r\n const y = this.radius * Math.cos(this.theta);\r\n const z = this.radius * Math.sin(this.theta) * Math.sin(this.phi);\r\n ref.set(x, y, z);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets a Vector3 from the current spherical coordinates\r\n * @returns the Vector3\r\n */\r\n public toVector3(): Vector3 {\r\n const ref = TmpVectors.Vector3[0];\r\n return this.toVector3ToRef(ref);\r\n }\r\n\r\n /**\r\n * Assigns the spherical coordinates from a Vector3\r\n * @param vector the vector to convert\r\n * @param ref the Spherical to update\r\n * @returns the updated ref\r\n */\r\n public static FromVector3ToRef(vector: DeepImmutable<Vector3>, ref: Spherical): Spherical {\r\n ref.radius = vector.length();\r\n ref.theta = Math.acos(vector.y / ref.radius);\r\n ref.phi = Math.atan2(vector.z, vector.x);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets a Spherical from a Vector3\r\n * @param vector defines the vector in (x, y, z) coordinate space\r\n * @returns a new Spherical\r\n */\r\n public static FromVector3(vector: DeepImmutable<Vector3>): Spherical {\r\n const spherical = new Spherical(0, 0, 0);\r\n Spherical.FromVector3ToRef(vector, spherical);\r\n return spherical;\r\n }\r\n\r\n /**\r\n * Converts an array of floats to a spherical\r\n * @param array the array to convert\r\n * @returns the converted spherical\r\n */\r\n public static FromArray(array: number[]) {\r\n return new Spherical(array[0], array[1], array[2]);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"math.polar.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Maths/math.polar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,KAAK;IAId;;;;OAIG;IACH,YAAY,MAAc,EAAE,KAAa;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,KAAY,EAAE,GAAU;QACpC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QACxC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACrC,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,KAAY;QACnB,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC1B,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,UAAU,CAAC,KAAY;QAC1B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QA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,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjB,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,gBAAgB,CAAC,MAA8B,EAAE,GAAc;QACzE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAC7B,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,MAA8B;QACpD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,KAAe;QACnC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { Vector2, Vector3 } from \"./math.vector\";\r\n\r\n/**\r\n * Class used to store (r, theta) vector representation\r\n */\r\nexport class Polar {\r\n public radius: number;\r\n public theta: number;\r\n\r\n /**\r\n * Creates a new Polar object\r\n * @param radius the radius of the vector\r\n * @param theta the angle of the vector\r\n */\r\n constructor(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"Polar\"\r\n */\r\n public getClassName() {\r\n return \"Polar\";\r\n }\r\n\r\n /**\r\n * Converts the current polar to a string\r\n * @returns the current polar as a string\r\n */\r\n public toString() {\r\n return JSON.stringify(this);\r\n }\r\n\r\n /**\r\n * Converts the current polar to an array\r\n * @reutrns the current polar as an array\r\n */\r\n public asArray() {\r\n return [this.radius, this.theta];\r\n }\r\n\r\n /**\r\n * Adds the current Polar and the given Polar and stores the result\r\n * @param polar the polar to add\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public addToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius + polar.radius;\r\n ref.theta = this.theta + polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the current Polar and the given Polar\r\n * @param polar the polar to add\r\n * @returns the sum polar\r\n */\r\n public add(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.addToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the given polar to the current polar\r\n * @param polar the polar to add\r\n * @returns the current polar\r\n */\r\n public addInPlace(polar: Polar) {\r\n this.addToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds the provided values to the current polar\r\n * @param radius the amount to add to the radius\r\n * @param theta the amount to add to the theta\r\n * @returns the current polar\r\n */\r\n public addInPlaceFromFloats(radius: number, theta: number) {\r\n this.radius += radius;\r\n this.theta += theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given Polar from the current Polar and stores the result\r\n * @param polar the polar to subtract\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius - polar.radius;\r\n ref.theta = this.theta - polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Polar from the current Polar\r\n * @param polar the polar to subtract\r\n * @returns the difference polar\r\n */\r\n public subtract(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.subtractToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Polar from the current Polar\r\n * @param polar the polar to subtract\r\n * @returns the current polar\r\n */\r\n public subtractInPlace(polar: Polar) {\r\n this.subtractToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current polar\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractFromFloatsToRef(radius: number, theta: number, ref: Polar) {\r\n ref.radius = this.radius - radius;\r\n ref.theta = this.theta - theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current polar\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @returns the difference polar\r\n */\r\n public subtractFromFloats(radius: number, theta: number) {\r\n const ref = new Polar(0, 0);\r\n this.subtractFromFloatsToRef(radius, theta, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Polar with the current Polar and stores the result\r\n * @param polar the polar to multiply\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public multiplyToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius * polar.radius;\r\n ref.theta = this.theta * polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Polar with the current Polar\r\n * @param polar the polar to multiply\r\n * @returns the product polar\r\n */\r\n public multiply(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.multiplyToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Polar with the current Polar\r\n * @param polar the polar to multiply\r\n * @returns the current polar\r\n */\r\n public multiplyInPlace(polar: Polar) {\r\n this.multiplyToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Divides the current Polar by the given Polar and stores the result\r\n * @param polar the polar to divide\r\n * @param ref the polar to store the result in\r\n * @returns the updated ref\r\n */\r\n public divideToRef(polar: Polar, ref: Polar) {\r\n ref.radius = this.radius / polar.radius;\r\n ref.theta = this.theta / polar.theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Polar by the given Polar\r\n * @param polar the polar to divide\r\n * @returns the quotient polar\r\n */\r\n public divide(polar: Polar) {\r\n const ref = new Polar(0, 0);\r\n this.divideToRef(polar, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Polar by the given Polar\r\n * @param polar the polar to divide\r\n * @returns the current polar\r\n */\r\n public divideInPlace(polar: Polar) {\r\n this.divideToRef(polar, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the current polar\r\n * @returns a clone of the current polar\r\n */\r\n public clone() {\r\n return new Polar(this.radius, this.theta);\r\n }\r\n\r\n /**\r\n * Copies the source polar into the current polar\r\n * @param source the polar to copy from\r\n * @returns the current polar\r\n */\r\n public copyFrom(source: Polar) {\r\n this.radius = source.radius;\r\n this.theta = source.theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Copies the given values into the current polar\r\n * @param radius the radius to use\r\n * @param theta the theta to use\r\n * @returns the current polar\r\n */\r\n public copyFromFloats(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Scales the current polar and stores the result\r\n * @param scale defines the multiplication factor\r\n * @param ref where to store the result\r\n * @returns the updated ref\r\n */\r\n public scaleToRef(scale: number, ref: Polar) {\r\n ref.radius = this.radius * scale;\r\n ref.theta = this.theta * scale;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current polar and returns a new polar with the scaled coordinates\r\n * @param scale defines the multiplication factor\r\n * @returns the scaled polar\r\n */\r\n public scale(scale: number) {\r\n const ref = new Polar(0, 0);\r\n this.scaleToRef(scale, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current polar\r\n * @param scale defines the multiplication factor\r\n * @returns the current polar\r\n */\r\n public scaleInPlace(scale: number) {\r\n this.scaleToRef(scale, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current polar\r\n * @param radius the new radius\r\n * @param theta the new theta\r\n * @returns the current polar\r\n */\r\n public set(radius: number, theta: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current polar\r\n * @param value the new values\r\n * @returns the current polar\r\n */\r\n public setAll(value: number) {\r\n this.set(value, value);\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the rectangular coordinates of the current Polar\r\n * @param ref the reference to assign the result\r\n * @returns the updated reference\r\n */\r\n public toVector2ToRef(ref: Vector2): Vector2 {\r\n const x = this.radius * Math.cos(this.theta);\r\n const y = this.radius * Math.sin(this.theta);\r\n ref.set(x, y);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets the rectangular coordinates of the current Polar\r\n * @returns the rectangular coordinates\r\n */\r\n public toVector2(): Vector2 {\r\n const ref = new Vector2(0, 0);\r\n return this.toVector2ToRef(ref);\r\n }\r\n\r\n /**\r\n * Converts a given Vector2 to its polar coordinates\r\n * @param v the Vector2 to convert\r\n * @param ref the reference to assign the result\r\n * @returns the updated reference\r\n */\r\n public static FromVector2ToRef(v: Vector2, ref: Polar): Polar {\r\n const theta = Math.sign(v.y) * Math.acos(v.x / v.length());\r\n ref.radius = v.length();\r\n ref.theta = theta;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Converts a given Vector2 to its polar coordinates\r\n * @param v the Vector2 to convert\r\n * @returns a Polar\r\n */\r\n public static FromVector2(v: Vector2): Polar {\r\n const polar = new Polar(0, 0);\r\n Polar.FromVector2ToRef(v, polar);\r\n return polar;\r\n }\r\n\r\n /**\r\n * Converts an array of floats to a polar\r\n * @param array the array to convert\r\n * @returns the converted polar\r\n */\r\n public static FromArray(array: number[]) {\r\n return new Polar(array[0], array[1]);\r\n }\r\n}\r\n\r\n/**\r\n * Class used for (radius, theta, phi) vector representation.\r\n */\r\nexport class Spherical {\r\n public radius: number;\r\n public theta: number;\r\n public phi: number;\r\n\r\n /**\r\n * @param radius spherical radius\r\n * @param theta angle from positive y axis to radial line from 0 to PI (vertical)\r\n * @param phi angle from positive x axis measured anticlockwise from -PI to PI (horizontal)\r\n */\r\n constructor(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n }\r\n\r\n /**\r\n * Gets the class name\r\n * @returns the string \"Spherical\"\r\n */\r\n public getClassName() {\r\n return \"Spherical\";\r\n }\r\n\r\n /**\r\n * Converts the current spherical to a string\r\n * @returns the current spherical as a string\r\n */\r\n public toString() {\r\n return JSON.stringify(this);\r\n }\r\n\r\n /**\r\n * Converts the current spherical to an array\r\n * @reutrns the current spherical as an array\r\n */\r\n public asArray() {\r\n return [this.radius, this.theta, this.phi];\r\n }\r\n\r\n /**\r\n * Adds the current Spherical and the given Spherical and stores the result\r\n * @param spherical the spherical to add\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public addToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius + spherical.radius;\r\n ref.theta = this.theta + spherical.theta;\r\n ref.phi = this.phi + spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the current Spherical and the given Spherical\r\n * @param spherical the spherical to add\r\n * @returns the sum spherical\r\n */\r\n public add(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.addToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds the given spherical to the current spherical\r\n * @param spherical the spherical to add\r\n * @returns the current spherical\r\n */\r\n public addInPlace(spherical: Spherical) {\r\n this.addToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds the provided values to the current spherical\r\n * @param radius the amount to add to the radius\r\n * @param theta the amount to add to the theta\r\n * @param phi the amount to add to the phi\r\n * @returns the current spherical\r\n */\r\n public addInPlaceFromFloats(radius: number, theta: number, phi: number) {\r\n this.radius += radius;\r\n this.theta += theta;\r\n this.phi += phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given Spherical from the current Spherical and stores the result\r\n * @param spherical the spherical to subtract\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius - spherical.radius;\r\n ref.theta = this.theta - spherical.theta;\r\n ref.phi = this.phi - spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Spherical from the current Spherical\r\n * @param spherical the spherical to subtract\r\n * @returns the difference spherical\r\n */\r\n public subtract(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.subtractToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given Spherical from the current Spherical\r\n * @param spherical the spherical to subtract\r\n * @returns the current spherical\r\n */\r\n public subtractInPlace(spherical: Spherical) {\r\n this.subtractToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current spherical\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @param phi the amount to subtract from the phi\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public subtractFromFloatsToRef(radius: number, theta: number, phi: number, ref: Spherical) {\r\n ref.radius = this.radius - radius;\r\n ref.theta = this.theta - theta;\r\n ref.phi = this.phi - phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Subtracts the given floats from the current spherical\r\n * @param radius the amount to subtract from the radius\r\n * @param theta the amount to subtract from the theta\r\n * @param phi the amount to subtract from the phi\r\n * @returns the difference spherical\r\n */\r\n public subtractFromFloats(radius: number, theta: number, phi: number) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.subtractFromFloatsToRef(radius, theta, phi, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Spherical with the current Spherical and stores the result\r\n * @param spherical the spherical to multiply\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public multiplyToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius * spherical.radius;\r\n ref.theta = this.theta * spherical.theta;\r\n ref.phi = this.phi * spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Spherical with the current Spherical\r\n * @param spherical the spherical to multiply\r\n * @returns the product spherical\r\n */\r\n public multiply(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.multiplyToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Multiplies the given Spherical with the current Spherical\r\n * @param spherical the spherical to multiply\r\n * @returns the current spherical\r\n */\r\n public multiplyInPlace(spherical: Spherical) {\r\n this.multiplyToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Divides the current Spherical by the given Spherical and stores the result\r\n * @param spherical the spherical to divide\r\n * @param ref the spherical to store the result in\r\n * @returns the updated ref\r\n */\r\n public divideToRef(spherical: Spherical, ref: Spherical) {\r\n ref.radius = this.radius / spherical.radius;\r\n ref.theta = this.theta / spherical.theta;\r\n ref.phi = this.phi / spherical.phi;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Spherical by the given Spherical\r\n * @param spherical the spherical to divide\r\n * @returns the quotient spherical\r\n */\r\n public divide(spherical: Spherical) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.divideToRef(spherical, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Divides the current Spherical by the given Spherical\r\n * @param spherical the spherical to divide\r\n * @returns the current spherical\r\n */\r\n public divideInPlace(spherical: Spherical) {\r\n this.divideToRef(spherical, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the current spherical\r\n * @returns a clone of the current spherical\r\n */\r\n public clone() {\r\n return new Spherical(this.radius, this.theta, this.phi);\r\n }\r\n\r\n /**\r\n * Copies the source spherical into the current spherical\r\n * @param source the spherical to copy from\r\n * @returns the current spherical\r\n */\r\n public copyFrom(source: Spherical) {\r\n this.radius = source.radius;\r\n this.theta = source.theta;\r\n this.phi = source.phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Copies the given values into the current spherical\r\n * @param radius the radius to use\r\n * @param theta the theta to use\r\n * @param phi the phi to use\r\n * @returns the current spherical\r\n */\r\n public copyFromFloats(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Scales the current spherical and stores the result\r\n * @param scale defines the multiplication factor\r\n * @param ref where to store the result\r\n * @returns the updated ref\r\n */\r\n public scaleToRef(scale: number, ref: Spherical) {\r\n ref.radius = this.radius * scale;\r\n ref.theta = this.theta * scale;\r\n ref.phi = this.phi * scale;\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current spherical and returns a new spherical with the scaled coordinates\r\n * @param scale defines the multiplication factor\r\n * @returns the scaled spherical\r\n */\r\n public scale(scale: number) {\r\n const ref = new Spherical(0, 0, 0);\r\n this.scaleToRef(scale, ref);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Scales the current spherical\r\n * @param scale defines the multiplication factor\r\n * @returns the current spherical\r\n */\r\n public scaleInPlace(scale: number) {\r\n this.scaleToRef(scale, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current spherical\r\n * @param radius the new radius\r\n * @param theta the new theta\r\n * @param phi the new phi\r\n * @returns the current spherical\r\n */\r\n public set(radius: number, theta: number, phi: number) {\r\n this.radius = radius;\r\n this.theta = theta;\r\n this.phi = phi;\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the values of the current spherical\r\n * @param value the new values\r\n * @returns the current spherical\r\n */\r\n public setAll(value: number) {\r\n this.set(value, value, value);\r\n return this;\r\n }\r\n\r\n /**\r\n * Assigns the rectangular coordinates of the current Spherical to a Vector3\r\n * @param ref the Vector3 to update\r\n * @returns the updated Vector3\r\n */\r\n public toVector3ToRef(ref: DeepImmutable<Vector3>): Vector3 {\r\n const x = this.radius * Math.sin(this.theta) * Math.cos(this.phi);\r\n const y = this.radius * Math.cos(this.theta);\r\n const z = this.radius * Math.sin(this.theta) * Math.sin(this.phi);\r\n ref.set(x, y, z);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets a Vector3 from the current spherical coordinates\r\n * @returns the (x, y,z) form of the current Spherical\r\n */\r\n public toVector3(): Vector3 {\r\n const ref = new Vector3(0, 0, 0);\r\n return this.toVector3ToRef(ref);\r\n }\r\n\r\n /**\r\n * Assigns the spherical coordinates from a Vector3\r\n * @param vector the vector to convert\r\n * @param ref the Spherical to update\r\n * @returns the updated ref\r\n */\r\n public static FromVector3ToRef(vector: DeepImmutable<Vector3>, ref: Spherical): Spherical {\r\n ref.radius = vector.length();\r\n ref.theta = Math.acos(vector.y / ref.radius);\r\n ref.phi = Math.atan2(vector.z, vector.x);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Gets a Spherical from a Vector3\r\n * @param vector defines the vector in (x, y, z) coordinate space\r\n * @returns a new Spherical\r\n */\r\n public static FromVector3(vector: DeepImmutable<Vector3>): Spherical {\r\n const spherical = new Spherical(0, 0, 0);\r\n Spherical.FromVector3ToRef(vector, spherical);\r\n return spherical;\r\n }\r\n\r\n /**\r\n * Converts an array of floats to a spherical\r\n * @param array the array to convert\r\n * @returns the converted spherical\r\n */\r\n public static FromArray(array: number[]) {\r\n return new Spherical(array[0], array[1], array[2]);\r\n }\r\n}\r\n"]}