MaxMipLevelNode.js 560 B

1234567891011121314151617181920212223242526272829303132
  1. import UniformNode from '../core/UniformNode.js';
  2. import { NodeUpdateType } from '../core/constants.js';
  3. class MaxMipLevelNode extends UniformNode {
  4. constructor( texture ) {
  5. super( 0 );
  6. this.texture = texture;
  7. this.updateType = NodeUpdateType.Frame;
  8. }
  9. update() {
  10. const { width, height } = this.texture.images ? this.texture.images[ 0 ] : this.texture.image;
  11. this.value = Math.log( Math.max( width, height ) ) * Math.LOG2E;
  12. if ( this.value > 0 ) {
  13. this.updateType = NodeUpdateType.None;
  14. }
  15. }
  16. }
  17. export default MaxMipLevelNode;