npm

@14islands/lerp

1.0.3 • Public • Published

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.

Package Sidebar

Install

npm i @14islands/lerp

Weekly Downloads

325

Version

1.0.3

License

MIT

Unpacked Size

4.41 kB

Total Files

6

Last publish

Collaborators

  • abreu00
  • ffdead