forked from jeromeetienne/threex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreex.sparksPlugins.js
36 lines (32 loc) · 1.09 KB
/
threex.sparksPlugins.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
var THREEx = THREEx || {};
THREEx.SparksPlugins = {};
THREEx.SparksPlugins.InitColor = function(color){
this.initialize = function( emitter, particle ){
particle.target.color().copy( color );
};
};
THREEx.SparksPlugins.InitSize = function(size){
this.initialize = function( emitter, particle ){
particle.target.size(size);
};
};
THREEx.SparksPlugins.ActionLinearColor = function(colorSrc, colorDst, deltaSeconds){
var colorInc = new THREE.Color();
colorInc.r = (colorDst.r - colorSrc.r) / deltaSeconds;
colorInc.g = (colorDst.g - colorSrc.g) / deltaSeconds;
colorInc.b = (colorDst.b - colorSrc.b) / deltaSeconds;
this.update = function( emitter, particle, time ){
var color = particle.target.color();
color.r += colorInc.r * time;
color.g += colorInc.g * time;
color.b += colorInc.b * time;
};
};
THREEx.SparksPlugins.ActionLinearSize = function(sizeSrc, sizeDst, deltaSeconds){
var sizeInc = ( sizeDst - sizeSrc ) / deltaSeconds;
this.update = function( emitter, particle, time ){
var size = particle.target.size();
size += sizeInc * time;
particle.target.size( size );
};
};