Texture.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. clone: function ( texture ) {
  31. if ( texture === undefined ) texture = new THREE.Texture();
  32. texture.image = this.image;
  33. texture.mipmaps = this.mipmaps.slice(0);
  34. texture.mapping = this.mapping;
  35. texture.wrapS = this.wrapS;
  36. texture.wrapT = this.wrapT;
  37. texture.magFilter = this.magFilter;
  38. texture.minFilter = this.minFilter;
  39. texture.anisotropy = this.anisotropy;
  40. texture.format = this.format;
  41. texture.type = this.type;
  42. texture.offset.copy( this.offset );
  43. texture.repeat.copy( this.repeat );
  44. texture.generateMipmaps = this.generateMipmaps;
  45. texture.premultiplyAlpha = this.premultiplyAlpha;
  46. texture.flipY = this.flipY;
  47. texture.unpackAlignment = this.unpackAlignment;
  48. return texture;
  49. }
  50. };
  51. THREE.TextureIdCount = 0;