assassin-bug/framework/physics/vec3.js

29 lines
561 B
JavaScript
Raw Normal View History

2022-11-26 01:22:02 +00:00
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
});
}
}