mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Merge pull request #4879 from rexrainbow/curve-improvement2
Override default Curve.getUtoTmapping method
This commit is contained in:
commit
a4fb73fe38
1 changed files with 35 additions and 0 deletions
|
@ -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!
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue