@babylonjs/core 6.45.0 → 6.46.0

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 (235) hide show
  1. package/Animations/animation.js +1 -1
  2. package/Animations/animation.js.map +1 -1
  3. package/BakedVertexAnimation/bakedVertexAnimationManager.js +2 -1
  4. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  5. package/Bones/skeleton.js +2 -2
  6. package/Bones/skeleton.js.map +1 -1
  7. package/Cameras/camera.d.ts +3 -3
  8. package/Cameras/camera.js +2 -1
  9. package/Cameras/camera.js.map +1 -1
  10. package/Cameras/cameraInputsManager.js +1 -1
  11. package/Cameras/cameraInputsManager.js.map +1 -1
  12. package/Cameras/targetCamera.js +4 -0
  13. package/Cameras/targetCamera.js.map +1 -1
  14. package/Compute/computeShader.d.ts +4 -2
  15. package/Compute/computeShader.js +7 -3
  16. package/Compute/computeShader.js.map +1 -1
  17. package/Debug/directionalLightFrustumViewer.js +6 -6
  18. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  19. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  20. package/Engines/Extensions/engine.computeShader.js +1 -0
  21. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  22. package/Engines/Extensions/engine.rawTexture.js +3 -3
  23. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  24. package/Engines/Native/nativePipelineContext.js +1 -1
  25. package/Engines/Native/nativePipelineContext.js.map +1 -1
  26. package/Engines/WebGL/webGLPipelineContext.js +1 -1
  27. package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
  28. package/Engines/WebGPU/webgpuComputeContext.js +7 -3
  29. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  30. package/Engines/engine.d.ts +1 -1
  31. package/Engines/thinEngine.js +2 -2
  32. package/Engines/thinEngine.js.map +1 -1
  33. package/Engines/webgpuEngine.js +2 -15
  34. package/Engines/webgpuEngine.js.map +1 -1
  35. package/Layers/glowLayer.js +2 -1
  36. package/Layers/glowLayer.js.map +1 -1
  37. package/Layers/highlightLayer.js +2 -1
  38. package/Layers/highlightLayer.js.map +1 -1
  39. package/Lights/light.js +2 -1
  40. package/Lights/light.js.map +1 -1
  41. package/Loading/Plugins/babylonFileLoader.js +9 -0
  42. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  43. package/Loading/sceneLoader.d.ts +6 -1
  44. package/Loading/sceneLoader.js +6 -5
  45. package/Loading/sceneLoader.js.map +1 -1
  46. package/Materials/Background/backgroundMaterial.js +2 -1
  47. package/Materials/Background/backgroundMaterial.js.map +1 -1
  48. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
  49. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  50. package/Materials/Node/nodeMaterial.d.ts +2 -1
  51. package/Materials/Node/nodeMaterial.js +5 -1
  52. package/Materials/Node/nodeMaterial.js.map +1 -1
  53. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -1
  54. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  55. package/Materials/PBR/pbrMaterial.js +2 -1
  56. package/Materials/PBR/pbrMaterial.js.map +1 -1
  57. package/Materials/PBR/pbrMetallicRoughnessMaterial.js +2 -1
  58. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  59. package/Materials/PBR/pbrSpecularGlossinessMaterial.js +2 -1
  60. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  61. package/Materials/Textures/baseTexture.js +2 -1
  62. package/Materials/Textures/baseTexture.js.map +1 -1
  63. package/Materials/Textures/cubeTexture.js +2 -1
  64. package/Materials/Textures/cubeTexture.js.map +1 -1
  65. package/Materials/Textures/rawCubeTexture.js +1 -1
  66. package/Materials/Textures/rawCubeTexture.js.map +1 -1
  67. package/Materials/Textures/texture.js +2 -1
  68. package/Materials/Textures/texture.js.map +1 -1
  69. package/Materials/colorCurves.d.ts +1 -1
  70. package/Materials/colorCurves.functions.d.ts +5 -0
  71. package/Materials/colorCurves.functions.js +8 -0
  72. package/Materials/colorCurves.functions.js.map +1 -0
  73. package/Materials/colorCurves.js +8 -8
  74. package/Materials/colorCurves.js.map +1 -1
  75. package/Materials/fresnelParameters.js +1 -1
  76. package/Materials/fresnelParameters.js.map +1 -1
  77. package/Materials/imageProcessingConfiguration.d.ts +3 -48
  78. package/Materials/imageProcessingConfiguration.defines.d.ts +46 -0
  79. package/Materials/imageProcessingConfiguration.defines.js +27 -0
  80. package/Materials/imageProcessingConfiguration.defines.js.map +1 -0
  81. package/Materials/imageProcessingConfiguration.functions.d.ts +13 -0
  82. package/Materials/imageProcessingConfiguration.functions.js +41 -0
  83. package/Materials/imageProcessingConfiguration.functions.js.map +1 -0
  84. package/Materials/imageProcessingConfiguration.js +18 -69
  85. package/Materials/imageProcessingConfiguration.js.map +1 -1
  86. package/Materials/material.js +2 -1
  87. package/Materials/material.js.map +1 -1
  88. package/Materials/materialHelper.d.ts +33 -33
  89. package/Materials/materialHelper.js +244 -286
  90. package/Materials/materialHelper.js.map +1 -1
  91. package/Materials/materialPluginBase.js +2 -1
  92. package/Materials/materialPluginBase.js.map +1 -1
  93. package/Materials/materialStencilState.js +2 -1
  94. package/Materials/materialStencilState.js.map +1 -1
  95. package/Materials/shaderMaterial.js +1 -1
  96. package/Materials/shaderMaterial.js.map +1 -1
  97. package/Materials/standardMaterial.d.ts +1 -1
  98. package/Materials/standardMaterial.js +2 -1
  99. package/Materials/standardMaterial.js.map +1 -1
  100. package/Materials/uniformBuffer.js +2 -2
  101. package/Materials/uniformBuffer.js.map +1 -1
  102. package/Maths/math.color.d.ts +392 -66
  103. package/Maths/math.color.js +541 -65
  104. package/Maths/math.color.js.map +1 -1
  105. package/Maths/math.like.d.ts +17 -28
  106. package/Maths/math.like.js.map +1 -1
  107. package/Maths/math.plane.d.ts +2 -1
  108. package/Maths/math.plane.js.map +1 -1
  109. package/Maths/math.polar.d.ts +1 -1
  110. package/Maths/math.polar.js.map +1 -1
  111. package/Maths/math.scalar.d.ts +6 -6
  112. package/Maths/math.scalar.functions.d.ts +51 -0
  113. package/Maths/math.scalar.functions.js +80 -0
  114. package/Maths/math.scalar.functions.js.map +1 -0
  115. package/Maths/math.scalar.js +48 -73
  116. package/Maths/math.scalar.js.map +1 -1
  117. package/Maths/math.vector.d.ts +571 -72
  118. package/Maths/math.vector.js +917 -119
  119. package/Maths/math.vector.js.map +1 -1
  120. package/Maths/math.viewport.d.ts +2 -1
  121. package/Maths/math.viewport.js.map +1 -1
  122. package/Maths/tensor.d.ts +411 -0
  123. package/Maths/tensor.js +3 -0
  124. package/Maths/tensor.js.map +1 -0
  125. package/Meshes/Node/Blocks/Set/setColorsBlock.js +20 -4
  126. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  127. package/Meshes/Node/nodeGeometry.js +2 -1
  128. package/Meshes/Node/nodeGeometry.js.map +1 -1
  129. package/Meshes/mesh.js +2 -2
  130. package/Meshes/mesh.js.map +1 -1
  131. package/Meshes/mesh.vertexData.d.ts +4 -0
  132. package/Meshes/mesh.vertexData.js +10 -0
  133. package/Meshes/mesh.vertexData.js.map +1 -1
  134. package/Meshes/transformNode.js +2 -1
  135. package/Meshes/transformNode.js.map +1 -1
  136. package/Misc/arrayTools.d.ts +2 -19
  137. package/Misc/arrayTools.js.map +1 -1
  138. package/Misc/decorators.d.ts +0 -80
  139. package/Misc/decorators.functions.d.ts +7 -0
  140. package/Misc/decorators.functions.js +52 -0
  141. package/Misc/decorators.functions.js.map +1 -0
  142. package/Misc/decorators.js +2 -318
  143. package/Misc/decorators.js.map +1 -1
  144. package/Misc/decorators.serialization.d.ts +81 -0
  145. package/Misc/decorators.serialization.js +269 -0
  146. package/Misc/decorators.serialization.js.map +1 -0
  147. package/Misc/index.d.ts +1 -0
  148. package/Misc/index.js +1 -0
  149. package/Misc/index.js.map +1 -1
  150. package/Misc/sceneRecorder.js +1 -1
  151. package/Misc/sceneRecorder.js.map +1 -1
  152. package/Misc/sceneSerializer.js +8 -1
  153. package/Misc/sceneSerializer.js.map +1 -1
  154. package/Misc/tools.functions.d.ts +14 -0
  155. package/Misc/tools.functions.js +23 -0
  156. package/Misc/tools.functions.js.map +1 -0
  157. package/Misc/tools.js +5 -6
  158. package/Misc/tools.js.map +1 -1
  159. package/Morph/morphTarget.js +2 -1
  160. package/Morph/morphTarget.js.map +1 -1
  161. package/Particles/EmitterTypes/boxParticleEmitter.js +8 -8
  162. package/Particles/EmitterTypes/boxParticleEmitter.js.map +1 -1
  163. package/Particles/baseParticleSystem.d.ts +8 -11
  164. package/Particles/baseParticleSystem.js +9 -40
  165. package/Particles/baseParticleSystem.js.map +1 -1
  166. package/Particles/gpuParticleSystem.d.ts +71 -1
  167. package/Particles/gpuParticleSystem.js +102 -1
  168. package/Particles/gpuParticleSystem.js.map +1 -1
  169. package/Particles/particle.d.ts +3 -3
  170. package/Particles/particle.js +3 -3
  171. package/Particles/particle.js.map +1 -1
  172. package/Particles/particleSystem.d.ts +81 -455
  173. package/Particles/particleSystem.functions.d.ts +61 -0
  174. package/Particles/particleSystem.functions.js +79 -0
  175. package/Particles/particleSystem.functions.js.map +1 -0
  176. package/Particles/particleSystem.js +390 -1984
  177. package/Particles/particleSystem.js.map +1 -1
  178. package/Particles/thinParticleSystem.d.ts +485 -0
  179. package/Particles/thinParticleSystem.js +1768 -0
  180. package/Particles/thinParticleSystem.js.map +1 -0
  181. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +2 -1
  182. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  183. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -1
  184. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  185. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +2 -1
  186. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  187. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +2 -1
  188. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  189. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +2 -1
  190. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
  191. package/PostProcesses/blackAndWhitePostProcess.js +2 -1
  192. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  193. package/PostProcesses/blurPostProcess.js +2 -1
  194. package/PostProcesses/blurPostProcess.js.map +1 -1
  195. package/PostProcesses/chromaticAberrationPostProcess.js +2 -1
  196. package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
  197. package/PostProcesses/colorCorrectionPostProcess.js +2 -1
  198. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  199. package/PostProcesses/convolutionPostProcess.js +2 -1
  200. package/PostProcesses/convolutionPostProcess.js.map +1 -1
  201. package/PostProcesses/displayPassPostProcess.js +1 -1
  202. package/PostProcesses/displayPassPostProcess.js.map +1 -1
  203. package/PostProcesses/filterPostProcess.js +2 -1
  204. package/PostProcesses/filterPostProcess.js.map +1 -1
  205. package/PostProcesses/fxaaPostProcess.js +1 -1
  206. package/PostProcesses/fxaaPostProcess.js.map +1 -1
  207. package/PostProcesses/grainPostProcess.js +2 -1
  208. package/PostProcesses/grainPostProcess.js.map +1 -1
  209. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  210. package/PostProcesses/motionBlurPostProcess.js +2 -1
  211. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  212. package/PostProcesses/passPostProcess.js +1 -1
  213. package/PostProcesses/passPostProcess.js.map +1 -1
  214. package/PostProcesses/postProcess.js +2 -1
  215. package/PostProcesses/postProcess.js.map +1 -1
  216. package/PostProcesses/refractionPostProcess.js +2 -1
  217. package/PostProcesses/refractionPostProcess.js.map +1 -1
  218. package/PostProcesses/screenSpaceCurvaturePostProcess.js +2 -1
  219. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  220. package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -1
  221. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  222. package/PostProcesses/sharpenPostProcess.js +2 -1
  223. package/PostProcesses/sharpenPostProcess.js.map +1 -1
  224. package/Probes/reflectionProbe.js +2 -1
  225. package/Probes/reflectionProbe.js.map +1 -1
  226. package/Sprites/spriteManager.d.ts +4 -0
  227. package/Sprites/spriteManager.js.map +1 -1
  228. package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
  229. package/XR/features/WebXRControllerTeleportation.js +75 -31
  230. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  231. package/node.js +2 -1
  232. package/node.js.map +1 -1
  233. package/package.json +1 -1
  234. package/types.d.ts +105 -0
  235. package/types.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"math.plane.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.plane.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,KAAK;IAWd;;;;;;OAMG;IACH,YAAY,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QAClD,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED;;OAEG;IACI,OAAO;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,UAAU;IACV;;OAEG;IACI,KAAK;QACR,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE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;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,MAA8B,EAAE,MAAe;QACxE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,0BAA0B,CAAkB,MAA8B,EAAE,MAA8B,EAAE,MAAS;QACxH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,0CAA0C,CAAC,MAA8B,EAAE,MAA8B,EAAE,KAA6B;QAC3I,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;;AAnNc,gBAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { Vector3, Matrix } from \"./math.vector\";\r\n\r\n/**\r\n * Represents a plane by the equation ax + by + cz + d = 0\r\n */\r\nexport class Plane {\r\n private static _TmpMatrix = Matrix.Identity();\r\n\r\n /**\r\n * Normal of the plane (a,b,c)\r\n */\r\n public normal: Vector3;\r\n /**\r\n * d component of the plane\r\n */\r\n public d: number;\r\n /**\r\n * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0\r\n * @param a a component of the plane\r\n * @param b b component of the plane\r\n * @param c c component of the plane\r\n * @param d d component of the plane\r\n */\r\n constructor(a: number, b: number, c: number, d: number) {\r\n this.normal = new Vector3(a, b, c);\r\n this.d = d;\r\n }\r\n\r\n /**\r\n * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].\r\n */\r\n public asArray(): number[] {\r\n return [this.normal.x, this.normal.y, this.normal.z, this.d];\r\n }\r\n\r\n // Methods\r\n /**\r\n * @returns a new plane copied from the current Plane.\r\n */\r\n public clone(): Plane {\r\n return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);\r\n }\r\n /**\r\n * @returns the string \"Plane\".\r\n */\r\n public getClassName(): string {\r\n return \"Plane\";\r\n }\r\n /**\r\n * @returns the Plane hash code.\r\n */\r\n public getHashCode(): number {\r\n let hash = this.normal.getHashCode();\r\n hash = (hash * 397) ^ (this.d | 0);\r\n return hash;\r\n }\r\n /**\r\n * Normalize the current Plane in place.\r\n * @returns the updated Plane.\r\n */\r\n public normalize(): Plane {\r\n const norm = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z);\r\n let magnitude = 0.0;\r\n\r\n if (norm !== 0) {\r\n magnitude = 1.0 / norm;\r\n }\r\n this.normal.x *= magnitude;\r\n this.normal.y *= magnitude;\r\n this.normal.z *= magnitude;\r\n this.d *= magnitude;\r\n return this;\r\n }\r\n /**\r\n * Applies a transformation the plane and returns the result\r\n * @param transformation the transformation matrix to be applied to the plane\r\n * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.\r\n */\r\n public transform(transformation: DeepImmutable<Matrix>): Plane {\r\n const invertedMatrix = Plane._TmpMatrix;\r\n transformation.invertToRef(invertedMatrix);\r\n const m = invertedMatrix.m;\r\n const x = this.normal.x;\r\n const y = this.normal.y;\r\n const z = this.normal.z;\r\n const d = this.d;\r\n\r\n const normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];\r\n const normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];\r\n const normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];\r\n const finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];\r\n\r\n return new Plane(normalX, normalY, normalZ, finalD);\r\n }\r\n\r\n /**\r\n * Compute the dot product between the point and the plane normal\r\n * @param point point to calculate the dot product with\r\n * @returns the dot product (float) of the point coordinates and the plane normal.\r\n */\r\n public dotCoordinate(point: DeepImmutable<Vector3>): number {\r\n return this.normal.x * point.x + this.normal.y * point.y + this.normal.z * point.z + this.d;\r\n }\r\n\r\n /**\r\n * Updates the current Plane from the plane defined by the three given points.\r\n * @param point1 one of the points used to construct the plane\r\n * @param point2 one of the points used to construct the plane\r\n * @param point3 one of the points used to construct the plane\r\n * @returns the updated Plane.\r\n */\r\n public copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane {\r\n const x1 = point2.x - point1.x;\r\n const y1 = point2.y - point1.y;\r\n const z1 = point2.z - point1.z;\r\n const x2 = point3.x - point1.x;\r\n const y2 = point3.y - point1.y;\r\n const z2 = point3.z - point1.z;\r\n const yz = y1 * z2 - z1 * y2;\r\n const xz = z1 * x2 - x1 * z2;\r\n const xy = x1 * y2 - y1 * x2;\r\n const pyth = Math.sqrt(yz * yz + xz * xz + xy * xy);\r\n let invPyth;\r\n\r\n if (pyth !== 0) {\r\n invPyth = 1.0 / pyth;\r\n } else {\r\n invPyth = 0.0;\r\n }\r\n\r\n this.normal.x = yz * invPyth;\r\n this.normal.y = xz * invPyth;\r\n this.normal.z = xy * invPyth;\r\n this.d = -(this.normal.x * point1.x + this.normal.y * point1.y + this.normal.z * point1.z);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).\r\n * Note that for this function to work as expected you should make sure that:\r\n * - direction and the plane normal are normalized\r\n * - epsilon is a number just bigger than -1, something like -0.99 for eg\r\n * @param direction the direction to check if the plane is facing\r\n * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)\r\n * @returns True if the plane is facing the given direction\r\n */\r\n public isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean {\r\n const dot = Vector3.Dot(this.normal, direction);\r\n return dot <= epsilon;\r\n }\r\n\r\n /**\r\n * Calculates the distance to a point\r\n * @param point point to calculate distance to\r\n * @returns the signed distance (float) from the given point to the Plane.\r\n */\r\n public signedDistanceTo(point: DeepImmutable<Vector3>): number {\r\n return Vector3.Dot(point, this.normal) + this.d;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a plane from an array\r\n * @param array the array to create a plane from\r\n * @returns a new Plane from the given array.\r\n */\r\n static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane {\r\n return new Plane(array[0], array[1], array[2], array[3]);\r\n }\r\n /**\r\n * Creates a plane from three points\r\n * @param point1 point used to create the plane\r\n * @param point2 point used to create the plane\r\n * @param point3 point used to create the plane\r\n * @returns a new Plane defined by the three given points.\r\n */\r\n static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane {\r\n const result = new Plane(0.0, 0.0, 0.0, 0.0);\r\n result.copyFromPoints(point1, point2, point3);\r\n return result;\r\n }\r\n /**\r\n * Creates a plane from an origin point and a normal\r\n * @param origin origin of the plane to be constructed\r\n * @param normal normal of the plane to be constructed\r\n * @returns a new Plane the normal vector to this plane at the given origin point.\r\n */\r\n static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane {\r\n const plane = new Plane(0.0, 0.0, 0.0, 0.0);\r\n return this.FromPositionAndNormalToRef(origin, normal, plane);\r\n }\r\n\r\n /**\r\n * Updates the given Plane \"result\" from an origin point and a normal.\r\n * @param origin origin of the plane to be constructed\r\n * @param normal the normalized normals of the plane to be constructed\r\n * @param result defines the Plane where to store the result\r\n * @returns result input\r\n */\r\n static FromPositionAndNormalToRef<T extends Plane>(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, result: T): T {\r\n result.normal.copyFrom(normal);\r\n result.normal.normalize();\r\n result.d = -origin.dot(result.normal);\r\n return result;\r\n }\r\n\r\n /**\r\n * Calculates the distance from a plane and a point\r\n * @param origin origin of the plane to be constructed\r\n * @param normal normal of the plane to be constructed\r\n * @param point point to calculate distance to\r\n * @returns the signed distance between the plane defined by the normal vector at the \"origin\"\" point and the given other point.\r\n */\r\n static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number {\r\n const d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);\r\n return Vector3.Dot(point, normal) + d;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"math.plane.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.plane.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,KAAK;IAWd;;;;;;OAMG;IACH,YAAY,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QAClD,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAED;;OAEG;IACI,OAAO;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,UAAU;IACV;;OAEG;IACI,KAAK;QACR,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC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D;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,MAA8B,EAAE,MAAe;QACxE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,0BAA0B,CAAkB,MAA8B,EAAE,MAA8B,EAAE,MAAS;QACxH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,0CAA0C,CAAC,MAA8B,EAAE,MAA8B,EAAE,KAA6B;QAC3I,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;;AAnNc,gBAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { Vector3, Matrix } from \"./math.vector\";\r\nimport type { IPlaneLike } from \"./math.like\";\r\n\r\n/**\r\n * Represents a plane by the equation ax + by + cz + d = 0\r\n */\r\nexport class Plane implements IPlaneLike {\r\n private static _TmpMatrix = Matrix.Identity();\r\n\r\n /**\r\n * Normal of the plane (a,b,c)\r\n */\r\n public normal: Vector3;\r\n /**\r\n * d component of the plane\r\n */\r\n public d: number;\r\n /**\r\n * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0\r\n * @param a a component of the plane\r\n * @param b b component of the plane\r\n * @param c c component of the plane\r\n * @param d d component of the plane\r\n */\r\n constructor(a: number, b: number, c: number, d: number) {\r\n this.normal = new Vector3(a, b, c);\r\n this.d = d;\r\n }\r\n\r\n /**\r\n * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].\r\n */\r\n public asArray(): number[] {\r\n return [this.normal.x, this.normal.y, this.normal.z, this.d];\r\n }\r\n\r\n // Methods\r\n /**\r\n * @returns a new plane copied from the current Plane.\r\n */\r\n public clone(): Plane {\r\n return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);\r\n }\r\n /**\r\n * @returns the string \"Plane\".\r\n */\r\n public getClassName(): string {\r\n return \"Plane\";\r\n }\r\n /**\r\n * @returns the Plane hash code.\r\n */\r\n public getHashCode(): number {\r\n let hash = this.normal.getHashCode();\r\n hash = (hash * 397) ^ (this.d | 0);\r\n return hash;\r\n }\r\n /**\r\n * Normalize the current Plane in place.\r\n * @returns the updated Plane.\r\n */\r\n public normalize(): Plane {\r\n const norm = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z);\r\n let magnitude = 0.0;\r\n\r\n if (norm !== 0) {\r\n magnitude = 1.0 / norm;\r\n }\r\n this.normal.x *= magnitude;\r\n this.normal.y *= magnitude;\r\n this.normal.z *= magnitude;\r\n this.d *= magnitude;\r\n return this;\r\n }\r\n /**\r\n * Applies a transformation the plane and returns the result\r\n * @param transformation the transformation matrix to be applied to the plane\r\n * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.\r\n */\r\n public transform(transformation: DeepImmutable<Matrix>): Plane {\r\n const invertedMatrix = Plane._TmpMatrix;\r\n transformation.invertToRef(invertedMatrix);\r\n const m = invertedMatrix.m;\r\n const x = this.normal.x;\r\n const y = this.normal.y;\r\n const z = this.normal.z;\r\n const d = this.d;\r\n\r\n const normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];\r\n const normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];\r\n const normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];\r\n const finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];\r\n\r\n return new Plane(normalX, normalY, normalZ, finalD);\r\n }\r\n\r\n /**\r\n * Compute the dot product between the point and the plane normal\r\n * @param point point to calculate the dot product with\r\n * @returns the dot product (float) of the point coordinates and the plane normal.\r\n */\r\n public dotCoordinate(point: DeepImmutable<Vector3>): number {\r\n return this.normal.x * point.x + this.normal.y * point.y + this.normal.z * point.z + this.d;\r\n }\r\n\r\n /**\r\n * Updates the current Plane from the plane defined by the three given points.\r\n * @param point1 one of the points used to construct the plane\r\n * @param point2 one of the points used to construct the plane\r\n * @param point3 one of the points used to construct the plane\r\n * @returns the updated Plane.\r\n */\r\n public copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane {\r\n const x1 = point2.x - point1.x;\r\n const y1 = point2.y - point1.y;\r\n const z1 = point2.z - point1.z;\r\n const x2 = point3.x - point1.x;\r\n const y2 = point3.y - point1.y;\r\n const z2 = point3.z - point1.z;\r\n const yz = y1 * z2 - z1 * y2;\r\n const xz = z1 * x2 - x1 * z2;\r\n const xy = x1 * y2 - y1 * x2;\r\n const pyth = Math.sqrt(yz * yz + xz * xz + xy * xy);\r\n let invPyth;\r\n\r\n if (pyth !== 0) {\r\n invPyth = 1.0 / pyth;\r\n } else {\r\n invPyth = 0.0;\r\n }\r\n\r\n this.normal.x = yz * invPyth;\r\n this.normal.y = xz * invPyth;\r\n this.normal.z = xy * invPyth;\r\n this.d = -(this.normal.x * point1.x + this.normal.y * point1.y + this.normal.z * point1.z);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).\r\n * Note that for this function to work as expected you should make sure that:\r\n * - direction and the plane normal are normalized\r\n * - epsilon is a number just bigger than -1, something like -0.99 for eg\r\n * @param direction the direction to check if the plane is facing\r\n * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)\r\n * @returns True if the plane is facing the given direction\r\n */\r\n public isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean {\r\n const dot = Vector3.Dot(this.normal, direction);\r\n return dot <= epsilon;\r\n }\r\n\r\n /**\r\n * Calculates the distance to a point\r\n * @param point point to calculate distance to\r\n * @returns the signed distance (float) from the given point to the Plane.\r\n */\r\n public signedDistanceTo(point: DeepImmutable<Vector3>): number {\r\n return Vector3.Dot(point, this.normal) + this.d;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates a plane from an array\r\n * @param array the array to create a plane from\r\n * @returns a new Plane from the given array.\r\n */\r\n static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane {\r\n return new Plane(array[0], array[1], array[2], array[3]);\r\n }\r\n /**\r\n * Creates a plane from three points\r\n * @param point1 point used to create the plane\r\n * @param point2 point used to create the plane\r\n * @param point3 point used to create the plane\r\n * @returns a new Plane defined by the three given points.\r\n */\r\n static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane {\r\n const result = new Plane(0.0, 0.0, 0.0, 0.0);\r\n result.copyFromPoints(point1, point2, point3);\r\n return result;\r\n }\r\n /**\r\n * Creates a plane from an origin point and a normal\r\n * @param origin origin of the plane to be constructed\r\n * @param normal normal of the plane to be constructed\r\n * @returns a new Plane the normal vector to this plane at the given origin point.\r\n */\r\n static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane {\r\n const plane = new Plane(0.0, 0.0, 0.0, 0.0);\r\n return this.FromPositionAndNormalToRef(origin, normal, plane);\r\n }\r\n\r\n /**\r\n * Updates the given Plane \"result\" from an origin point and a normal.\r\n * @param origin origin of the plane to be constructed\r\n * @param normal the normalized normals of the plane to be constructed\r\n * @param result defines the Plane where to store the result\r\n * @returns result input\r\n */\r\n static FromPositionAndNormalToRef<T extends Plane>(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, result: T): T {\r\n result.normal.copyFrom(normal);\r\n result.normal.normalize();\r\n result.d = -origin.dot(result.normal);\r\n return result;\r\n }\r\n\r\n /**\r\n * Calculates the distance from a plane and a point\r\n * @param origin origin of the plane to be constructed\r\n * @param normal normal of the plane to be constructed\r\n * @param point point to calculate distance to\r\n * @returns the signed distance between the plane defined by the normal vector at the \"origin\"\" point and the given other point.\r\n */\r\n static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number {\r\n const d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);\r\n return Vector3.Dot(point, normal) + d;\r\n }\r\n}\r\n"]}
