浏览代码

Update negate to return a new Vector3

ApisNecros 4 月之前
父节点
当前提交
ad13d63d54
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      12/Vector3.js

+ 6 - 4
12/Vector3.js

@@ -27,11 +27,13 @@ module.exports = class Vector3 {
     /**
      * Flip the sign of all properties of the vector
      *
-     * @returns {void}
+     * @returns {Vector3} A new Vector3
      */
     negate() {
-        this.x = -this.x;
-        this.y = -this.y;
-        this.z = -this.z;
+        return new Vector3(
+            -this.x,
+            -this.y,
+            -this.z,
+        );
     }
 };