Added origin to resize method

This commit is contained in:
Richard Davey 2022-12-08 16:17:10 +00:00
parent fea262f3e0
commit 45c0c23f6f

View file

@ -234,10 +234,12 @@ var Vertex = new Class({
* @param {number} y - The y position of the vertex. * @param {number} y - The y position of the vertex.
* @param {number} width - The width of the parent Mesh. * @param {number} width - The width of the parent Mesh.
* @param {number} height - The height of the parent Mesh. * @param {number} height - The height of the parent Mesh.
* @param {number} originX - The originX of the parent Mesh.
* @param {number} originY - The originY of the parent Mesh.
* *
* @return {this} This Vertex. * @return {this} This Vertex.
*/ */
resize: function (x, y, width, height) resize: function (x, y, width, height, originX, originY)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
@ -246,6 +248,24 @@ var Vertex = new Class({
this.vy = -this.y * height; this.vy = -this.y * height;
this.vz = 0; this.vz = 0;
if (originX < 0.5)
{
this.vx += width * (0.5 - originX);
}
else if (originX > 0.5)
{
this.vx -= width * (originX - 0.5);
}
if (originY < 0.5)
{
this.vy += height * (0.5 - originY);
}
else if (originY > 0.5)
{
this.vy -= height * (originY - 0.5);
}
return this; return this;
}, },