-
Notifications
You must be signed in to change notification settings - Fork 38
/
threex.atmospherematerialdatgui.js
42 lines (40 loc) · 1.08 KB
/
threex.atmospherematerialdatgui.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
/**
* vendor.js framework definition
* @type {Object}
*/
var THREEx = THREEx || {};
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 , 5)
.listen().onChange( onChange )
datGui.addColor( options, 'glowColor' )
.listen().onChange( onChange )
datGui.add( options, 'presetFront' )
datGui.add( options, 'presetBack' )
}