threex.atmospherematerialdatgui.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * vendor.js framework definition
  3. * @type {Object}
  4. */
  5. var THREEx = THREEx || {};
  6. THREEx.addAtmosphereMaterial2DatGui = function(material, datGui){
  7. datGui = datGui || new dat.GUI()
  8. var uniforms = material.uniforms
  9. // options
  10. var options = {
  11. coeficient : uniforms['coeficient'].value,
  12. power : uniforms['power'].value,
  13. glowColor : '#'+uniforms.glowColor.value.getHexString(),
  14. presetFront : function(){
  15. options.coeficient = 1
  16. options.power = 2
  17. onChange()
  18. },
  19. presetBack : function(){
  20. options.coeficient = 0.5
  21. options.power = 4.0
  22. onChange()
  23. },
  24. }
  25. var onChange = function(){
  26. uniforms['coeficient'].value = options.coeficient
  27. uniforms['power'].value = options.power
  28. uniforms.glowColor.value.set( options.glowColor );
  29. }
  30. onChange()
  31. // config datGui
  32. datGui.add( options, 'coeficient' , 0.0 , 2)
  33. .listen().onChange( onChange )
  34. datGui.add( options, 'power' , 0.0 , 5)
  35. .listen().onChange( onChange )
  36. datGui.addColor( options, 'glowColor' )
  37. .listen().onChange( onChange )
  38. datGui.add( options, 'presetFront' )
  39. datGui.add( options, 'presetBack' )
  40. }