-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
**When performing the lerp function on a Vector2 instance the result of that operation wil be used to overwrite the original value of that Vector2's instance.
Meaning the lerp function is not immutable. And after reading the documentation it is not supposed to be.
So that is why I am not posting this as a bug.
Here is the thing though; I usually do not want to lose the original Vector2's value. So have to remember to clone the original Vector2 every time a interpolation is needed. That tends to create hard to find bugs. Or at least decrease readability of the code.
The Geom classes have static methods for things like GetPoint, even though you can also do .getPoint operations on an instance object. And as far as I know the latter does not really mutate the instance member vars.
Could not find such a static method for interpolation, well there is Phaser.Math.Linear but that does not return a new Vector2, or even Point;
So why not include a static method for interpolation that takes 2 Vector2 in a similar fashion as GetPoint does for geom classes and returns a brand new Vector2 as the result?
I include here a demo to show what i mean: