29 lines
561 B
JavaScript
29 lines
561 B
JavaScript
export class Vec3 {
|
|
constructor(values = {
|
|
x: 0,
|
|
y: 0,
|
|
z: 0
|
|
}) {
|
|
this.x = values.x;
|
|
this.y = values.y;
|
|
this.z = values.z;
|
|
}
|
|
add(vector) {
|
|
this.x += vector.x;
|
|
this.y += vector.y;
|
|
this.z += vector.z;
|
|
}
|
|
multiply(vector) {
|
|
this.x *= vector.x;
|
|
this.y *= vector.y;
|
|
this.z *= vector.z;
|
|
}
|
|
clone() {
|
|
return new Vec3({
|
|
x: this.x,
|
|
y: this.y,
|
|
z: this.z
|
|
});
|
|
}
|
|
}
|