MaxMIPLevelNode.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { FloatNode } from '../inputs/FloatNode.js';
  5. function MaxMIPLevelNode( texture ) {
  6. FloatNode.call( this );
  7. this.texture = texture;
  8. this.maxMIPLevel = 0;
  9. };
  10. MaxMIPLevelNode.prototype = Object.create( FloatNode.prototype );
  11. MaxMIPLevelNode.prototype.constructor = MaxMIPLevelNode;
  12. MaxMIPLevelNode.prototype.nodeType = "MaxMIPLevel";
  13. Object.defineProperties( MaxMIPLevelNode.prototype, {
  14. value: {
  15. get: function () {
  16. if ( this.maxMIPLevel === 0 ) {
  17. var image = this.texture.value.image ? this.texture.value.image[0] : undefined;
  18. this.maxMIPLevel = image !== undefined ? Math.log( Math.max( image.width, image.height ) ) * Math.LOG2E : 0;
  19. }
  20. return this.maxMIPLevel;
  21. },
  22. set: function () { }
  23. }
  24. } );
  25. MaxMIPLevelNode.prototype.toJSON = function ( meta ) {
  26. var data = this.getJSONNode( meta );
  27. if ( ! data ) {
  28. data = this.createJSONNode( meta );
  29. data.texture = this.texture.uuid;
  30. }
  31. return data;
  32. };
  33. export { MaxMIPLevelNode };