SampledTexture.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import Sampler from './Sampler.js';
  2. let _id = 0;
  3. /**
  4. * Represents a sampled texture binding type.
  5. *
  6. * @private
  7. * @augments Sampler
  8. */
  9. class SampledTexture extends Sampler {
  10. /**
  11. * Constructs a new sampled texture.
  12. *
  13. * @param {string} name - The sampled texture's name.
  14. * @param {?Texture} texture - The texture this binding is referring to.
  15. */
  16. constructor( name, texture ) {
  17. super( name, texture );
  18. /**
  19. * This identifier.
  20. *
  21. * @type {number}
  22. */
  23. this.id = _id ++;
  24. /**
  25. * Whether the texture is a storage texture or not.
  26. *
  27. * @type {boolean}
  28. * @default false
  29. */
  30. this.store = false;
  31. /**
  32. * This flag can be used for type testing.
  33. *
  34. * @type {boolean}
  35. * @readonly
  36. * @default true
  37. */
  38. this.isSampledTexture = true;
  39. }
  40. }
  41. /**
  42. * Represents a sampled array texture binding type.
  43. *
  44. * @private
  45. * @augments SampledTexture
  46. */
  47. class SampledArrayTexture extends SampledTexture {
  48. /**
  49. * Constructs a new sampled array texture.
  50. *
  51. * @param {string} name - The sampled array texture's name.
  52. * @param {?(DataArrayTexture|CompressedArrayTexture)} texture - The texture this binding is referring to.
  53. */
  54. constructor( name, texture ) {
  55. super( name, texture );
  56. /**
  57. * This flag can be used for type testing.
  58. *
  59. * @type {boolean}
  60. * @readonly
  61. * @default true
  62. */
  63. this.isSampledArrayTexture = true;
  64. }
  65. }
  66. /**
  67. * Represents a sampled 3D texture binding type.
  68. *
  69. * @private
  70. * @augments SampledTexture
  71. */
  72. class Sampled3DTexture extends SampledTexture {
  73. /**
  74. * Constructs a new sampled 3D texture.
  75. *
  76. * @param {string} name - The sampled 3D texture's name.
  77. * @param {?Data3DTexture} texture - The texture this binding is referring to.
  78. */
  79. constructor( name, texture ) {
  80. super( name, texture );
  81. /**
  82. * This flag can be used for type testing.
  83. *
  84. * @type {boolean}
  85. * @readonly
  86. * @default true
  87. */
  88. this.isSampled3DTexture = true;
  89. }
  90. }
  91. /**
  92. * Represents a sampled cube texture binding type.
  93. *
  94. * @private
  95. * @augments SampledTexture
  96. */
  97. class SampledCubeTexture extends SampledTexture {
  98. /**
  99. * Constructs a new sampled cube texture.
  100. *
  101. * @param {string} name - The sampled cube texture's name.
  102. * @param {?(CubeTexture|CompressedCubeTexture)} texture - The texture this binding is referring to.
  103. */
  104. constructor( name, texture ) {
  105. super( name, texture );
  106. /**
  107. * This flag can be used for type testing.
  108. *
  109. * @type {boolean}
  110. * @readonly
  111. * @default true
  112. */
  113. this.isSampledCubeTexture = true;
  114. }
  115. }
  116. export { SampledTexture, SampledArrayTexture, Sampled3DTexture, SampledCubeTexture };
粤ICP备19079148号