Merge pull request #4879 from rexrainbow/curve-improvement2

Override default Curve.getUtoTmapping method
This commit is contained in:
Richard Davey 2019-12-18 14:37:36 +00:00 committed by GitHub
commit a4fb73fe38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -194,6 +194,41 @@ var LineCurve = new Class({
return tangent.normalize();
},
// Override default Curve.getUtoTmapping
/**
* [description]
*
* @method Phaser.Curves.Line#getUtoTmapping
* @since 3.0.0
*
* @param {number} u - [description]
* @param {integer} distance - [description]
* @param {integer} [divisions] - [description]
*
* @return {number} [description]
*/
getUtoTmapping: function (u, distance, divisions)
{
var t;
if (distance)
{
var arcLengths = this.getLengths(divisions);
var lineLength = arcLengths[arcLengths.length - 1];
// Cannot overshoot the curve
var targetLineLength = Math.min(distance, lineLength);
t = targetLineLength / lineLength;
}
else
{
t = u;
}
return t;
},
// Override default Curve.draw because this is better than calling getPoints on a line!
/**