Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wildpeaks/package-interpolators
Typescript classes to interpolate between keyframes in the style of VRML interpolators
https://github.com/wildpeaks/package-interpolators
npm-package typescript
Last synced: 2 days ago
JSON representation
Typescript classes to interpolate between keyframes in the style of VRML interpolators
- Host: GitHub
- URL: https://github.com/wildpeaks/package-interpolators
- Owner: wildpeaks
- License: mit
- Created: 2017-06-10T01:17:50.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-04T22:01:51.000Z (about 1 month ago)
- Last Synced: 2024-10-05T19:36:18.420Z (about 1 month ago)
- Topics: npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@wildpeaks/interpolators
- Size: 691 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Interpolators
![Github Release](https://img.shields.io/github/v/release/wildpeaks/package-interpolators.svg?label=Release&logo=github&logoColor=eceff4&colorA=4c566a&colorB=11abfb)
**Typescript classes to interpolate keyframes** in the style of [VRML interpolators](http://www.web3d.org/documents/specifications/14772/V2.0/part1/nodesRef.html#ScalarInterpolator).
Install using:
npm install @wildpeaks/interpolators
-------------------------------------------------------------------------------
## ScalarInterpolator
**ScalarInterpolator** interpolates `number` values.
Example:
````ts
import {ScalarInterpolator} from '@wildpeaks/interpolators';const interp = new ScalarInterpolator([0, 0.5, 1], [1, 2, 3]);
// First keyframe
interp.setFraction(0);
console.log(interp.getValue()); // 1// Second keyframe
interp.setFraction(0.5);
console.log(interp.getValue()); // 2// Interpolated keyframe
interp.setFraction(0.25);
console.log(interp.getValue()); // 1.5````
-------------------------------------------------------------------------------
## PositionInterpolator2D
**PositionInterpolator2D** interpolates `[number, number]` values.
Example:
````ts
import {PositionInterpolator2D} from '@wildpeaks/interpolators';const interp = new PositionInterpolator2D([0, 0.5, 1], [ [1,10], [2,20], [3,30] ]);
// First keyframe
interp.setFraction(0);
console.log(interp.getValue()); // [1, 10]// Second keyframe
interp.setFraction(0.5);
console.log(interp.getValue()); // [2, 20]// Interpolated keyframe
interp.setFraction(0.25);
console.log(interp.getValue()); // [1.5, 15]````
-------------------------------------------------------------------------------
## PositionInterpolator
**PositionInterpolator** interpolates `[number, number, number]` values.
Example:
````ts
import {PositionInterpolator} from '@wildpeaks/interpolators';const interp = new PositionInterpolator([0, 0.5, 1], [ [1,10,100], [2,20,200], [3,30,300] ]);
// First keyframe
interp.setFraction(0);
console.log(interp.getValue()); // [1, 10, 100]// Second keyframe
interp.setFraction(0.5);
console.log(interp.getValue()); // [2, 20, 200]// Interpolated keyframe
interp.setFraction(0.25);
console.log(interp.getValue()); // [1.5, 15, 150]````
-------------------------------------------------------------------------------