UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

19 lines (16 loc) 527 B
import { clamp01 } from "./clamp01.js"; /** * Ken Perlin's suggested improvement on `smoothStep` function * has gentler entry and exit slope * @see https://en.wikipedia.org/wiki/Smoothstep * @param {number} edge0 * @param {number} edge1 * @param {number} x * @returns {number} */ export function smootherStep(edge0, edge1, x) { // Scale, and clamp x to 0..1 range const span = edge1 - edge0; const t = clamp01((x - edge0) / span); return t * t * t * (t * (6.0 * t - 15.0) + 10.0); }