MaxMIPLevelNode.js 779 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { FloatNode } from '../inputs/FloatNode.js';
  2. class MaxMIPLevelNode extends FloatNode {
  3. constructor( texture ) {
  4. super();
  5. this.texture = texture;
  6. this.maxMIPLevel = 0;
  7. }
  8. get value() {
  9. if ( this.maxMIPLevel === 0 ) {
  10. var image = this.texture.value.image;
  11. if ( Array.isArray( image ) ) image = image[ 0 ];
  12. this.maxMIPLevel = image !== undefined ? Math.log( Math.max( image.width, image.height ) ) * Math.LOG2E : 0;
  13. }
  14. return this.maxMIPLevel;
  15. }
  16. set value( val ) {
  17. }
  18. toJSON( meta ) {
  19. let data = this.getJSONNode( meta );
  20. if ( ! data ) {
  21. data = this.createJSONNode( meta );
  22. data.texture = this.texture.uuid;
  23. }
  24. return data;
  25. }
  26. }
  27. MaxMIPLevelNode.prototype.nodeType = 'MaxMIPLevel';
  28. export { MaxMIPLevelNode };