Texture.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.uuid = THREE.Math.generateUUID();
  9. this.name = '';
  10. this.image = image;
  11. this.mipmaps = [];
  12. this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
  13. this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
  14. this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;
  15. this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
  16. this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;
  17. this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
  18. this.format = format !== undefined ? format : THREE.RGBAFormat;
  19. this.type = type !== undefined ? type : THREE.UnsignedByteType;
  20. this.offset = new THREE.Vector2( 0, 0 );
  21. this.repeat = new THREE.Vector2( 1, 1 );
  22. this.generateMipmaps = true;
  23. this.premultiplyAlpha = false;
  24. this.flipY = true;
  25. this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
  26. this.needsUpdate = false;
  27. this.onUpdate = null;
  28. };
  29. THREE.Texture.prototype = {
  30. constructor: THREE.Texture,
  31. clone: function ( texture ) {
  32. if ( texture === undefined ) texture = new THREE.Texture();
  33. texture.image = this.image;
  34. texture.mipmaps = this.mipmaps.slice(0);
  35. texture.mapping = this.mapping;
  36. texture.wrapS = this.wrapS;
  37. texture.wrapT = this.wrapT;
  38. texture.magFilter = this.magFilter;
  39. texture.minFilter = this.minFilter;
  40. texture.anisotropy = this.anisotropy;
  41. texture.format = this.format;
  42. texture.type = this.type;
  43. texture.offset.copy( this.offset );
  44. texture.repeat.copy( this.repeat );
  45. texture.generateMipmaps = this.generateMipmaps;
  46. texture.premultiplyAlpha = this.premultiplyAlpha;
  47. texture.flipY = this.flipY;
  48. texture.unpackAlignment = this.unpackAlignment;
  49. return texture;
  50. },
  51. dispose: function () {
  52. this.dispatchEvent( { type: 'dispose' } );
  53. }
  54. };
  55. THREE.EventDispatcher.prototype.apply( THREE.Texture.prototype );
  56. THREE.TextureIdCount = 0;