Texture.js 1.6 KB
Newer Older
M
Mr.doob 已提交
1
/**
M
Mr.doob 已提交
2
 * @author mrdoob / http://mrdoob.com/
3
 * @author alteredq / http://alteredqualia.com/
4
 * @author szimek / https://github.com/szimek/
M
Mr.doob 已提交
5 6
 */

7
THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
M
Mr.doob 已提交
8

M
Mr.doob 已提交
9 10
	this.id = THREE.TextureCount ++;

M
Mr.doob 已提交
11
	this.image = image;
12

M
Mr.doob 已提交
13
	this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
14

15 16
	this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
	this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;
M
Mr.doob 已提交
17

18 19
	this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
	this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;
20

21 22
	this.anisotropy = anisotropy !== undefined ? anisotropy : 1;

23 24 25
	this.format = format !== undefined ? format : THREE.RGBAFormat;
	this.type = type !== undefined ? type : THREE.UnsignedByteType;

26
	this.offset = new THREE.Vector2( 0, 0 );
27 28
	this.repeat = new THREE.Vector2( 1, 1 );

29
	this.generateMipmaps = true;
30
	this.premultiplyAlpha = false;
31
	this.flipY = true;
32

A
alteredq 已提交
33
	this.needsUpdate = false;
34
	this.onUpdate = null;
35

M
Mr.doob 已提交
36 37 38 39
};

THREE.Texture.prototype = {

40 41
	constructor: THREE.Texture,

42 43
	clone: function () {

44
		var clonedTexture = new THREE.Texture( this.image, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter, this.format, this.type, this.anisotropy );
45 46 47 48

		clonedTexture.offset.copy( this.offset );
		clonedTexture.repeat.copy( this.repeat );

49 50 51 52
		clonedTexture.generateMipmaps = this.generateMipmaps;
		clonedTexture.premultiplyAlpha = this.premultiplyAlpha;
		clonedTexture.flipY = this.flipY;

53
		return clonedTexture;
54

55
	}
M
Mr.doob 已提交
56 57

};
M
Mr.doob 已提交
58

M
Mr.doob 已提交
59
THREE.TextureCount = 0;