SampledTexture.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import Binding from './Binding.js';
  2. let id = 0;
  3. class SampledTexture extends Binding {
  4. constructor( name, texture ) {
  5. super( name );
  6. this.id = id ++;
  7. this.texture = texture;
  8. this.version = texture ? texture.version : 0;
  9. this.store = false;
  10. this.isSampledTexture = true;
  11. }
  12. get needsBindingsUpdate() {
  13. const { texture, version } = this;
  14. return texture.isVideoTexture ? true : version !== texture.version; // @TODO: version === 0 && texture.version > 0 ( add it just to External Textures like PNG,JPG )
  15. }
  16. update() {
  17. if ( this.version !== this.texture.version ) {
  18. this.version = this.texture.version;
  19. return true;
  20. }
  21. return false;
  22. }
  23. }
  24. class SampledArrayTexture extends SampledTexture {
  25. constructor( name, texture ) {
  26. super( name, texture );
  27. this.isSampledArrayTexture = true;
  28. }
  29. }
  30. class Sampled3DTexture extends SampledTexture {
  31. constructor( name, texture ) {
  32. super( name, texture );
  33. this.isSampled3DTexture = true;
  34. }
  35. }
  36. class SampledCubeTexture extends SampledTexture {
  37. constructor( name, texture ) {
  38. super( name, texture );
  39. this.isSampledCubeTexture = true;
  40. }
  41. }
  42. export { SampledTexture, SampledArrayTexture, Sampled3DTexture, SampledCubeTexture };