@@ -393,7 +393,7 @@ export declare class Spherical {
393
393
  * @param ref the Vector3 to update
394
394
  * @returns the updated Vector3
395
395
  */
396
- toVector3ToRef(ref: DeepImmutable<Vector3>): Vector3;
396
+ toVector3ToRef(ref: Vector3): Vector3;
397
397
  /**
398
398
  * Gets a Vector3 from the current spherical coordinates
399
399
  * @returns the (x, y,z) form of the current Spherical
@@ -1 +1 @@
1
- {"version":3,"file":"math.polar.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.polar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,KAAK;IACd;;;;OAIG;IACH,YACW,MAAc,EACd,KAAa;QADb,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAQ;QAEpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,OAAO,C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BAAgB,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 /**\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(\r\n public radius: number,\r\n public theta: number\r\n ) {\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 * @returns 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 /**\r\n * Creates a new Spherical object from the given spherical coordinates\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(\r\n public radius: number,\r\n public theta: number,\r\n public phi: number\r\n ) {\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 * @returns 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"]}
1
+ {"version":3,"file":"math.polar.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.polar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,KAAK;IACd;;;;OAIG;IACH,YACW,MAAc,EACd,KAAa;QADb,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAQ;QAEpB,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,O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AI,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 /**\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(\r\n public radius: number,\r\n public theta: number\r\n ) {\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 * @returns 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 /**\r\n * Creates a new Spherical object from the given spherical coordinates\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(\r\n public radius: number,\r\n public theta: number,\r\n public phi: number\r\n ) {\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 * @returns 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: 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"]}
@@ -13,13 +13,13 @@ export declare class Scalar {
13
13
  * @param epsilon (default = 1.401298E-45)
14
14
  * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
15
15
  */
16
- static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
16
+ static WithinEpsilon: (a: number, b: number, epsilon?: number) => boolean;
17
17
  /**
18
18
  * Returns a string : the upper case translation of the number i to hexadecimal.
19
19
  * @param i number
20
20
  * @returns the upper case translation of the number i to hexadecimal.
21
21
  */
22
- static ToHex(i: number): string;
22
+ static ToHex: (i: number) => string;
23
23
  /**
24
24
  * Returns -1 if value is negative and +1 is value is positive.
25
25
  * @param value the value
@@ -35,7 +35,7 @@ export declare class Scalar {
35
35
  * @param max the max value to clamp to (default: 1)
36
36
  * @returns the clamped value
37
37
  */
38
- static Clamp(value: number, min?: number, max?: number): number;
38
+ static Clamp: (value: number, min?: number, max?: number) => number;
39
39
  /**
40
40
  * the log2 of value.
41
41
  * @param value the value to compute log2 of
@@ -130,7 +130,7 @@ export declare class Scalar {
130
130
  * @param amount amount to lerp between
131
131
  * @returns the lerped value
132
132
  */
133
- static Lerp(start: number, end: number, amount: number): number;
133
+ static Lerp: (start: number, end: number, amount: number) => number;
134
134
  /**
135
135
  * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
136
136
  * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
@@ -175,7 +175,7 @@ export declare class Scalar {
175
175
  * @param max max value of random
176
176
  * @returns random value
177
177
  */
178
- static RandomRange(min: number, max: number): number;
178
+ static RandomRange: (min: number, max: number) => number;
179
179
  /**
180
180
  * This function returns percentage of a number in a given range.
181
181
  *
@@ -202,7 +202,7 @@ export declare class Scalar {
202
202
  * @param angle The angle to normalize in radian.
203
203
  * @returns The converted angle.
204
204
  */
205
- static NormalizeRadians(angle: number): number;
205
+ static NormalizeRadians: (angle: number) => number;
206
206
  /**
207
207
  * Returns the highest common factor of two integers.
208
208
  * @param a first parameter
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Extract int value
3
+ * @param value number value
4
+ * @returns int value
5
+ */
6
+ export declare function ExtractAsInt(value: number): number;
7
+ /**
8
+ * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
9
+ * @param a number
10
+ * @param b number
11
+ * @param epsilon (default = 1.401298E-45)
12
+ * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
13
+ */
14
+ export declare function WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
15
+ /**
16
+ * Returns a random float number between and min and max values
17
+ * @param min min value of random
18
+ * @param max max value of random
19
+ * @returns random value
20
+ */
21
+ export declare function RandomRange(min: number, max: number): number;
22
+ /**
23
+ * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
24
+ * @param start start value
25
+ * @param end target value
26
+ * @param amount amount to lerp between
27
+ * @returns the lerped value
28
+ */
29
+ export declare function Lerp(start: number, end: number, amount: number): number;
30
+ /**
31
+ * Returns the value itself if it's between min and max.
32
+ * Returns min if the value is lower than min.
33
+ * Returns max if the value is greater than max.
34
+ * @param value the value to clmap
35
+ * @param min the min value to clamp to (default: 0)
36
+ * @param max the max value to clamp to (default: 1)
37
+ * @returns the clamped value
38
+ */
39
+ export declare function Clamp(value: number, min?: number, max?: number): number;
40
+ /**
41
+ * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
42
+ * @param angle The angle to normalize in radian.
43
+ * @returns The converted angle.
44
+ */
45
+ export declare function NormalizeRadians(angle: number): number;
46
+ /**
47
+ * Returns a string : the upper case translation of the number i to hexadecimal.
48
+ * @param i number
49
+ * @returns the upper case translation of the number i to hexadecimal.
50
+ */
51
+ export declare function ToHex(i: number): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Extract int value
3
+ * @param value number value
4
+ * @returns int value
5
+ */
6
+ export function ExtractAsInt(value) {
7
+ return parseInt(value.toString().replace(/\W/g, ""));
8
+ }
9
+ /**
10
+ * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
11
+ * @param a number
12
+ * @param b number
13
+ * @param epsilon (default = 1.401298E-45)
14
+ * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
15
+ */
16
+ export function WithinEpsilon(a, b, epsilon = 1.401298e-45) {
17
+ return Math.abs(a - b) <= epsilon;
18
+ }
19
+ /**
20
+ * Returns a random float number between and min and max values
21
+ * @param min min value of random
22
+ * @param max max value of random
23
+ * @returns random value
24
+ */
25
+ export function RandomRange(min, max) {
26
+ if (min === max) {
27
+ return min;
28
+ }
29
+ return Math.random() * (max - min) + min;
30
+ }
31
+ /**
32
+ * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
33
+ * @param start start value
34
+ * @param end target value
35
+ * @param amount amount to lerp between
36
+ * @returns the lerped value
37
+ */
38
+ export function Lerp(start, end, amount) {
39
+ return start + (end - start) * amount;
40
+ }
41
+ /**
42
+ * Returns the value itself if it's between min and max.
43
+ * Returns min if the value is lower than min.
44
+ * Returns max if the value is greater than max.
45
+ * @param value the value to clmap
46
+ * @param min the min value to clamp to (default: 0)
47
+ * @param max the max value to clamp to (default: 1)
48
+ * @returns the clamped value
49
+ */
50
+ export function Clamp(value, min = 0, max = 1) {
51
+ return Math.min(max, Math.max(min, value));
52
+ }
53
+ /**
54
+ * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
55
+ * @param angle The angle to normalize in radian.
56
+ * @returns The converted angle.
57
+ */
58
+ export function NormalizeRadians(angle) {
59
+ // More precise but slower version kept for reference.
60
+ // angle = angle % Tools.TwoPi;
61
+ // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
62
+ //if (angle > Math.PI) {
63
+ // angle -= Tools.TwoPi;
64
+ //}
65
+ angle -= Math.PI * 2 * Math.floor((angle + Math.PI) / (Math.PI * 2));
66
+ return angle;
67
+ }
68
+ /**
69
+ * Returns a string : the upper case translation of the number i to hexadecimal.
70
+ * @param i number
71
+ * @returns the upper case translation of the number i to hexadecimal.
72
+ */
73
+ export function ToHex(i) {
74
+ const str = i.toString(16);
75
+ if (i <= 15) {
76
+ return ("0" + str).toUpperCase();
77
+ }
78
+ return str.toUpperCase();
79
+ }
80
+ //# sourceMappingURL=math.scalar.functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.scalar.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.scalar.functions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS,EAAE,CAAS,EAAE,UAAkB,YAAY;IAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW;IAChD,IAAI,GAAG,KAAK,GAAG,EAAE;QACb,OAAO,GAAG,CAAC;KACd;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,KAAa,EAAE,GAAW,EAAE,MAAc;IAC3D,OAAO,KAAK,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC1C,sDAAsD;IACtD,+BAA+B;IAC/B,+CAA+C;IAE/C,wBAAwB;IACxB,wBAAwB;IACxB,GAAG;IAEH,KAAK,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAErE,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,CAAS;IAC3B,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3B,IAAI,CAAC,IAAI,EAAE,EAAE;QACT,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;KACpC;IAED,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/**\r\n * Extract int value\r\n * @param value number value\r\n * @returns int value\r\n */\r\nexport function ExtractAsInt(value: number) {\r\n return parseInt(value.toString().replace(/\\W/g, \"\"));\r\n}\r\n\r\n/**\r\n * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n * @param a number\r\n * @param b number\r\n * @param epsilon (default = 1.401298E-45)\r\n * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)\r\n */\r\nexport function WithinEpsilon(a: number, b: number, epsilon: number = 1.401298e-45): boolean {\r\n return Math.abs(a - b) <= epsilon;\r\n}\r\n\r\n/**\r\n * Returns a random float number between and min and max values\r\n * @param min min value of random\r\n * @param max max value of random\r\n * @returns random value\r\n */\r\nexport function RandomRange(min: number, max: number): number {\r\n if (min === max) {\r\n return min;\r\n }\r\n return Math.random() * (max - min) + min;\r\n}\r\n\r\n/**\r\n * Creates a new scalar with values linearly interpolated of \"amount\" between the start scalar and the end scalar.\r\n * @param start start value\r\n * @param end target value\r\n * @param amount amount to lerp between\r\n * @returns the lerped value\r\n */\r\nexport function Lerp(start: number, end: number, amount: number): number {\r\n return start + (end - start) * amount;\r\n}\r\n\r\n/**\r\n * Returns the value itself if it's between min and max.\r\n * Returns min if the value is lower than min.\r\n * Returns max if the value is greater than max.\r\n * @param value the value to clmap\r\n * @param min the min value to clamp to (default: 0)\r\n * @param max the max value to clamp to (default: 1)\r\n * @returns the clamped value\r\n */\r\nexport function Clamp(value: number, min = 0, max = 1): number {\r\n return Math.min(max, Math.max(min, value));\r\n}\r\n\r\n/**\r\n * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.\r\n * @param angle The angle to normalize in radian.\r\n * @returns The converted angle.\r\n */\r\nexport function NormalizeRadians(angle: number): number {\r\n // More precise but slower version kept for reference.\r\n // angle = angle % Tools.TwoPi;\r\n // angle = (angle + Tools.TwoPi) % Tools.TwoPi;\r\n\r\n //if (angle > Math.PI) {\r\n //\tangle -= Tools.TwoPi;\r\n //}\r\n\r\n angle -= Math.PI * 2 * Math.floor((angle + Math.PI) / (Math.PI * 2));\r\n\r\n return angle;\r\n}\r\n\r\n/**\r\n * Returns a string : the upper case translation of the number i to hexadecimal.\r\n * @param i number\r\n * @returns the upper case translation of the number i to hexadecimal.\r\n */\r\nexport function ToHex(i: number): string {\r\n const str = i.toString(16);\r\n\r\n if (i <= 15) {\r\n return (\"0\" + str).toUpperCase();\r\n }\r\n\r\n return str.toUpperCase();\r\n}\r\n"]}
@@ -1,29 +1,8 @@
1
+ import { Clamp, Lerp, NormalizeRadians, RandomRange, ToHex, WithinEpsilon } from "./math.scalar.functions.js";
1
2
  /**
2
3
  * Scalar computation library
3
4
  */
4
5
  export class Scalar {
5
- /**
6
- * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
7
- * @param a number
8
- * @param b number
9
- * @param epsilon (default = 1.401298E-45)
10
- * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
11
- */
12
- static WithinEpsilon(a, b, epsilon = 1.401298e-45) {
13
- return Math.abs(a - b) <= epsilon;
14
- }
15
- /**
16
- * Returns a string : the upper case translation of the number i to hexadecimal.
17
- * @param i number
18
- * @returns the upper case translation of the number i to hexadecimal.
19
- */
20
- static ToHex(i) {
21
- const str = i.toString(16);
22
- if (i <= 15) {
23
- return ("0" + str).toUpperCase();
24
- }
25
- return str.toUpperCase();
26
- }
27
6
  /**
28
7
  * Returns -1 if value is negative and +1 is value is positive.
29
8
  * @param value the value
@@ -36,18 +15,6 @@ export class Scalar {
36
15
  }
37
16
  return value > 0 ? 1 : -1;
38
17
  }
39
- /**
40
- * Returns the value itself if it's between min and max.
41
- * Returns min if the value is lower than min.
42
- * Returns max if the value is greater than max.
43
- * @param value the value to clmap
44
- * @param min the min value to clamp to (default: 0)
45
- * @param max the max value to clamp to (default: 1)
46
- * @returns the clamped value
47
- */
48
- static Clamp(value, min = 0, max = 1) {
49
- return Math.min(max, Math.max(min, value));
50
- }
51
18
  /**
52
19
  * the log2 of value.
53
20
  * @param value the value to compute log2 of
@@ -201,16 +168,6 @@ export class Scalar {
201
168
  }
202
169
  return result;
203
170
  }
204
- /**
205
- * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
206
- * @param start start value
207
- * @param end target value
208
- * @param amount amount to lerp between
209
- * @returns the lerped value
210
- */
211
- static Lerp(start, end, amount) {
212
- return start + (end - start) * amount;
213
- }
214
171
  /**
215
172
  * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
216
173
  * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
@@ -224,7 +181,7 @@ export class Scalar {
224
181
  if (num > 180.0) {
225
182
  num -= 360.0;
226
183
  }
227
- return start + num * Scalar.Clamp(amount);
184
+ return start + num * Clamp(amount);
228
185
  }
229
186
  /**
230
187
  * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
@@ -236,7 +193,7 @@ export class Scalar {
236
193
  static InverseLerp(a, b, value) {
237
194
  let result = 0;
238
195
  if (a != b) {
239
- result = Scalar.Clamp((value - a) / (b - a));
196
+ result = Clamp((value - a) / (b - a));
240
197
  }
241
198
  else {
242
199
  result = 0.0;
@@ -275,18 +232,6 @@ export class Scalar {
275
232
  const t2 = time * time;
276
233
  return (t2 - time) * 6 * value1 + (3 * t2 - 4 * time + 1) * tangent1 + (-t2 + time) * 6 * value2 + (3 * t2 - 2 * time) * tangent2;
277
234
  }
278
- /**
279
- * Returns a random float number between and min and max values
280
- * @param min min value of random
281
- * @param max max value of random
282
- * @returns random value
283
- */
284
- static RandomRange(min, max) {
285
- if (min === max) {
286
- return min;
287
- }
288
- return Math.random() * (max - min) + min;
289
- }
290
235
  /**
291
236
  * This function returns percentage of a number in a given range.
292
237
  *
@@ -312,21 +257,6 @@ export class Scalar {
312
257
  static PercentToRange(percent, min, max) {
313
258
  return (max - min) * percent + min;
314
259
  }
315
- /**
316
- * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
317
- * @param angle The angle to normalize in radian.
318
- * @returns The converted angle.
319
- */
320
- static NormalizeRadians(angle) {
321
- // More precise but slower version kept for reference.
322
- // angle = angle % Tools.TwoPi;
323
- // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
324
- //if (angle > Math.PI) {
325
- // angle -= Tools.TwoPi;
326
- //}
327
- angle -= Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi);
328
- return angle;
329
- }
330
260
  /**
331
261
  * Returns the highest common factor of two integers.
332
262
  * @param a first parameter
@@ -345,4 +275,49 @@ export class Scalar {
345
275
  * Two pi constants convenient for computation.
346
276
  */
347
277
  Scalar.TwoPi = Math.PI * 2;
278
+ /**
279
+ * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
280
+ * @param a number
281
+ * @param b number
282
+ * @param epsilon (default = 1.401298E-45)
283
+ * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
284
+ */
285
+ Scalar.WithinEpsilon = WithinEpsilon;
286
+ /**
287
+ * Returns a string : the upper case translation of the number i to hexadecimal.
288
+ * @param i number
289
+ * @returns the upper case translation of the number i to hexadecimal.
290
+ */
291
+ Scalar.ToHex = ToHex;
292
+ /**
293
+ * Returns the value itself if it's between min and max.
294
+ * Returns min if the value is lower than min.
295
+ * Returns max if the value is greater than max.
296
+ * @param value the value to clmap
297
+ * @param min the min value to clamp to (default: 0)
298
+ * @param max the max value to clamp to (default: 1)
299
+ * @returns the clamped value
300
+ */
301
+ Scalar.Clamp = Clamp;
302
+ /**
303
+ * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
304
+ * @param start start value
305
+ * @param end target value
306
+ * @param amount amount to lerp between
307
+ * @returns the lerped value
308
+ */
309
+ Scalar.Lerp = Lerp;
310
+ /**
311
+ * Returns a random float number between and min and max values
312
+ * @param min min value of random
313
+ * @param max max value of random
314
+ * @returns random value
315
+ */
316
+ Scalar.RandomRange = RandomRange;
317
+ /**
318
+ * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
319
+ * @param angle The angle to normalize in radian.
320
+ * @returns The converted angle.
321
+ */
322
+ Scalar.NormalizeRadians = NormalizeRadians;
348
323
  //# sourceMappingURL=math.scalar.js.map