diff --git a/src/vector.js b/src/vector.js index c4174ed4..69578b8d 100644 --- a/src/vector.js +++ b/src/vector.js @@ -1,4 +1,3 @@ - let inProgress = 'default'; const v3ValueOf = { @@ -56,6 +55,15 @@ export class Vector { return v3ValueOf[inProgress].call(this); } + normalize() { + const { length } = this; + return new Vector(this.x / length, this.y / length, this.z / length); + } + + norm() { + return this.normalize(); + } + toString() { return `[${this.x}, ${this.y}, ${this.z}]`; }