ColorBlendMode.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import freezeObject from '../Core/freezeObject.js';
  2. import CesiumMath from '../Core/Math.js';
  3. /**
  4. * Defines different modes for blending between a target color and a primitive's source color.
  5. *
  6. * HIGHLIGHT multiplies the source color by the target color
  7. * REPLACE replaces the source color with the target color
  8. * MIX blends the source color and target color together
  9. *
  10. * @exports ColorBlendMode
  11. *
  12. * @see Model.colorBlendMode
  13. */
  14. var ColorBlendMode = {
  15. HIGHLIGHT : 0,
  16. REPLACE : 1,
  17. MIX : 2
  18. };
  19. /**
  20. * @private
  21. */
  22. ColorBlendMode.getColorBlend = function(colorBlendMode, colorBlendAmount) {
  23. if (colorBlendMode === ColorBlendMode.HIGHLIGHT) {
  24. return 0.0;
  25. } else if (colorBlendMode === ColorBlendMode.REPLACE) {
  26. return 1.0;
  27. } else if (colorBlendMode === ColorBlendMode.MIX) {
  28. // The value 0.0 is reserved for highlight, so clamp to just above 0.0.
  29. return CesiumMath.clamp(colorBlendAmount, CesiumMath.EPSILON4, 1.0);
  30. }
  31. };
  32. export default freezeObject(ColorBlendMode);