javascript lerp between value code example
Example: javascript lerp
export function lerp(v0, v1, amt, maxMove = 0, minDiff = 0.0001) {
let diff = v1 - v0;
if (maxMove > 0) {
diff = Math.min(diff, maxMove);
diff = Math.max(diff, -maxMove);
}
if (Math.abs(diff) < minDiff) {
return v1;
}
return v0 + diff * amt;
};
export default lerp;