Texture.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.TextureLib.length;
  8. THREE.TextureLib.push( this );
  9. this.image = image;
  10. this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
  11. this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
  12. this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;
  13. this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
  14. this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;
  15. this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
  16. this.format = format !== undefined ? format : THREE.RGBAFormat;
  17. this.type = type !== undefined ? type : THREE.UnsignedByteType;
  18. this.offset = new THREE.Vector2( 0, 0 );
  19. this.repeat = new THREE.Vector2( 1, 1 );
  20. this.generateMipmaps = true;
  21. this.premultiplyAlpha = false;
  22. this.flipY = true;
  23. this.needsUpdate = false;
  24. this.onUpdate = null;
  25. };
  26. THREE.Texture.prototype = {
  27. constructor: THREE.Texture,
  28. clone: function () {
  29. var texture = new THREE.Texture();
  30. texture.image = this.image;
  31. texture.mapping = this.mapping;
  32. texture.wrapS = this.wrapS;
  33. texture.wrapT = this.wrapT;
  34. texture.magFilter = this.magFilter;
  35. texture.minFilter = this.minFilter;
  36. texture.anisotropy = this.anisotropy;
  37. texture.format = this.format;
  38. texture.type = this.type;
  39. texture.offset.copy( this.offset );
  40. texture.repeat.copy( this.repeat );
  41. texture.generateMipmaps = this.generateMipmaps;
  42. texture.premultiplyAlpha = this.premultiplyAlpha;
  43. texture.flipY = this.flipY;
  44. return texture;
  45. },
  46. deallocate: function () {
  47. THREE.TextureLib[ this.id ] = null;
  48. }
  49. };
  50. THREE.TextureLib = [];
粤ICP备19079148号