Texture.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. * @author szimek / https://github.com/szimek/
  5. */
  6. THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
  7. this.id = THREE.TextureIdCount ++;
  8. this.name = '';
  9. this.image = image;
  10. this.mipmaps = [];
  11. this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
  12. this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
  13. this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;
  14. this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
  15. this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;
  16. this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
  17. this.format = format !== undefined ? format : THREE.RGBAFormat;
  18. this.type = type !== undefined ? type : THREE.UnsignedByteType;
  19. this.offset = new THREE.Vector2( 0, 0 );
  20. this.repeat = new THREE.Vector2( 1, 1 );
  21. this.generateMipmaps = true;
  22. this.premultiplyAlpha = false;
  23. this.flipY = true;
  24. this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
  25. this.needsUpdate = false;
  26. this.onUpdate = null;
  27. };
  28. THREE.Texture.prototype = {
  29. constructor: THREE.Texture,
  30. addEventListener: THREE.EventDispatcher.prototype.addEventListener,
  31. hasEventListener: THREE.EventDispatcher.prototype.hasEventListener,
  32. removeEventListener: THREE.EventDispatcher.prototype.removeEventListener,
  33. dispatchEvent: THREE.EventDispatcher.prototype.dispatchEvent,
  34. clone: function ( texture ) {
  35. if ( texture === undefined ) texture = new THREE.Texture();
  36. texture.image = this.image;
  37. texture.mipmaps = this.mipmaps.slice(0);
  38. texture.mapping = this.mapping;
  39. texture.wrapS = this.wrapS;
  40. texture.wrapT = this.wrapT;
  41. texture.magFilter = this.magFilter;
  42. texture.minFilter = this.minFilter;
  43. texture.anisotropy = this.anisotropy;
  44. texture.format = this.format;
  45. texture.type = this.type;
  46. texture.offset.copy( this.offset );
  47. texture.repeat.copy( this.repeat );
  48. texture.generateMipmaps = this.generateMipmaps;
  49. texture.premultiplyAlpha = this.premultiplyAlpha;
  50. texture.flipY = this.flipY;
  51. texture.unpackAlignment = this.unpackAlignment;
  52. return texture;
  53. },
  54. dispose: function () {
  55. this.dispatchEvent( { type: 'dispose' } );
  56. }
  57. };
  58. THREE.TextureIdCount = 0;
粤ICP备19079148号