BlendingState.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import freezeObject from '../Core/freezeObject.js';
  2. import BlendEquation from './BlendEquation.js';
  3. import BlendFunction from './BlendFunction.js';
  4. /**
  5. * The blending state combines {@link BlendEquation} and {@link BlendFunction} and the
  6. * <code>enabled</code> flag to define the full blending state for combining source and
  7. * destination fragments when rendering.
  8. * <p>
  9. * This is a helper when using custom render states with {@link Appearance#renderState}.
  10. * </p>
  11. *
  12. * @exports BlendingState
  13. */
  14. var BlendingState = {
  15. /**
  16. * Blending is disabled.
  17. *
  18. * @type {Object}
  19. * @constant
  20. */
  21. DISABLED : freezeObject({
  22. enabled : false
  23. }),
  24. /**
  25. * Blending is enabled using alpha blending, <code>source(source.alpha) + destination(1 - source.alpha)</code>.
  26. *
  27. * @type {Object}
  28. * @constant
  29. */
  30. ALPHA_BLEND : freezeObject({
  31. enabled : true,
  32. equationRgb : BlendEquation.ADD,
  33. equationAlpha : BlendEquation.ADD,
  34. functionSourceRgb : BlendFunction.SOURCE_ALPHA,
  35. functionSourceAlpha : BlendFunction.ONE,
  36. functionDestinationRgb : BlendFunction.ONE_MINUS_SOURCE_ALPHA,
  37. functionDestinationAlpha : BlendFunction.ONE_MINUS_SOURCE_ALPHA
  38. }),
  39. /**
  40. * Blending is enabled using alpha blending with premultiplied alpha, <code>source + destination(1 - source.alpha)</code>.
  41. *
  42. * @type {Object}
  43. * @constant
  44. */
  45. PRE_MULTIPLIED_ALPHA_BLEND : freezeObject({
  46. enabled : true,
  47. equationRgb : BlendEquation.ADD,
  48. equationAlpha : BlendEquation.ADD,
  49. functionSourceRgb : BlendFunction.ONE,
  50. functionSourceAlpha : BlendFunction.ONE,
  51. functionDestinationRgb : BlendFunction.ONE_MINUS_SOURCE_ALPHA,
  52. functionDestinationAlpha : BlendFunction.ONE_MINUS_SOURCE_ALPHA
  53. }),
  54. /**
  55. * Blending is enabled using additive blending, <code>source(source.alpha) + destination</code>.
  56. *
  57. * @type {Object}
  58. * @constant
  59. */
  60. ADDITIVE_BLEND : freezeObject({
  61. enabled : true,
  62. equationRgb : BlendEquation.ADD,
  63. equationAlpha : BlendEquation.ADD,
  64. functionSourceRgb : BlendFunction.SOURCE_ALPHA,
  65. functionSourceAlpha : BlendFunction.ONE,
  66. functionDestinationRgb : BlendFunction.ONE,
  67. functionDestinationAlpha : BlendFunction.ONE
  68. })
  69. };
  70. export default freezeObject(BlendingState);