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

Sampler.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import Check from "../Core/Check.js";
  2. import Frozen from "../Core/Frozen.js";
  3. import defined from "../Core/defined.js";
  4. import DeveloperError from "../Core/DeveloperError.js";
  5. import TextureMagnificationFilter from "./TextureMagnificationFilter.js";
  6. import TextureMinificationFilter from "./TextureMinificationFilter.js";
  7. import TextureWrap from "./TextureWrap.js";
  8. /**
  9. * @private
  10. */
  11. function Sampler(options) {
  12. options = options ?? Frozen.EMPTY_OBJECT;
  13. const {
  14. wrapR = TextureWrap.CLAMP_TO_EDGE,
  15. wrapS = TextureWrap.CLAMP_TO_EDGE,
  16. wrapT = TextureWrap.CLAMP_TO_EDGE,
  17. minificationFilter = TextureMinificationFilter.LINEAR,
  18. magnificationFilter = TextureMagnificationFilter.LINEAR,
  19. maximumAnisotropy = 1.0,
  20. } = options;
  21. //>>includeStart('debug', pragmas.debug);
  22. if (!TextureWrap.validate(wrapR)) {
  23. throw new DeveloperError("Invalid sampler.wrapR.");
  24. }
  25. if (!TextureWrap.validate(wrapS)) {
  26. throw new DeveloperError("Invalid sampler.wrapS.");
  27. }
  28. if (!TextureWrap.validate(wrapT)) {
  29. throw new DeveloperError("Invalid sampler.wrapT.");
  30. }
  31. if (!TextureMinificationFilter.validate(minificationFilter)) {
  32. throw new DeveloperError("Invalid sampler.minificationFilter.");
  33. }
  34. if (!TextureMagnificationFilter.validate(magnificationFilter)) {
  35. throw new DeveloperError("Invalid sampler.magnificationFilter.");
  36. }
  37. Check.typeOf.number.greaterThanOrEquals(
  38. "maximumAnisotropy",
  39. maximumAnisotropy,
  40. 1.0,
  41. );
  42. //>>includeEnd('debug');
  43. this._wrapR = wrapR;
  44. this._wrapS = wrapS;
  45. this._wrapT = wrapT;
  46. this._minificationFilter = minificationFilter;
  47. this._magnificationFilter = magnificationFilter;
  48. this._maximumAnisotropy = maximumAnisotropy;
  49. }
  50. Object.defineProperties(Sampler.prototype, {
  51. wrapR: {
  52. get: function () {
  53. return this._wrapR;
  54. },
  55. },
  56. wrapS: {
  57. get: function () {
  58. return this._wrapS;
  59. },
  60. },
  61. wrapT: {
  62. get: function () {
  63. return this._wrapT;
  64. },
  65. },
  66. minificationFilter: {
  67. get: function () {
  68. return this._minificationFilter;
  69. },
  70. },
  71. magnificationFilter: {
  72. get: function () {
  73. return this._magnificationFilter;
  74. },
  75. },
  76. maximumAnisotropy: {
  77. get: function () {
  78. return this._maximumAnisotropy;
  79. },
  80. },
  81. });
  82. Sampler.equals = function (left, right) {
  83. return (
  84. left === right ||
  85. (defined(left) &&
  86. defined(right) &&
  87. left._wrapR === right._wrapR &&
  88. left._wrapS === right._wrapS &&
  89. left._wrapT === right._wrapT &&
  90. left._minificationFilter === right._minificationFilter &&
  91. left._magnificationFilter === right._magnificationFilter &&
  92. left._maximumAnisotropy === right._maximumAnisotropy)
  93. );
  94. };
  95. Sampler.NEAREST = Object.freeze(
  96. new Sampler({
  97. wrapR: TextureWrap.CLAMP_TO_EDGE,
  98. wrapS: TextureWrap.CLAMP_TO_EDGE,
  99. wrapT: TextureWrap.CLAMP_TO_EDGE,
  100. minificationFilter: TextureMinificationFilter.NEAREST,
  101. magnificationFilter: TextureMagnificationFilter.NEAREST,
  102. }),
  103. );
  104. export default Sampler;