123456789101112131415161718192021222324252627282930313233343536373839 |
- module.exports = class Vector3 {
- /**
- * A 3D vector
- *
- * @param {number} x The X value of this vector
- * @param {number} y The Y value of this vector
- * @param {number} z The Z value of this vector
- */
- constructor(x, y, z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- /**
- * Add another vector to this one
- *
- * @param {Vector3} operand The vector to add to this one
- * @returns {void}
- */
- add(operand) {
- this.x += operand.x;
- this.y += operand.y;
- this.z += operand.z;
- }
- /**
- * Flip the sign of all properties of the vector
- *
- * @returns {Vector3} A new Vector3
- */
- negate() {
- return new Vector3(
- -this.x,
- -this.y,
- -this.z,
- );
- }
- };
|