Answers for "js lerp"

1

lerp javascript

function lerp(a, b, t) {
  return (1 - t) * a + t * b;
}
Posted by: Guest on May-30-2021
1

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;
Posted by: Guest on April-26-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language