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);
Some devices only run at 30fps, for instance iOS in battery saving mode. Some devices run faster, for instance Oculus Quest 2 runs at 90 fps, Macbook M1 Max and gaming PCs run at 120 fps.
// 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)
MIT, see LICENSE.md for details.