优化vector2构造函数

This commit is contained in:
yhh
2021-05-24 17:20:27 +08:00
parent 9c7703eb2d
commit da3ab02a8d
20 changed files with 177 additions and 109 deletions
+2 -2
View File
@@ -304,7 +304,7 @@ module es {
*/
public getClosestPointOnRectangleToPoint(point: Vector2) {
// 对于每条轴,如果点在框外,就把它限制在框内,否则就不要管它
let res = new Vector2();
let res = es.Vector2.zero;
res.x = MathHelper.clamp(point.x, this.left, this.right);
res.y = MathHelper.clamp(point.y, this.top, this.bottom);
@@ -319,7 +319,7 @@ module es {
*/
public getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2 {
// 对于每条轴,如果点在框外,就把它限制在框内,否则就不要管它
let res = new Vector2();
let res = es.Vector2.zero;
res.x = MathHelper.clamp(point.x, this.left, this.right);
res.y = MathHelper.clamp(point.y, this.top, this.bottom);