phaser/v3/src/math/CatmullRom.js

12 lines
282 B
JavaScript
Raw Normal View History

2017-09-21 01:30:35 +00:00
var CatmullRom = function (t, p0, p1, p2, p3)
{
2017-09-21 01:30:35 +00:00
var v0 = (p2 - p0) * 0.5;
var v1 = (p3 - p1) * 0.5;
var t2 = t * t;
var t3 = t * t2;
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
};
module.exports = CatmullRom;