forked from cvan/tanx-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfireParticle.js
More file actions
27 lines (24 loc) · 774 Bytes
/
fireParticle.js
File metadata and controls
27 lines (24 loc) · 774 Bytes
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
pc.script.create('fireParticle', function (context) {
var FireParticle = function (entity) {
this.entity = entity;
};
FireParticle.prototype = {
initialize: function () {
this.born = 0;
this.life = 0;
this.size = 0.01;
this.targetSize = 0.1;
},
update: function (dt) {
var time = Date.now() - this.born;
if (time > this.life) {
this.entity.fire('finish');
this.entity.enabled = false;
} else {
this.size += (this.targetSize - this.size) * (0.1 * (this.life / 200));
this.entity.setLocalScale(this.size, 0.1, this.size);
}
}
};
return FireParticle;
});