Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@14islands/lerp

14islands1.3kMIT1.0.3

Frame rate independent linear interpolation function

linear, interpolation, lerp, interp, smoothstep, mix, anim, animation, animate, fps, independent, damping

readme

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

Sandbox demo

License

MIT, see LICENSE.md for details.