Texture.js 1.8 KB

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