(min: number, max: number, x: number)
| 49 | |
| 50 | // Prefer glsl's argument order which differs from that of MathUtils. |
| 51 | export function smoothstep(min: number, max: number, x: number): number { |
| 52 | if (x <= min) { |
| 53 | return 0 |
| 54 | } |
| 55 | if (x >= max) { |
| 56 | return 1 |
| 57 | } |
| 58 | x = (x - min) / (max - min) |
| 59 | return x * x * (3 - 2 * x) |
| 60 | } |
| 61 | |
| 62 | export function saturate(x: number): number { |
| 63 | return Math.min(Math.max(x, 0), 1) |
nothing calls this directly
no outgoing calls
no test coverage detected