SampledTexture.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. const { texture, version } = this;
  18. if ( version !== texture.version ) {
  19. this.version = texture.version;
  20. return true;
  21. }
  22. return false;
  23. }
  24. }
  25. class SampledArrayTexture extends SampledTexture {
  26. constructor( name, texture ) {
  27. super( name, texture );
  28. this.isSampledArrayTexture = true;
  29. }
  30. }
  31. class Sampled3DTexture extends SampledTexture {
  32. constructor( name, texture ) {
  33. super( name, texture );
  34. this.isSampled3DTexture = true;
  35. }
  36. }
  37. class SampledCubeTexture extends SampledTexture {
  38. constructor( name, texture ) {
  39. super( name, texture );
  40. this.isSampledCubeTexture = true;
  41. }
  42. }
  43. export { SampledTexture, SampledArrayTexture, Sampled3DTexture, SampledCubeTexture };