智慧水务管理系统 - 精河县供水工程综合管理平台

ShaderDestination.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import Check from "../Core/Check.js";
  2. import DeveloperError from "../Core/DeveloperError.js";
  3. /**
  4. * A bit flag describing whether a variable should be added to the
  5. * vertex shader, the fragment shader, or both (or none).
  6. *
  7. * @enum {number}
  8. * @private
  9. */
  10. const ShaderDestination = {
  11. NONE: 0,
  12. VERTEX: 1,
  13. FRAGMENT: 2,
  14. BOTH: 3,
  15. };
  16. /**
  17. * Check if a variable should be included in the vertex shader.
  18. *
  19. * @param {ShaderDestination} destination The ShaderDestination to check
  20. * @return {boolean} <code>true</code> if the variable appears in the vertex shader, or <code>false</code> otherwise
  21. * @private
  22. */
  23. ShaderDestination.includesVertexShader = function (destination) {
  24. //>>includeStart('debug', pragmas.debug);
  25. Check.typeOf.number("destination", destination);
  26. //>>includeEnd('debug');
  27. return (destination & ShaderDestination.VERTEX) !== 0;
  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 (destination & ShaderDestination.FRAGMENT) !== 0;
  42. };
  43. /**
  44. * Compute the union of multiple ShaderDestinations (e.g., VERTEX | FRAGMENT yields BOTH)
  45. * @param {...ShaderDestination} destinations
  46. * @returns {ShaderDestination} The union of the provided destinations
  47. * @private
  48. */
  49. ShaderDestination.union = function (...destinations) {
  50. //>>includeStart('debug', pragmas.debug);
  51. if (destinations.length === 0) {
  52. throw new DeveloperError(
  53. "ShaderDestination.union requires at least one destination.",
  54. );
  55. }
  56. //>>includeEnd('debug');
  57. let result = 0;
  58. for (let i = 0; i < destinations.length; i++) {
  59. result |= destinations[i];
  60. }
  61. return result;
  62. };
  63. /**
  64. * Compute the intersection of multiple ShaderDestinations (e.g., VERTEX & FRAGMENT yields NONE)
  65. * @param {...ShaderDestination} destinations
  66. * @returns {ShaderDestination} The intersection of the provided destinations
  67. * @private
  68. */
  69. ShaderDestination.intersection = function (...destinations) {
  70. //>>includeStart('debug', pragmas.debug);
  71. if (destinations.length === 0) {
  72. throw new DeveloperError(
  73. "ShaderDestination.intersection requires at least one destination.",
  74. );
  75. }
  76. //>>includeEnd('debug');
  77. let result = destinations[0];
  78. for (let i = 1; i < destinations.length; i++) {
  79. result &= destinations[i];
  80. }
  81. return result;
  82. };
  83. Object.freeze(ShaderDestination);
  84. export default ShaderDestination;