Texture.js 1.4 KB
Newer Older
M
Mr.doob 已提交
1 2
/**
 * @author mr.doob / 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 ) {
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 23
	this.format = format !== undefined ? format : THREE.RGBAFormat;
	this.type = type !== undefined ? type : THREE.UnsignedByteType;

24
	this.offset = new THREE.Vector2( 0, 0 );
25 26
	this.repeat = new THREE.Vector2( 1, 1 );

27
	this.generateMipmaps = true;
28
	this.premultiplyAlpha = false;
29
	this.flipY = true;
30

A
alteredq 已提交
31
	this.needsUpdate = false;
32
	this.onUpdate = null;
33

M
Mr.doob 已提交
34 35 36 37
};

THREE.Texture.prototype = {

38 39
	constructor: THREE.Texture,

40 41
	clone: function () {

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

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

		return clonedTexture;
48

49
	}
M
Mr.doob 已提交
50 51

};
M
Mr.doob 已提交
52

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