You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

33 lines
606 B

import UniformNode from '../core/UniformNode.js';
import { NodeUpdateType } from '../core/constants.js';
class MaxMipLevelNode extends UniformNode {
constructor( texture ) {
super( 0 );
this.texture = texture;
this.updateType = NodeUpdateType.FRAME;
}
update() {
const images = this.texture.images;
const image = ( images && images.length > 0 ) ? ( images[ 0 ]?.image || images[ 0 ] ) : this.texture.image;
if ( image?.width !== undefined ) {
const { width, height } = image;
this.value = Math.log2( Math.max( width, height ) );
}
}
}
export default MaxMipLevelNode;