1.0.3 • Published 4 years ago
@14islands/lerp v1.0.3
Frame rate independent linear interpolation function
This is a frame rate independent linear interpolation function based on this article. It uses https://www.npmjs.com/package/lerp under the hood.
var lerp = require('@14islands/lerp')
var res = lerp(a, b, t, frameDelta, targetFps);
Usage
// classic lerp - works as expected
lerp(start, end, progress)
// Interpolates and adjusts for the frame delta. Default target is 60fps.
const frameDelta = clock.getDelta()
lerp(start, end, alpha, frameDeltaMs)
// Adjust for frame delta targeting a 120fps refresh rate.
const frameDelta = clock.getDelta()
lerp(start, end, alpha, frameDelta, 120)
Demo
License
MIT, see LICENSE.md for details.