diff options
author | Nivesh Rajbhandari | 2012-06-19 15:56:23 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-06-19 15:56:23 -0700 |
commit | 3ed06c2a55b1ae840334efeb47f7743944ecb3ca (patch) | |
tree | 0ad3e94248a1d4828386c8743a670c709357a470 /js/lib/rdge/materials/radial-gradient-material.js | |
parent | a0d18963d746e410511c29edd32bc1775d2d5851 (diff) | |
parent | 483ad57efcd6475776f580c3af5b60e6deeaf781 (diff) | |
download | ninja-3ed06c2a55b1ae840334efeb47f7743944ecb3ca.tar.gz |
Merge branch 'refs/heads/ninja-internal' into GIO_Fixes
Diffstat (limited to 'js/lib/rdge/materials/radial-gradient-material.js')
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 277 |
1 files changed, 29 insertions, 248 deletions
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js index b0b63cee..c9c2536f 100755 --- a/js/lib/rdge/materials/radial-gradient-material.js +++ b/js/lib/rdge/materials/radial-gradient-material.js | |||
@@ -12,201 +12,52 @@ var RadialGradientMaterial = function RadialGradientMaterial() { | |||
12 | /////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////// |
13 | // Instance variables | 13 | // Instance variables |
14 | /////////////////////////////////////////////////////////////////////// | 14 | /////////////////////////////////////////////////////////////////////// |
15 | this._name = "RadialGradientMaterial"; | 15 | this._name = "Radial Gradient"; |
16 | this._shaderName = "radialGradient"; | 16 | this._shaderName = "radialGradient"; |
17 | 17 | ||
18 | this._color1 = [1, 0, 0, 1]; | 18 | this._defaultColor1 = [1, 0, 0, 1]; |
19 | this._color2 = [0, 1, 0, 1]; | 19 | this._defaultColor2 = [0, 1, 0, 1]; |
20 | this._color3 = [0, 0, 1, 1]; | 20 | this._defaultColor3 = [0, 0, 1, 1]; |
21 | this._color4 = [0, 1, 1, 1]; | 21 | this._defaultColor4 = [0, 1, 1, 1]; |
22 | this._colorStop1 = 0.0; | 22 | this._defaultColorStop1 = 0.0; |
23 | this._colorStop2 = 0.3; | 23 | this._defaultColorStop2 = 0.3; |
24 | this._colorStop3 = 0.6; | 24 | this._defaultColorStop3 = 0.6; |
25 | this._colorStop4 = 1.0; | 25 | this._defaultColorStop4 = 1.0; |
26 | // this._colorCount = 4; | 26 | // this._defaultColorCount = 4; |
27 | 27 | ||
28 | this._textureTransform = [1,0,0, 0,1,0, 0,0,1]; | 28 | this._textureTransform = [1,0,0, 0,1,0, 0,0,1]; |
29 | 29 | ||
30 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
31 | // Property Accessors | 31 | // Property Accessors |
32 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
33 | this.getName = function () { | 33 | |
34 | return this._name; | ||
35 | }; | ||
36 | |||
37 | this.getShaderName = function () { | ||
38 | return this._shaderName; | ||
39 | }; | ||
40 | |||
41 | this.getColor1 = function () { | ||
42 | return this._color1; | ||
43 | }; | ||
44 | |||
45 | this.setColor1 = function (c) { | ||
46 | this._color1 = c.slice(); | ||
47 | if (this._shader && this._shader['default']) { | ||
48 | this._shader['default'].u_color1.set(c); | ||
49 | } | ||
50 | }; | ||
51 | |||
52 | this.getColor2 = function () { | ||
53 | return this._color2; | ||
54 | }; | ||
55 | |||
56 | this.setColor2 = function (c) { | ||
57 | this._color2 = c.slice(); | ||
58 | if (this._shader && this._shader['default']) { | ||
59 | this._shader['default'].u_color2.set(c); | ||
60 | } | ||
61 | |||
62 | }; | ||
63 | |||
64 | this.getColor3 = function () { | ||
65 | return this._color3; | ||
66 | }; | ||
67 | |||
68 | this.setColor3 = function (c) { | ||
69 | this._color3 = c.slice(); | ||
70 | if (this._shader && this._shader['default']) { | ||
71 | this._shader['default'].u_color3.set(c); | ||
72 | } | ||
73 | }; | ||
74 | |||
75 | this.getColor4 = function () { | ||
76 | return this._color4; | ||
77 | }; | ||
78 | |||
79 | this.setColor4 = function (c) { | ||
80 | this._color4 = c.slice(); | ||
81 | if (this._shader && this._shader['default']) { | ||
82 | this._shader['default'].u_color4.set(c); | ||
83 | } | ||
84 | }; | ||
85 | |||
86 | this.getColorStop1 = function () { | ||
87 | return this._colorStop1; | ||
88 | }; | ||
89 | |||
90 | this.setColorStop1 = function (s) { | ||
91 | this._colorStop1 = s; | ||
92 | if (this._shader && this._shader['default']) { | ||
93 | this._shader['default'].u_colorStop1.set([s]); | ||
94 | } | ||
95 | }; | ||
96 | |||
97 | this.getColorStop2 = function () { | ||
98 | return this._colorStop2; | ||
99 | }; | ||
100 | |||
101 | this.setColorStop2 = function (s) { | ||
102 | this._colorStop2 = s; | ||
103 | if (this._shader && this._shader['default']) { | ||
104 | this._shader['default'].u_colorStop2.set([s]); | ||
105 | } | ||
106 | }; | ||
107 | |||
108 | this.getColorStop3 = function () { | ||
109 | return this._colorStop3; | ||
110 | }; | ||
111 | |||
112 | this.setColorStop3 = function (s) { | ||
113 | this._colorStop3 = s; | ||
114 | if (this._shader && this._shader['default']) { | ||
115 | this._shader['default'].u_colorStop3.set([s]); | ||
116 | } | ||
117 | }; | ||
118 | |||
119 | this.getColorStop4 = function () { | ||
120 | return this._colorStop4; | ||
121 | }; | ||
122 | |||
123 | this.setColorStop4 = function (s) { | ||
124 | this._colorStop4 = s; | ||
125 | if (this._shader && this._shader['default']) { | ||
126 | this._shader['default'].u_colorStop4.set([s]); | ||
127 | } | ||
128 | }; | ||
129 | |||
130 | this.getColorCount = function () { | ||
131 | return this._colorCount; | ||
132 | }; | ||
133 | |||
134 | this.setColorCount = function (c) { | ||
135 | this._colorCount = c; | ||
136 | if (this._shader && this._shader['default']) { | ||
137 | this._shader['default'].u_colorCount.set([c]); | ||
138 | } | ||
139 | }; | ||
140 | |||
141 | this.isAnimated = function () { | ||
142 | return false; | ||
143 | }; | ||
144 | 34 | ||
35 | this.isAnimated = function () { return false; }; | ||
36 | this.getShaderDef = function() { return radialGradientMaterialDef; }; | ||
145 | 37 | ||
146 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
147 | // Material Property Accessors | 39 | // Material Property Accessors |
148 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
149 | this._propNames = ["color1", "color2", "color3", "color4", "colorStop1", "colorStop2", "colorStop3", "colorStop4" ]; | 41 | this._propNames = ["u_color1", "u_color2", "u_color3", "u_color4", "u_colorStop1", "u_colorStop2", "u_colorStop3", "u_colorStop4" ]; |
150 | this._propLabels = ["Color 1", "Color 2", "Color 3", "Color 4", "Color Stop 1", "Color Stop 2", "Color Stop 3", "Color Stop 4" ]; | 42 | this._propLabels = ["Color 1", "Color 2", "Color 3", "Color 4", "Color Stop 1", "Color Stop 2", "Color Stop 3", "Color Stop 4" ]; |
151 | this._propTypes = ["color", "color", "color", "color", "float", "float", "float", "float" ]; | 43 | this._propTypes = ["color", "color", "color", "color", "float", "float", "float", "float" ]; |
152 | this._propValues = []; | 44 | this._propValues = []; |
153 | 45 | ||
154 | this._propValues[this._propNames[0]] = this._color1.slice(0); | 46 | this._propValues[this._propNames[0]] = this._defaultColor1.slice(0); |
155 | this._propValues[this._propNames[1]] = this._color2.slice(0); | 47 | this._propValues[this._propNames[1]] = this._defaultColor2.slice(0); |
156 | this._propValues[this._propNames[2]] = this._color3.slice(0); | 48 | this._propValues[this._propNames[2]] = this._defaultColor3.slice(0); |
157 | this._propValues[this._propNames[3]] = this._color4.slice(0); | 49 | this._propValues[this._propNames[3]] = this._defaultColor4.slice(0); |
158 | |||
159 | this._propValues[this._propNames[4]] = this._colorStop1; | ||
160 | this._propValues[this._propNames[5]] = this._colorStop2; | ||
161 | this._propValues[this._propNames[6]] = this._colorStop3; | ||
162 | this._propValues[this._propNames[7]] = this._colorStop4; | ||
163 | 50 | ||
164 | this.setProperty = function (prop, value) { | 51 | this._propValues[this._propNames[4]] = this._defaultColorStop1; |
165 | if (prop === "color") prop = "color1"; | 52 | this._propValues[this._propNames[5]] = this._defaultColorStop2; |
166 | 53 | this._propValues[this._propNames[6]] = this._defaultColorStop3; | |
167 | // make sure we have legitimate imput | 54 | this._propValues[this._propNames[7]] = this._defaultColorStop4; |
168 | var ok = this.validateProperty(prop, value); | ||
169 | if (!ok) { | ||
170 | console.log("invalid property in Radial Gradient Material:" + prop + " : " + value); | ||
171 | } | ||
172 | |||
173 | switch (prop) { | ||
174 | case "color1": this.setColor1(value); break; | ||
175 | case "color2": this.setColor2(value); break; | ||
176 | case "color3": this.setColor3(value); break; | ||
177 | case "color4": this.setColor4(value); break; | ||
178 | case "colorStop1": this.setColorStop1(value); break; | ||
179 | case "colorStop2": this.setColorStop2(value); break; | ||
180 | case "colorStop3": this.setColorStop3(value); break; | ||
181 | case "colorStop4": this.setColorStop4(value); break; | ||
182 | case "angle": this.setAngle(value); break; | ||
183 | } | ||
184 | |||
185 | //this.updateValuesInShader(); | ||
186 | }; | ||
187 | /////////////////////////////////////////////////////////////////////// | 55 | /////////////////////////////////////////////////////////////////////// |
188 | 56 | ||
189 | 57 | ||
190 | /////////////////////////////////////////////////////////////// |