export namespace MathUtils { param value param min param max returns export function clamp ( value , min , max ) { return value < min ? min : value > max ? max : value ; } see https param edge0 param edge1 param x export function smoothStep ( edge0 , edge1 , x ) { x = clamp ( ( x - edge0 ) / ( edge1 - edge0 ) , 0.0 , 1.0 ) ; return x * x * ( 3 - 2 * x ) ; } see https param edge0 param edge1 param x export function smootherStep ( edge0 , edge1 , x ) { x = clamp ( ( x - edge0 ) / ( edge1 - edge0 ) , 0.0 , 1.0 ) ; return x * x * x * ( x * ( x * 6 - 15 ) + 10 ) ; } param val param inMin param inMax param outMin param outMax export function map ( val , inMin , inMax , outMin , outMax ) { return ( ( val - inMin ) * ( outMax - outMin ) ) / ( inMax - inMin ) + outMin ; } param a param b export function min2 ( a , b ) { let result ; if ( a !== undefined ) { result = a ; } if ( b !== undefined ) { result = result === undefined ? b : Math . min ( result , b ) ; } return result ; } param a param b export function max2 ( a , b ) { let result ; if ( a !== undefined ) { result = a ; } if ( b !== undefined ) { result = result === undefined ? b : Math . max ( result , b ) ; } return result ; } param value param lowerBound param upperBound returns export function isClamped ( value , lowerBound , upperBound ) { if ( lowerBound !== undefined && value < lowerBound ) { return false ; } if ( upperBound !== undefined && value > upperBound ) { return false ; } return true ; } param startValue param endValue param time returns export function easeInOutCubic ( startValue , endValue , time ) { const timeValue = time < 0.5 ? 4 * time * time * time : ( time - 1 ) * ( 2 * time - 2 ) * ( 2 * time - 2 ) + 1 ; return startValue + ( endValue - startValue ) * timeValue ; } }