forked from jeromeetienne/threex.planets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreex.atmospheredatgui.js
48 lines (46 loc) · 1.27 KB
/
threex.atmospheredatgui.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
41
42
43
44
45
46
47
48
/**
* vendor.js framework definition
* @type {Object}
*/
var THREEx = THREEx || {};
/**
* add a THREEx.AtmosphereMaterial to Dat.DUI
*
* @param {THREE.ShaderMaterial} material the material to handle
* @param {dat.GUI+} datGui the dat.GUI to which we need to add
*/
THREEx.addAtmosphereMaterial2DatGui = function(material, datGui){
datGui = datGui || new dat.GUI()
var uniforms = material.uniforms
// options
var options = {
coeficient : uniforms['coeficient'].value,
power : uniforms['power'].value,
glowColor : '#'+uniforms.glowColor.value.getHexString(),
presetFront : function(){
options.coeficient = 1
options.power = 2
onChange()
},
presetBack : function(){
options.coeficient = 0.5
options.power = 4.0
onChange()
},
}
var onChange = function(){
uniforms['coeficient'].value = options.coeficient
uniforms['power'].value = options.power
uniforms.glowColor.value.set( options.glowColor );
}
onChange()
// config datGui
datGui.add( options, 'coeficient' , 0.0 , 2)
.listen().onChange( onChange )
datGui.add( options, 'power' , 0.0 , 30)
.listen().onChange( onChange )
datGui.addColor( options, 'glowColor' )
.listen().onChange( onChange )
datGui.add( options, 'presetFront' )
datGui.add( options, 'presetBack' )
}