2017-09-20 22:10:37 +00:00
|
|
|
// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
|
|
|
|
|
|
|
|
var Class = require('../../../utils/Class');
|
|
|
|
var Curve = require('../Curve');
|
|
|
|
var Vector2 = require('../../../math/Vector2');
|
|
|
|
var CubicBezier = require('../../../math/interpolation/CubicBezierInterpolation');
|
|
|
|
|
|
|
|
// Phaser.Paths.Curves.CubicBezier
|
|
|
|
|
|
|
|
var CubicBezierCurve = new Class({
|
|
|
|
|
|
|
|
Extends: Curve,
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function CubicBezierCurve (v0, v1, v2, v3)
|
|
|
|
{
|
2017-09-21 00:19:27 +00:00
|
|
|
Curve.call(this);
|
|
|
|
|
2017-09-20 22:10:37 +00:00
|
|
|
this.v0 = v0;
|
|
|
|
this.v1 = v1;
|
|
|
|
this.v2 = v2;
|
|
|
|
this.v3 = v3;
|
|
|
|
},
|
|
|
|
|
|
|
|
getPoint: function (t, out)
|
|
|
|
{
|
|
|
|
if (out === undefined) { out = new Vector2(); }
|
|
|
|
|
|
|
|
var v0 = this.v0;
|
|
|
|
var v1 = this.v1;
|
|
|
|
var v2 = this.v2;
|
|
|
|
var v3 = this.v3;
|
|
|
|
|
|
|
|
return out.set(
|
|
|
|
CubicBezier(t, v0.x, v1.x, v2.x, v3.x),
|
|
|
|
CubicBezier(t, v0.y, v1.y, v2.y, v3.y)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = CubicBezierCurve;
|