NodeSampledTexture.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { SampledTexture } from '../SampledTexture.js';
  2. class NodeSampledTexture extends SampledTexture {
  3. constructor( name, textureNode, groupNode, access = null ) {
  4. super( name, textureNode ? textureNode.value : null );
  5. this.textureNode = textureNode;
  6. this.groupNode = groupNode;
  7. this.access = access;
  8. }
  9. get needsBindingsUpdate() {
  10. return this.textureNode.value !== this.texture || super.needsBindingsUpdate;
  11. }
  12. update() {
  13. const { textureNode } = this;
  14. if ( this.texture !== textureNode.value ) {
  15. this.texture = textureNode.value;
  16. return true;
  17. }
  18. return super.update();
  19. }
  20. }
  21. class NodeSampledCubeTexture extends NodeSampledTexture {
  22. constructor( name, textureNode, groupNode, access ) {
  23. super( name, textureNode, groupNode, access );
  24. this.isSampledCubeTexture = true;
  25. }
  26. }
  27. class NodeSampledTexture3D extends NodeSampledTexture {
  28. constructor( name, textureNode, groupNode, access ) {
  29. super( name, textureNode, groupNode, access );
  30. this.isSampledTexture3D = true;
  31. }
  32. }
  33. export { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D };