addgradient.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. window.prepareGradient = function() {
  2. var grad = new BABYLON.GradientMaterial("gradient", scene);
  3. // Top color
  4. registerColorPicker("gradient", "topColor", "#ff0000", function(value) {
  5. grad.topColor = BABYLON.Color3.FromHexString(value);
  6. }, function() {
  7. return grad.topColor.toHexString();
  8. });
  9. // topColorAlpha
  10. registerRangeUI("gradient", "topColorAlpha", 0, 1, function(value) {
  11. grad.topColorAlpha = value;
  12. }, function() {
  13. return grad.topColorAlpha;
  14. });
  15. // Bottom color
  16. registerColorPicker("gradient", "bottomColor", "#0000ff", function(value) {
  17. grad.bottomColor = BABYLON.Color3.FromHexString(value);
  18. }, function() {
  19. return grad.bottomColor.toHexString();
  20. });
  21. // topColorAlpha
  22. registerRangeUI("gradient", "bottomColorAlpha", 0, 1, function(value) {
  23. grad.bottomColorAlpha = value;
  24. }, function() {
  25. return grad.bottomColorAlpha;
  26. });
  27. // offset
  28. registerRangeUI("gradient", "offset", -1, 1, function(value) {
  29. grad.offset = value;
  30. }, function() {
  31. return grad.offset;
  32. });
  33. // smoothness
  34. registerRangeUI("gradient", "smoothness", 0, 5, function(value) {
  35. grad.smoothness = value;
  36. }, function() {
  37. return grad.smoothness;
  38. });
  39. return grad;
  40. };