2
0

MaxMIPLevelNode.js 995 B

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