ShaderDestination.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import Check from "../Core/Check.js";
  2. /**
  3. * An enum describing whether a variable should be added to the
  4. * vertex shader, the fragment shader, or both.
  5. *
  6. * @private
  7. */
  8. const ShaderDestination = {
  9. VERTEX: 0,
  10. FRAGMENT: 1,
  11. BOTH: 2,
  12. };
  13. /**
  14. * Check if a variable should be included in the vertex shader.
  15. *
  16. * @param {ShaderDestination} destination The ShaderDestination to check
  17. * @return {boolean} <code>true</code> if the variable appears in the vertex shader, or <code>false</code> otherwise
  18. * @private
  19. */
  20. ShaderDestination.includesVertexShader = function (destination) {
  21. //>>includeStart('debug', pragmas.debug);
  22. Check.typeOf.number("destination", destination);
  23. //>>includeEnd('debug');
  24. return (
  25. destination === ShaderDestination.VERTEX ||
  26. destination === ShaderDestination.BOTH
  27. );
  28. };
  29. /**
  30. * Check if a variable should be included in the vertex shader.
  31. *
  32. * @param {ShaderDestination} destination The ShaderDestination to check
  33. * @return {boolean} <code>true</code> if the variable appears in the vertex shader, or <code>false</code> otherwise
  34. * @private
  35. */
  36. ShaderDestination.includesFragmentShader = function (destination) {
  37. //>>includeStart('debug', pragmas.debug);
  38. Check.typeOf.number("destination", destination);
  39. //>>includeEnd('debug');
  40. //
  41. return (
  42. destination === ShaderDestination.FRAGMENT ||
  43. destination === ShaderDestination.BOTH
  44. );
  45. };
  46. export default Object.freeze(ShaderDestination);