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');
|
2017-09-21 01:30:54 +00:00
|
|
|
var CubicBezier = require('../../../math/interpolation/CubicBezierInterpolation');
|
2017-09-20 22:10:37 +00:00
|
|
|
var Curve = require('../Curve');
|
|
|
|
var Vector2 = require('../../../math/Vector2');
|
|
|
|
|
2017-09-21 01:30:54 +00:00
|
|
|
// Phaser.Curves.CubicBezier
|
2017-09-20 22:10:37 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2017-09-21 01:30:54 +00:00
|
|
|
return out.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y));
|
2017-09-20 22:10:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = CubicBezierCurve;
|