@babylonjs/core 7.23.1 → 7.25.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.
- package/Animations/animation.js +3 -3
- package/Animations/animation.js.map +1 -1
- package/Audio/sound.js +15 -7
- package/Audio/sound.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +3 -3
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +2 -2
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Compute/computeEffect.js +4 -4
- package/Compute/computeEffect.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js +2 -3
- package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
- package/Engines/Processors/Expressions/shaderDefineExpression.js +1 -1
- package/Engines/Processors/Expressions/shaderDefineExpression.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +2 -2
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -2
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +12 -10
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +2 -2
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/nativeEngine.js +3 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +2 -2
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Loading/sceneLoader.js +3 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +17 -8
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +1 -2
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.d.ts +0 -2
- package/Materials/Textures/Filtering/hdrFiltering.js +12 -4
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Loaders/textureLoaderManager.d.ts +14 -1
- package/Materials/Textures/Loaders/textureLoaderManager.js +50 -21
- package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +15 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +24 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/index.d.ts +6 -0
- package/Materials/Textures/index.js +8 -0
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/Textures/texture.js +2 -2
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/effect.functions.js +4 -4
- package/Materials/effect.functions.js.map +1 -1
- package/Maths/math.color.js +6 -7
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.path.js +5 -5
- package/Maths/math.path.js.map +1 -1
- package/Maths/math.scalar.d.ts +33 -191
- package/Maths/math.scalar.functions.d.ts +147 -0
- package/Maths/math.scalar.functions.js +247 -0
- package/Maths/math.scalar.functions.js.map +1 -1
- package/Maths/math.scalar.js +15 -303
- package/Maths/math.scalar.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +3 -3
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +8 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +30 -13
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js +2 -2
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +4 -4
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/noiseBlock.js +3 -3
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
- package/Meshes/geodesicMesh.js +3 -3
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/trailMesh.js +4 -4
- package/Meshes/trailMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +7 -7
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +2 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/basis.js +2 -3
- package/Misc/basis.js.map +1 -1
- package/Misc/dds.js +9 -9
- package/Misc/dds.js.map +1 -1
- package/Misc/dumpTools.js +2 -2
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/environmentTextureTools.js +4 -4
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/reflector.js +3 -3
- package/Misc/reflector.js.map +1 -1
- package/Misc/screenshotTools.d.ts +2 -1
- package/Misc/screenshotTools.js +3 -2
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/tools.d.ts +6 -3
- package/Misc/tools.js +5 -3
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +10 -10
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.js +9 -9
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js +7 -7
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js +4 -4
- package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/pointParticleEmitter.js +4 -4
- package/Particles/EmitterTypes/pointParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +10 -10
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/gpuParticleSystem.js +2 -2
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/pointsCloudSystem.js +8 -8
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Physics/v1/Plugins/ammoJSPlugin.js +2 -2
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.js +2 -2
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +4 -4
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +4 -0
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +6 -0
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +4 -0
- package/PostProcesses/postProcess.js +1 -0
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +0 -2
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +46 -3
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.d.ts +0 -5
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js +33 -5
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +8 -3
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +56 -18
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +0 -2
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +20 -2
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +2 -14
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +108 -36
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +0 -2
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +23 -11
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +7 -3
- package/Rendering/depthPeelingRenderer.js +38 -3
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/index.d.ts +44 -0
- package/Rendering/index.js +46 -0
- package/Rendering/index.js.map +1 -1
- package/Shaders/iblCombineVoxelGrids.fragment.d.ts +5 -0
- package/Shaders/{combineVoxelGrids.fragment.js → iblCombineVoxelGrids.fragment.js} +3 -3
- package/Shaders/iblCombineVoxelGrids.fragment.js.map +1 -0
- package/Shaders/iblGenerateVoxelMip.fragment.d.ts +5 -0
- package/Shaders/{generateVoxelMip.fragment.js → iblGenerateVoxelMip.fragment.js} +3 -3
- package/Shaders/iblGenerateVoxelMip.fragment.js.map +1 -0
- package/Shaders/iblShadowVoxelTracing.fragment.js +18 -10
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js +2 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js.map +1 -1
- package/Shaders/{voxelGrid.fragment.d.ts → iblVoxelGrid.fragment.d.ts} +1 -1
- package/Shaders/{voxelGrid.fragment.js → iblVoxelGrid.fragment.js} +3 -3
- package/Shaders/iblVoxelGrid.fragment.js.map +1 -0
- package/Shaders/{voxelSlabDebug.fragment.d.ts → iblVoxelGrid.vertex.d.ts} +1 -1
- package/Shaders/{voxelGrid.vertex.js → iblVoxelGrid.vertex.js} +8 -4
- package/Shaders/iblVoxelGrid.vertex.js.map +1 -0
- package/Shaders/iblVoxelGrid2dArrayDebug.fragment.d.ts +5 -0
- package/Shaders/{voxelGrid2dArrayDebug.fragment.js → iblVoxelGrid2dArrayDebug.fragment.js} +3 -3
- package/Shaders/iblVoxelGrid2dArrayDebug.fragment.js.map +1 -0
- package/Shaders/iblVoxelGrid3dDebug.fragment.d.ts +5 -0
- package/Shaders/{voxelGrid3dDebug.fragment.js → iblVoxelGrid3dDebug.fragment.js} +3 -3
- package/Shaders/iblVoxelGrid3dDebug.fragment.js.map +1 -0
- package/Shaders/{combineVoxelGrids.fragment.d.ts → iblVoxelSlabDebug.fragment.d.ts} +1 -1
- package/Shaders/{voxelSlabDebug.fragment.js → iblVoxelSlabDebug.fragment.js} +3 -3
- package/Shaders/iblVoxelSlabDebug.fragment.js.map +1 -0
- package/Shaders/iblVoxelSlabDebug.vertex.d.ts +5 -0
- package/Shaders/{voxelSlabDebug.vertex.js → iblVoxelSlabDebug.vertex.js} +3 -3
- package/Shaders/iblVoxelSlabDebug.vertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +7 -7
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/copyTexture3DLayerToTexture.fragment.d.ts +5 -0
- package/ShadersWGSL/copyTexture3DLayerToTexture.fragment.js +10 -0
- package/ShadersWGSL/copyTexture3DLayerToTexture.fragment.js.map +1 -0
- package/ShadersWGSL/default.fragment.js +4 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/hdrFiltering.fragment.d.ts +9 -0
- package/ShadersWGSL/hdrFiltering.fragment.js +18 -0
- package/ShadersWGSL/hdrFiltering.fragment.js.map +1 -0
- package/ShadersWGSL/hdrFiltering.vertex.d.ts +5 -0
- package/ShadersWGSL/hdrFiltering.vertex.js +16 -0
- package/ShadersWGSL/hdrFiltering.vertex.js.map +1 -0
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.d.ts +5 -0
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.js +10 -0
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.js.map +1 -0
- package/ShadersWGSL/iblGenerateVoxelMip.fragment.d.ts +5 -0
- package/ShadersWGSL/iblGenerateVoxelMip.fragment.js +26 -0
- package/ShadersWGSL/iblGenerateVoxelMip.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowAccumulation.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowAccumulation.fragment.js +24 -0
- package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowDebug.fragment.js +16 -0
- package/ShadersWGSL/iblShadowDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.js +17 -0
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js +20 -0
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +163 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsCdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsCdfx.fragment.js +12 -0
- package/ShadersWGSL/iblShadowsCdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsCdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsCdfy.fragment.js +33 -0
- package/ShadersWGSL/iblShadowsCdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsCombine.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsCombine.fragment.js +10 -0
- package/ShadersWGSL/iblShadowsCombine.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsIcdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js +18 -0
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsIcdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js +17 -0
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js +41 -0
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js.map +1 -0
- package/{Shaders/voxelGrid3dDebug.fragment.d.ts → ShadersWGSL/iblVoxelGrid.fragment.d.ts} +1 -1
- package/ShadersWGSL/iblVoxelGrid.fragment.js +15 -0
- package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +5 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.js +14 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -0
- package/ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.js +10 -0
- package/ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js +22 -0
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.js +12 -0
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.d.ts +5 -0
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js +10 -0
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js.map +1 -0
- package/{Shaders/generateVoxelMip.fragment.d.ts → ShadersWGSL/oitBackBlend.fragment.d.ts} +1 -1
- package/ShadersWGSL/oitBackBlend.fragment.js +11 -0
- package/ShadersWGSL/oitBackBlend.fragment.js.map +1 -0
- package/{Shaders/voxelGrid.vertex.d.ts → ShadersWGSL/oitFinal.fragment.d.ts} +1 -1
- package/ShadersWGSL/oitFinal.fragment.js +14 -0
- package/ShadersWGSL/oitFinal.fragment.js.map +1 -0
- package/ShadersWGSL/pbr.fragment.js +17 -8
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/{Shaders/voxelSlabDebug.vertex.d.ts → ShadersWGSL/procedural.vertex.d.ts} +1 -1
- package/ShadersWGSL/procedural.vertex.js +16 -0
- package/ShadersWGSL/procedural.vertex.js.map +1 -0
- package/XR/features/WebXRHandTracking.d.ts +5 -0
- package/XR/features/WebXRHandTracking.js +34 -12
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +2 -2
- package/Shaders/combineVoxelGrids.fragment.js.map +0 -1
- package/Shaders/generateVoxelMip.fragment.js.map +0 -1
- package/Shaders/voxelGrid.fragment.js.map +0 -1
- package/Shaders/voxelGrid.vertex.js.map +0 -1
- package/Shaders/voxelGrid2dArrayDebug.fragment.d.ts +0 -5
- package/Shaders/voxelGrid2dArrayDebug.fragment.js.map +0 -1
- package/Shaders/voxelGrid3dDebug.fragment.js.map +0 -1
- package/Shaders/voxelSlabDebug.fragment.js.map +0 -1
- package/Shaders/voxelSlabDebug.vertex.js.map +0 -1
package/Maths/math.scalar.d.ts
CHANGED
|
@@ -1,213 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scalar computation library
|
|
3
|
+
* @deprecated Please use the scalar functions
|
|
3
4
|
*/
|
|
4
|
-
export declare
|
|
5
|
+
export declare const Scalar: {
|
|
5
6
|
/**
|
|
6
7
|
* Two pi constants convenient for computation.
|
|
7
8
|
*/
|
|
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
|
-
static WithinEpsilon: (a: number, b: number, epsilon?: number) => boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Returns a string : the upper case translation of the number i to hexadecimal.
|
|
19
|
-
* @param i number
|
|
20
|
-
* @returns the upper case translation of the number i to hexadecimal.
|
|
21
|
-
*/
|
|
22
|
-
static ToHex: (i: number) => string;
|
|
9
|
+
TwoPi: number;
|
|
23
10
|
/**
|
|
24
11
|
* Returns -1 if value is negative and +1 is value is positive.
|
|
25
12
|
* @param value the value
|
|
26
13
|
* @returns the value itself if it's equal to zero.
|
|
27
14
|
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns the value itself if it's between min and max.
|
|
31
|
-
* Returns min if the value is lower than min.
|
|
32
|
-
* Returns max if the value is greater than max.
|
|
33
|
-
* @param value the value to clmap
|
|
34
|
-
* @param min the min value to clamp to (default: 0)
|
|
35
|
-
* @param max the max value to clamp to (default: 1)
|
|
36
|
-
* @returns the clamped value
|
|
37
|
-
*/
|
|
38
|
-
static Clamp: (value: number, min?: number, max?: number) => number;
|
|
15
|
+
Sign: (x: number) => number;
|
|
39
16
|
/**
|
|
40
17
|
* the log2 of value.
|
|
41
18
|
* @param value the value to compute log2 of
|
|
42
19
|
* @returns the log2 of value.
|
|
43
20
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @returns the log2 of value.
|
|
49
|
-
*/
|
|
50
|
-
static ILog2(value: number): number;
|
|
51
|
-
/**
|
|
52
|
-
* Loops the value, so that it is never larger than length and never smaller than 0.
|
|
53
|
-
*
|
|
54
|
-
* This is similar to the modulo operator but it works with floating point numbers.
|
|
55
|
-
* For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
|
|
56
|
-
* With t = 5 and length = 2.5, the result would be 0.0.
|
|
57
|
-
* Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
|
|
58
|
-
* @param value the value
|
|
59
|
-
* @param length the length
|
|
60
|
-
* @returns the looped value
|
|
61
|
-
*/
|
|
62
|
-
static Repeat(value: number, length: number): number;
|
|
63
|
-
/**
|
|
64
|
-
* Normalize the value between 0.0 and 1.0 using min and max values
|
|
65
|
-
* @param value value to normalize
|
|
66
|
-
* @param min max to normalize between
|
|
67
|
-
* @param max min to normalize between
|
|
68
|
-
* @returns the normalized value
|
|
69
|
-
*/
|
|
70
|
-
static Normalize(value: number, min: number, max: number): number;
|
|
71
|
-
/**
|
|
72
|
-
* Denormalize the value from 0.0 and 1.0 using min and max values
|
|
73
|
-
* @param normalized value to denormalize
|
|
74
|
-
* @param min max to denormalize between
|
|
75
|
-
* @param max min to denormalize between
|
|
76
|
-
* @returns the denormalized value
|
|
77
|
-
*/
|
|
78
|
-
static Denormalize(normalized: number, min: number, max: number): number;
|
|
79
|
-
/**
|
|
80
|
-
* Calculates the shortest difference between two given angles given in degrees.
|
|
81
|
-
* @param current current angle in degrees
|
|
82
|
-
* @param target target angle in degrees
|
|
83
|
-
* @returns the delta
|
|
84
|
-
*/
|
|
85
|
-
static DeltaAngle(current: number, target: number): number;
|
|
86
|
-
/**
|
|
87
|
-
* PingPongs the value t, so that it is never larger than length and never smaller than 0.
|
|
88
|
-
* @param tx value
|
|
89
|
-
* @param length length
|
|
90
|
-
* @returns The returned value will move back and forth between 0 and length
|
|
91
|
-
*/
|
|
92
|
-
static PingPong(tx: number, length: number): number;
|
|
93
|
-
/**
|
|
94
|
-
* Interpolates between min and max with smoothing at the limits.
|
|
95
|
-
*
|
|
96
|
-
* This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
|
|
97
|
-
* from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
|
|
98
|
-
* @param from from
|
|
99
|
-
* @param to to
|
|
100
|
-
* @param tx value
|
|
101
|
-
* @returns the smooth stepped value
|
|
102
|
-
*/
|
|
103
|
-
static SmoothStep(from: number, to: number, tx: number): number;
|
|
104
|
-
/**
|
|
105
|
-
* Moves a value current towards target.
|
|
106
|
-
*
|
|
107
|
-
* This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
|
|
108
|
-
* Negative values of maxDelta pushes the value away from target.
|
|
109
|
-
* @param current current value
|
|
110
|
-
* @param target target value
|
|
111
|
-
* @param maxDelta max distance to move
|
|
112
|
-
* @returns resulting value
|
|
113
|
-
*/
|
|
114
|
-
static MoveTowards(current: number, target: number, maxDelta: number): number;
|
|
115
|
-
/**
|
|
116
|
-
* Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
|
|
117
|
-
*
|
|
118
|
-
* Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
|
|
119
|
-
* are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
|
|
120
|
-
* @param current current value
|
|
121
|
-
* @param target target value
|
|
122
|
-
* @param maxDelta max distance to move
|
|
123
|
-
* @returns resulting angle
|
|
124
|
-
*/
|
|
125
|
-
static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
|
|
126
|
-
/**
|
|
127
|
-
* Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
|
|
128
|
-
* @param start start value
|
|
129
|
-
* @param end target value
|
|
130
|
-
* @param amount amount to lerp between
|
|
131
|
-
* @returns the lerped value
|
|
132
|
-
*/
|
|
133
|
-
static Lerp: (start: number, end: number, amount: number) => number;
|
|
134
|
-
/**
|
|
135
|
-
* Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
|
|
136
|
-
* The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
|
|
137
|
-
* @param start start value
|
|
138
|
-
* @param end target value
|
|
139
|
-
* @param amount amount to lerp between
|
|
140
|
-
* @returns the lerped value
|
|
141
|
-
*/
|
|
142
|
-
static LerpAngle(start: number, end: number, amount: number): number;
|
|
143
|
-
/**
|
|
144
|
-
* Calculates the linear parameter t that produces the interpolant value within the range [a, b].
|
|
145
|
-
* @param a start value
|
|
146
|
-
* @param b target value
|
|
147
|
-
* @param value value between a and b
|
|
148
|
-
* @returns the inverseLerp value
|
|
149
|
-
*/
|
|
150
|
-
static InverseLerp(a: number, b: number, value: number): number;
|
|
151
|
-
/**
|
|
152
|
-
* Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
|
|
153
|
-
* @see http://mathworld.wolfram.com/HermitePolynomial.html
|
|
154
|
-
* @param value1 defines the first control point
|
|
155
|
-
* @param tangent1 defines the first tangent
|
|
156
|
-
* @param value2 defines the second control point
|
|
157
|
-
* @param tangent2 defines the second tangent
|
|
158
|
-
* @param amount defines the amount on the interpolation spline (between 0 and 1)
|
|
159
|
-
* @returns hermite result
|
|
160
|
-
*/
|
|
161
|
-
static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
|
|
162
|
-
/**
|
|
163
|
-
* Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars "value1", "value2", "tangent1", "tangent2".
|
|
164
|
-
* @param value1 defines the first control point
|
|
165
|
-
* @param tangent1 defines the first tangent
|
|
166
|
-
* @param value2 defines the second control point
|
|
167
|
-
* @param tangent2 defines the second tangent
|
|
168
|
-
* @param time define where the derivative must be done
|
|
169
|
-
* @returns 1st derivative
|
|
170
|
-
*/
|
|
171
|
-
static Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number;
|
|
172
|
-
/**
|
|
173
|
-
* Returns a random float number between and min and max values
|
|
174
|
-
* @param min min value of random
|
|
175
|
-
* @param max max value of random
|
|
176
|
-
* @returns random value
|
|
177
|
-
*/
|
|
178
|
-
static RandomRange: (min: number, max: number) => number;
|
|
179
|
-
/**
|
|
180
|
-
* This function returns percentage of a number in a given range.
|
|
181
|
-
*
|
|
182
|
-
* RangeToPercent(40,20,60) will return 0.5 (50%)
|
|
183
|
-
* RangeToPercent(34,0,100) will return 0.34 (34%)
|
|
184
|
-
* @param number to convert to percentage
|
|
185
|
-
* @param min min range
|
|
186
|
-
* @param max max range
|
|
187
|
-
* @returns the percentage
|
|
188
|
-
*/
|
|
189
|
-
static RangeToPercent(number: number, min: number, max: number): number;
|
|
190
|
-
/**
|
|
191
|
-
* This function returns number that corresponds to the percentage in a given range.
|
|
192
|
-
*
|
|
193
|
-
* PercentToRange(0.34,0,100) will return 34.
|
|
194
|
-
* @param percent to convert to number
|
|
195
|
-
* @param min min range
|
|
196
|
-
* @param max max range
|
|
197
|
-
* @returns the number
|
|
198
|
-
*/
|
|
199
|
-
static PercentToRange(percent: number, min: number, max: number): number;
|
|
200
|
-
/**
|
|
201
|
-
* Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
|
|
202
|
-
* @param angle The angle to normalize in radian.
|
|
203
|
-
* @returns The converted angle.
|
|
204
|
-
*/
|
|
205
|
-
static NormalizeRadians: (angle: number) => number;
|
|
21
|
+
Log2: {
|
|
22
|
+
(x: number): number;
|
|
23
|
+
(x: number): number;
|
|
24
|
+
};
|
|
206
25
|
/**
|
|
207
26
|
* Returns the highest common factor of two integers.
|
|
208
27
|
* @param a first parameter
|
|
209
28
|
* @param b second parameter
|
|
210
29
|
* @returns HCF of a and b
|
|
211
30
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
31
|
+
HCF: (a: number, b: number) => number;
|
|
32
|
+
ExtractAsInt(value: number): number;
|
|
33
|
+
WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
|
|
34
|
+
RandomRange(min: number, max: number): number;
|
|
35
|
+
Lerp(start: number, end: number, amount: number): number;
|
|
36
|
+
LerpAngle(start: number, end: number, amount: number): number;
|
|
37
|
+
InverseLerp(a: number, b: number, value: number): number;
|
|
38
|
+
Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
|
|
39
|
+
Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number;
|
|
40
|
+
Clamp(value: number, min?: number, max?: number): number;
|
|
41
|
+
NormalizeRadians(angle: number): number;
|
|
42
|
+
ToHex(i: number): string;
|
|
43
|
+
ILog2(value: number): number;
|
|
44
|
+
Repeat(value: number, length: number): number;
|
|
45
|
+
Normalize(value: number, min: number, max: number): number;
|
|
46
|
+
Denormalize(normalized: number, min: number, max: number): number;
|
|
47
|
+
DeltaAngle(current: number, target: number): number;
|
|
48
|
+
PingPong(tx: number, length: number): number;
|
|
49
|
+
SmoothStep(from: number, to: number, tx: number): number;
|
|
50
|
+
MoveTowards(current: number, target: number, maxDelta: number): number;
|
|
51
|
+
MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
|
|
52
|
+
RangeToPercent(number: number, min: number, max: number): number;
|
|
53
|
+
PercentToRange(percent: number, min: number, max: number): number;
|
|
54
|
+
HighestCommonFactor(a: number, b: number): number;
|
|
55
|
+
};
|
|
@@ -27,6 +27,44 @@ export declare function RandomRange(min: number, max: number): number;
|
|
|
27
27
|
* @returns the lerped value
|
|
28
28
|
*/
|
|
29
29
|
export declare function Lerp(start: number, end: number, amount: number): number;
|
|
30
|
+
/**
|
|
31
|
+
* Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
|
|
32
|
+
* The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
|
|
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 declare function LerpAngle(start: number, end: number, amount: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Calculates the linear parameter t that produces the interpolant value within the range [a, b].
|
|
41
|
+
* @param a start value
|
|
42
|
+
* @param b target value
|
|
43
|
+
* @param value value between a and b
|
|
44
|
+
* @returns the inverseLerp value
|
|
45
|
+
*/
|
|
46
|
+
export declare function InverseLerp(a: number, b: number, value: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
|
|
49
|
+
* @see http://mathworld.wolfram.com/HermitePolynomial.html
|
|
50
|
+
* @param value1 defines the first control point
|
|
51
|
+
* @param tangent1 defines the first tangent
|
|
52
|
+
* @param value2 defines the second control point
|
|
53
|
+
* @param tangent2 defines the second tangent
|
|
54
|
+
* @param amount defines the amount on the interpolation spline (between 0 and 1)
|
|
55
|
+
* @returns hermite result
|
|
56
|
+
*/
|
|
57
|
+
export declare function Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars "value1", "value2", "tangent1", "tangent2".
|
|
60
|
+
* @param value1 defines the first control point
|
|
61
|
+
* @param tangent1 defines the first tangent
|
|
62
|
+
* @param value2 defines the second control point
|
|
63
|
+
* @param tangent2 defines the second tangent
|
|
64
|
+
* @param time define where the derivative must be done
|
|
65
|
+
* @returns 1st derivative
|
|
66
|
+
*/
|
|
67
|
+
export declare function Hermite1stDerivative(value1: number, tangent1: number, value2: number, tangent2: number, time: number): number;
|
|
30
68
|
/**
|
|
31
69
|
* Returns the value itself if it's between min and max.
|
|
32
70
|
* Returns min if the value is lower than min.
|
|
@@ -49,3 +87,112 @@ export declare function NormalizeRadians(angle: number): number;
|
|
|
49
87
|
* @returns the upper case translation of the number i to hexadecimal.
|
|
50
88
|
*/
|
|
51
89
|
export declare function ToHex(i: number): string;
|
|
90
|
+
/**
|
|
91
|
+
* the floor part of a log2 value.
|
|
92
|
+
* @param value the value to compute log2 of
|
|
93
|
+
* @returns the log2 of value.
|
|
94
|
+
*/
|
|
95
|
+
export declare function ILog2(value: number): number;
|
|
96
|
+
/**
|
|
97
|
+
* Loops the value, so that it is never larger than length and never smaller than 0.
|
|
98
|
+
*
|
|
99
|
+
* This is similar to the modulo operator but it works with floating point numbers.
|
|
100
|
+
* For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
|
|
101
|
+
* With t = 5 and length = 2.5, the result would be 0.0.
|
|
102
|
+
* Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
|
|
103
|
+
* @param value the value
|
|
104
|
+
* @param length the length
|
|
105
|
+
* @returns the looped value
|
|
106
|
+
*/
|
|
107
|
+
export declare function Repeat(value: number, length: number): number;
|
|
108
|
+
/**
|
|
109
|
+
* Normalize the value between 0.0 and 1.0 using min and max values
|
|
110
|
+
* @param value value to normalize
|
|
111
|
+
* @param min max to normalize between
|
|
112
|
+
* @param max min to normalize between
|
|
113
|
+
* @returns the normalized value
|
|
114
|
+
*/
|
|
115
|
+
export declare function Normalize(value: number, min: number, max: number): number;
|
|
116
|
+
/**
|
|
117
|
+
* Denormalize the value from 0.0 and 1.0 using min and max values
|
|
118
|
+
* @param normalized value to denormalize
|
|
119
|
+
* @param min max to denormalize between
|
|
120
|
+
* @param max min to denormalize between
|
|
121
|
+
* @returns the denormalized value
|
|
122
|
+
*/
|
|
123
|
+
export declare function Denormalize(normalized: number, min: number, max: number): number;
|
|
124
|
+
/**
|
|
125
|
+
* Calculates the shortest difference between two given angles given in degrees.
|
|
126
|
+
* @param current current angle in degrees
|
|
127
|
+
* @param target target angle in degrees
|
|
128
|
+
* @returns the delta
|
|
129
|
+
*/
|
|
130
|
+
export declare function DeltaAngle(current: number, target: number): number;
|
|
131
|
+
/**
|
|
132
|
+
* PingPongs the value t, so that it is never larger than length and never smaller than 0.
|
|
133
|
+
* @param tx value
|
|
134
|
+
* @param length length
|
|
135
|
+
* @returns The returned value will move back and forth between 0 and length
|
|
136
|
+
*/
|
|
137
|
+
export declare function PingPong(tx: number, length: number): number;
|
|
138
|
+
/**
|
|
139
|
+
* Interpolates between min and max with smoothing at the limits.
|
|
140
|
+
*
|
|
141
|
+
* This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
|
|
142
|
+
* from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
|
|
143
|
+
* @param from from
|
|
144
|
+
* @param to to
|
|
145
|
+
* @param tx value
|
|
146
|
+
* @returns the smooth stepped value
|
|
147
|
+
*/
|
|
148
|
+
export declare function SmoothStep(from: number, to: number, tx: number): number;
|
|
149
|
+
/**
|
|
150
|
+
* Moves a value current towards target.
|
|
151
|
+
*
|
|
152
|
+
* This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
|
|
153
|
+
* Negative values of maxDelta pushes the value away from target.
|
|
154
|
+
* @param current current value
|
|
155
|
+
* @param target target value
|
|
156
|
+
* @param maxDelta max distance to move
|
|
157
|
+
* @returns resulting value
|
|
158
|
+
*/
|
|
159
|
+
export declare function MoveTowards(current: number, target: number, maxDelta: number): number;
|
|
160
|
+
/**
|
|
161
|
+
* Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
|
|
162
|
+
*
|
|
163
|
+
* Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
|
|
164
|
+
* are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
|
|
165
|
+
* @param current current value
|
|
166
|
+
* @param target target value
|
|
167
|
+
* @param maxDelta max distance to move
|
|
168
|
+
* @returns resulting angle
|
|
169
|
+
*/
|
|
170
|
+
export declare function MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
|
|
171
|
+
/**
|
|
172
|
+
* This function returns percentage of a number in a given range.
|
|
173
|
+
*
|
|
174
|
+
* RangeToPercent(40,20,60) will return 0.5 (50%)
|
|
175
|
+
* RangeToPercent(34,0,100) will return 0.34 (34%)
|
|
176
|
+
* @param number to convert to percentage
|
|
177
|
+
* @param min min range
|
|
178
|
+
* @param max max range
|
|
179
|
+
* @returns the percentage
|
|
180
|
+
*/
|
|
181
|
+
export declare function RangeToPercent(number: number, min: number, max: number): number;
|
|
182
|
+
/**
|
|
183
|
+
* This function returns number that corresponds to the percentage in a given range.
|
|
184
|
+
*
|
|
185
|
+
* PercentToRange(0.34,0,100) will return 34.
|
|
186
|
+
* @param percent to convert to number
|
|
187
|
+
* @param min min range
|
|
188
|
+
* @param max max range
|
|
189
|
+
* @returns the number
|
|
190
|
+
*/
|
|
191
|
+
export declare function PercentToRange(percent: number, min: number, max: number): number;
|
|
192
|
+
/**
|
|
193
|
+
* Returns the highest common factor of two integers.
|
|
194
|
+
* @param a first parameter
|
|
195
|
+
* @param b second parameter
|
|
196
|
+
* @returns HCF of a and b
|
|
197
|
+
*/
|
|
198
|
+
export declare function HighestCommonFactor(a: number, b: number): number;
|
|
@@ -38,6 +38,70 @@ export function RandomRange(min, max) {
|
|
|
38
38
|
export function Lerp(start, end, amount) {
|
|
39
39
|
return start + (end - start) * amount;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
|
|
43
|
+
* The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
|
|
44
|
+
* @param start start value
|
|
45
|
+
* @param end target value
|
|
46
|
+
* @param amount amount to lerp between
|
|
47
|
+
* @returns the lerped value
|
|
48
|
+
*/
|
|
49
|
+
export function LerpAngle(start, end, amount) {
|
|
50
|
+
let num = Repeat(end - start, 360.0);
|
|
51
|
+
if (num > 180.0) {
|
|
52
|
+
num -= 360.0;
|
|
53
|
+
}
|
|
54
|
+
return start + num * Clamp(amount);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Calculates the linear parameter t that produces the interpolant value within the range [a, b].
|
|
58
|
+
* @param a start value
|
|
59
|
+
* @param b target value
|
|
60
|
+
* @param value value between a and b
|
|
61
|
+
* @returns the inverseLerp value
|
|
62
|
+
*/
|
|
63
|
+
export function InverseLerp(a, b, value) {
|
|
64
|
+
let result = 0;
|
|
65
|
+
if (a != b) {
|
|
66
|
+
result = Clamp((value - a) / (b - a));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
result = 0.0;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
|
|
75
|
+
* @see http://mathworld.wolfram.com/HermitePolynomial.html
|
|
76
|
+
* @param value1 defines the first control point
|
|
77
|
+
* @param tangent1 defines the first tangent
|
|
78
|
+
* @param value2 defines the second control point
|
|
79
|
+
* @param tangent2 defines the second tangent
|
|
80
|
+
* @param amount defines the amount on the interpolation spline (between 0 and 1)
|
|
81
|
+
* @returns hermite result
|
|
82
|
+
*/
|
|
83
|
+
export function Hermite(value1, tangent1, value2, tangent2, amount) {
|
|
84
|
+
const squared = amount * amount;
|
|
85
|
+
const cubed = amount * squared;
|
|
86
|
+
const part1 = 2.0 * cubed - 3.0 * squared + 1.0;
|
|
87
|
+
const part2 = -2.0 * cubed + 3.0 * squared;
|
|
88
|
+
const part3 = cubed - 2.0 * squared + amount;
|
|
89
|
+
const part4 = cubed - squared;
|
|
90
|
+
return value1 * part1 + value2 * part2 + tangent1 * part3 + tangent2 * part4;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns a new scalar which is the 1st derivative of the Hermite spline defined by the scalars "value1", "value2", "tangent1", "tangent2".
|
|
94
|
+
* @param value1 defines the first control point
|
|
95
|
+
* @param tangent1 defines the first tangent
|
|
96
|
+
* @param value2 defines the second control point
|
|
97
|
+
* @param tangent2 defines the second tangent
|
|
98
|
+
* @param time define where the derivative must be done
|
|
99
|
+
* @returns 1st derivative
|
|
100
|
+
*/
|
|
101
|
+
export function Hermite1stDerivative(value1, tangent1, value2, tangent2, time) {
|
|
102
|
+
const t2 = time * time;
|
|
103
|
+
return (t2 - time) * 6 * value1 + (3 * t2 - 4 * time + 1) * tangent1 + (-t2 + time) * 6 * value2 + (3 * t2 - 2 * time) * tangent2;
|
|
104
|
+
}
|
|
41
105
|
/**
|
|
42
106
|
* Returns the value itself if it's between min and max.
|
|
43
107
|
* Returns min if the value is lower than min.
|
|
@@ -77,4 +141,187 @@ export function ToHex(i) {
|
|
|
77
141
|
}
|
|
78
142
|
return str.toUpperCase();
|
|
79
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* the floor part of a log2 value.
|
|
146
|
+
* @param value the value to compute log2 of
|
|
147
|
+
* @returns the log2 of value.
|
|
148
|
+
*/
|
|
149
|
+
export function ILog2(value) {
|
|
150
|
+
if (Math.log2) {
|
|
151
|
+
return Math.floor(Math.log2(value));
|
|
152
|
+
}
|
|
153
|
+
if (value < 0) {
|
|
154
|
+
return NaN;
|
|
155
|
+
}
|
|
156
|
+
else if (value === 0) {
|
|
157
|
+
return -Infinity;
|
|
158
|
+
}
|
|
159
|
+
let n = 0;
|
|
160
|
+
if (value < 1) {
|
|
161
|
+
while (value < 1) {
|
|
162
|
+
n++;
|
|
163
|
+
value = value * 2;
|
|
164
|
+
}
|
|
165
|
+
n = -n;
|
|
166
|
+
}
|
|
167
|
+
else if (value > 1) {
|
|
168
|
+
while (value > 1) {
|
|
169
|
+
n++;
|
|
170
|
+
value = Math.floor(value / 2);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return n;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Loops the value, so that it is never larger than length and never smaller than 0.
|
|
177
|
+
*
|
|
178
|
+
* This is similar to the modulo operator but it works with floating point numbers.
|
|
179
|
+
* For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
|
|
180
|
+
* With t = 5 and length = 2.5, the result would be 0.0.
|
|
181
|
+
* Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
|
|
182
|
+
* @param value the value
|
|
183
|
+
* @param length the length
|
|
184
|
+
* @returns the looped value
|
|
185
|
+
*/
|
|
186
|
+
export function Repeat(value, length) {
|
|
187
|
+
return value - Math.floor(value / length) * length;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Normalize the value between 0.0 and 1.0 using min and max values
|
|
191
|
+
* @param value value to normalize
|
|
192
|
+
* @param min max to normalize between
|
|
193
|
+
* @param max min to normalize between
|
|
194
|
+
* @returns the normalized value
|
|
195
|
+
*/
|
|
196
|
+
export function Normalize(value, min, max) {
|
|
197
|
+
return (value - min) / (max - min);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Denormalize the value from 0.0 and 1.0 using min and max values
|
|
201
|
+
* @param normalized value to denormalize
|
|
202
|
+
* @param min max to denormalize between
|
|
203
|
+
* @param max min to denormalize between
|
|
204
|
+
* @returns the denormalized value
|
|
205
|
+
*/
|
|
206
|
+
export function Denormalize(normalized, min, max) {
|
|
207
|
+
return normalized * (max - min) + min;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Calculates the shortest difference between two given angles given in degrees.
|
|
211
|
+
* @param current current angle in degrees
|
|
212
|
+
* @param target target angle in degrees
|
|
213
|
+
* @returns the delta
|
|
214
|
+
*/
|
|
215
|
+
export function DeltaAngle(current, target) {
|
|
216
|
+
let num = Repeat(target - current, 360.0);
|
|
217
|
+
if (num > 180.0) {
|
|
218
|
+
num -= 360.0;
|
|
219
|
+
}
|
|
220
|
+
return num;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* PingPongs the value t, so that it is never larger than length and never smaller than 0.
|
|
224
|
+
* @param tx value
|
|
225
|
+
* @param length length
|
|
226
|
+
* @returns The returned value will move back and forth between 0 and length
|
|
227
|
+
*/
|
|
228
|
+
export function PingPong(tx, length) {
|
|
229
|
+
const t = Repeat(tx, length * 2.0);
|
|
230
|
+
return length - Math.abs(t - length);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Interpolates between min and max with smoothing at the limits.
|
|
234
|
+
*
|
|
235
|
+
* This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
|
|
236
|
+
* from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
|
|
237
|
+
* @param from from
|
|
238
|
+
* @param to to
|
|
239
|
+
* @param tx value
|
|
240
|
+
* @returns the smooth stepped value
|
|
241
|
+
*/
|
|
242
|
+
export function SmoothStep(from, to, tx) {
|
|
243
|
+
let t = Clamp(tx);
|
|
244
|
+
t = -2.0 * t * t * t + 3.0 * t * t;
|
|
245
|
+
return to * t + from * (1.0 - t);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Moves a value current towards target.
|
|
249
|
+
*
|
|
250
|
+
* This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
|
|
251
|
+
* Negative values of maxDelta pushes the value away from target.
|
|
252
|
+
* @param current current value
|
|
253
|
+
* @param target target value
|
|
254
|
+
* @param maxDelta max distance to move
|
|
255
|
+
* @returns resulting value
|
|
256
|
+
*/
|
|
257
|
+
export function MoveTowards(current, target, maxDelta) {
|
|
258
|
+
let result = 0;
|
|
259
|
+
if (Math.abs(target - current) <= maxDelta) {
|
|
260
|
+
result = target;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
result = current + Math.sign(target - current) * maxDelta;
|
|
264
|
+
}
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
|
|
269
|
+
*
|
|
270
|
+
* Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
|
|
271
|
+
* are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
|
|
272
|
+
* @param current current value
|
|
273
|
+
* @param target target value
|
|
274
|
+
* @param maxDelta max distance to move
|
|
275
|
+
* @returns resulting angle
|
|
276
|
+
*/
|
|
277
|
+
export function MoveTowardsAngle(current, target, maxDelta) {
|
|
278
|
+
const num = DeltaAngle(current, target);
|
|
279
|
+
let result = 0;
|
|
280
|
+
if (-maxDelta < num && num < maxDelta) {
|
|
281
|
+
result = target;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
target = current + num;
|
|
285
|
+
result = MoveTowards(current, target, maxDelta);
|
|
286
|
+
}
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* This function returns percentage of a number in a given range.
|
|
291
|
+
*
|
|
292
|
+
* RangeToPercent(40,20,60) will return 0.5 (50%)
|
|
293
|
+
* RangeToPercent(34,0,100) will return 0.34 (34%)
|
|
294
|
+
* @param number to convert to percentage
|
|
295
|
+
* @param min min range
|
|
296
|
+
* @param max max range
|
|
297
|
+
* @returns the percentage
|
|
298
|
+
*/
|
|
299
|
+
export function RangeToPercent(number, min, max) {
|
|
300
|
+
return (number - min) / (max - min);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* This function returns number that corresponds to the percentage in a given range.
|
|
304
|
+
*
|
|
305
|
+
* PercentToRange(0.34,0,100) will return 34.
|
|
306
|
+
* @param percent to convert to number
|
|
307
|
+
* @param min min range
|
|
308
|
+
* @param max max range
|
|
309
|
+
* @returns the number
|
|
310
|
+
*/
|
|
311
|
+
export function PercentToRange(percent, min, max) {
|
|
312
|
+
return (max - min) * percent + min;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Returns the highest common factor of two integers.
|
|
316
|
+
* @param a first parameter
|
|
317
|
+
* @param b second parameter
|
|
318
|
+
* @returns HCF of a and b
|
|
319
|
+
*/
|
|
320
|
+
export function HighestCommonFactor(a, b) {
|
|
321
|
+
const r = a % b;
|
|
322
|
+
if (r === 0) {
|
|
323
|
+
return b;
|
|
324
|
+
}
|
|
325
|
+
return HighestCommonFactor(b, r);
|
|
326
|
+
}
|
|
80
327
|
//# sourceMappingURL=math.scalar.functions.js.map
|