source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/src/materials/Material.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 */
5
6THREE.Material = function () {
7
8 this.id = THREE.MaterialIdCount ++;
9 this.uuid = THREE.Math.generateUUID();
10
11 this.name = '';
12
13 this.side = THREE.FrontSide;
14
15 this.opacity = 1;
16 this.transparent = false;
17
18 this.blending = THREE.NormalBlending;
19
20 this.blendSrc = THREE.SrcAlphaFactor;
21 this.blendDst = THREE.OneMinusSrcAlphaFactor;
22 this.blendEquation = THREE.AddEquation;
23
24 this.depthTest = true;
25 this.depthWrite = true;
26
27 this.polygonOffset = false;
28 this.polygonOffsetFactor = 0;
29 this.polygonOffsetUnits = 0;
30
31 this.alphaTest = 0;
32
33 this.overdraw = 0; // Overdrawn pixels (typically between 0 and 1) for fixing antialiasing gaps in CanvasRenderer
34
35 this.visible = true;
36
37 this.needsUpdate = true;
38
39};
40
41THREE.Material.prototype = {
42
43 constructor: THREE.Material,
44
45 setValues: function ( values ) {
46
47 if ( values === undefined ) return;
48
49 for ( var key in values ) {
50
51 var newValue = values[ key ];
52
53 if ( newValue === undefined ) {
54
55 console.warn( 'THREE.Material: \'' + key + '\' parameter is undefined.' );
56 continue;
57
58 }
59
60 if ( key in this ) {
61
62 var currentValue = this[ key ];
63
64 if ( currentValue instanceof THREE.Color ) {
65
66 currentValue.set( newValue );
67
68 } else if ( currentValue instanceof THREE.Vector3 && newValue instanceof THREE.Vector3 ) {
69
70 currentValue.copy( newValue );
71
72 } else if ( key == 'overdraw') {
73
74 // ensure overdraw is backwards-compatable with legacy boolean type
75 this[ key ] = Number(newValue);
76
77 } else {
78
79 this[ key ] = newValue;
80
81 }
82
83 }
84
85 }
86
87 },
88
89 clone: function ( material ) {
90
91 if ( material === undefined ) material = new THREE.Material();
92
93 material.name = this.name;
94
95 material.side = this.side;
96
97 material.opacity = this.opacity;
98 material.transparent = this.transparent;
99
100 material.blending = this.blending;
101
102 material.blendSrc = this.blendSrc;
103 material.blendDst = this.blendDst;
104 material.blendEquation = this.blendEquation;
105
106 material.depthTest = this.depthTest;
107 material.depthWrite = this.depthWrite;
108
109 material.polygonOffset = this.polygonOffset;
110 material.polygonOffsetFactor = this.polygonOffsetFactor;
111 material.polygonOffsetUnits = this.polygonOffsetUnits;
112
113 material.alphaTest = this.alphaTest;
114
115 material.overdraw = this.overdraw;
116
117 material.visible = this.visible;
118
119 return material;
120
121 },
122
123 dispose: function () {
124
125 this.dispatchEvent( { type: 'dispose' } );
126
127 }
128
129};
130
131THREE.EventDispatcher.prototype.apply( THREE.Material.prototype );
132
133THREE.MaterialIdCount = 0;
Note: See TracBrowser for help on using the repository browser.