-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticle.js
40 lines (29 loc) · 981 Bytes
/
particle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//requires: vector3.js color.js
//class
(function() {
"use strict";
//shortcuts
const Vector3 = particlejs.Vector3;
const Color = particlejs.Color;
//constructor
const Particle = function(x = 0, y = 0, z = 0, r = 1) {
this.position = new Vector3(x, y, z);
this.screenPosition = new Vector3();
this.radius = r;
this.screenRadius = r;
this.color = new Color();
this.enabled = true;
this.visible = true;
//physics
this.velocity = new Vector3();
this.charge = 0;
this.mass = 0;
};
const proto = Particle.prototype;
proto.clone = function() {
const copy = new Particle(this.position.x, this.position.y, this.position.z, this.radius);
copy.color.set(this.color.r, this.color.g, this.color.b, this.color.a);
return copy;
};
particlejs.Particle = Particle;
})();