tsparticles
Version:
Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.
55 lines (54 loc) • 1.33 kB
JavaScript
import { Vector } from "./Vector";
export class Vector3d extends Vector {
constructor(x, y, z) {
super(x, y);
this.z = z === undefined ? x.z : z;
}
static clone(source) {
return Vector3d.create(source.x, source.y, source.z);
}
static create(x, y, z) {
return new Vector3d(x, y, z);
}
add(v) {
return v instanceof Vector3d ? Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z) : super.add(v);
}
addTo(v) {
super.addTo(v);
if (v instanceof Vector3d) {
this.z += v.z;
}
}
sub(v) {
return v instanceof Vector3d ? Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z) : super.sub(v);
}
subFrom(v) {
super.subFrom(v);
if (v instanceof Vector3d) {
this.z -= v.z;
}
}
mult(n) {
return Vector3d.create(this.x * n, this.y * n, this.z * n);
}
multTo(n) {
super.multTo(n);
this.z *= n;
}
div(n) {
return Vector3d.create(this.x / n, this.y / n, this.z / n);
}
divTo(n) {
super.divTo(n);
this.z /= n;
}
copy() {
return Vector3d.clone(this);
}
setTo(v) {
super.setTo(v);
if (v instanceof Vector3d) {
this.z = v.z;
}
}
}