source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/src/textures/Texture.js@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 2.5 KB
Line 
1/**
2 * @author mrdoob / http://mrdoob.com/
3 * @author alteredq / http://alteredqualia.com/
4 * @author szimek / https://github.com/szimek/
5 */
6
7THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
8
9 this.id = THREE.TextureIdCount ++;
10 this.uuid = THREE.Math.generateUUID();
11
12 this.name = '';
13
14 this.image = image;
15 this.mipmaps = [];
16
17 this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
18
19 this.wrapS = wrapS !== undefined ? wrapS : THREE.ClampToEdgeWrapping;
20 this.wrapT = wrapT !== undefined ? wrapT : THREE.ClampToEdgeWrapping;
21
22 this.magFilter = magFilter !== undefined ? magFilter : THREE.LinearFilter;
23 this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;
24
25 this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
26
27 this.format = format !== undefined ? format : THREE.RGBAFormat;
28 this.type = type !== undefined ? type : THREE.UnsignedByteType;
29
30 this.offset = new THREE.Vector2( 0, 0 );
31 this.repeat = new THREE.Vector2( 1, 1 );
32
33 this.generateMipmaps = true;
34 this.premultiplyAlpha = false;
35 this.flipY = true;
36 this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
37
38 this._needsUpdate = false;
39 this.onUpdate = null;
40
41};
42
43THREE.Texture.prototype = {
44
45 constructor: THREE.Texture,
46
47 get needsUpdate () {
48
49 return this._needsUpdate;
50
51 },
52
53 set needsUpdate ( value ) {
54
55 if ( value === true ) this.update();
56
57 this._needsUpdate = value;
58
59 },
60
61 clone: function ( texture ) {
62
63 if ( texture === undefined ) texture = new THREE.Texture();
64
65 texture.image = this.image;
66 texture.mipmaps = this.mipmaps.slice(0);
67
68 texture.mapping = this.mapping;
69
70 texture.wrapS = this.wrapS;
71 texture.wrapT = this.wrapT;
72
73 texture.magFilter = this.magFilter;
74 texture.minFilter = this.minFilter;
75
76 texture.anisotropy = this.anisotropy;
77
78 texture.format = this.format;
79 texture.type = this.type;
80
81 texture.offset.copy( this.offset );
82 texture.repeat.copy( this.repeat );
83
84 texture.generateMipmaps = this.generateMipmaps;
85 texture.premultiplyAlpha = this.premultiplyAlpha;
86 texture.flipY = this.flipY;
87 texture.unpackAlignment = this.unpackAlignment;
88
89 return texture;
90
91 },
92
93 update: function () {
94
95 this.dispatchEvent( { type: 'update' } );
96
97 },
98
99 dispose: function () {
100
101 this.dispatchEvent( { type: 'dispose' } );
102
103 }
104
105};
106
107THREE.EventDispatcher.prototype.apply( THREE.Texture.prototype );
108
109THREE.TextureIdCount = 0;
Note: See TracBrowser for help on using the repository browser.