diff options
author | Jose Antonio Marquez | 2012-05-22 18:02:36 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-22 18:02:36 -0700 |
commit | 27e6e1238ec1adb34aa396074e2559801c7e4314 (patch) | |
tree | d27f27fd071d9df575c6014eed0efee252ff0390 /js/lib/rdge/materials/linear-gradient-material.js | |
parent | 75fe4f36a6768d688792bc1925cfa4bfa508ac3e (diff) | |
parent | a341522e3603c18ab3b93defa894e3be702dd0f4 (diff) | |
download | ninja-27e6e1238ec1adb34aa396074e2559801c7e4314.tar.gz |
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'js/lib/rdge/materials/linear-gradient-material.js')
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js index 51a7430c..9b331fa7 100755 --- a/js/lib/rdge/materials/linear-gradient-material.js +++ b/js/lib/rdge/materials/linear-gradient-material.js | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; | 7 | var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; |
8 | var Material = require("js/lib/rdge/materials/material").Material; | 8 | var Material = require("js/lib/rdge/materials/material").Material; |
9 | var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; | ||
9 | 10 | ||
10 | var LinearGradientMaterial = function LinearGradientMaterial() { | 11 | var LinearGradientMaterial = function LinearGradientMaterial() { |
11 | /////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////// |
@@ -25,6 +26,8 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
25 | // this._colorCount = 4; | 26 | // this._colorCount = 4; |
26 | this._angle = 0.0; // the shader takes [cos(a), sin(a)] | 27 | this._angle = 0.0; // the shader takes [cos(a), sin(a)] |
27 | 28 | ||
29 | this._textureTransform = [1,0,0, 0,1,0, 0,0,1]; | ||
30 | |||
28 | /////////////////////////////////////////////////////////////////////// | 31 | /////////////////////////////////////////////////////////////////////// |
29 | // Property Accessors | 32 | // Property Accessors |
30 | /////////////////////////////////////////////////////////////////////// | 33 | /////////////////////////////////////////////////////////////////////// |
@@ -132,12 +135,6 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
132 | } | 135 | } |
133 | }; | 136 | }; |
134 | 137 | ||
135 | // this.getColorCount = function() { return this._colorCount; }; | ||
136 | // this.setColorCount = function(c) { this._colorCount = c; | ||
137 | // if (this._shader && this._shader['default']) | ||
138 | // this._shader['default'].u_colorCount.set([c]); | ||
139 | // }; | ||
140 | |||
141 | this.getAngle = function () { | 138 | this.getAngle = function () { |
142 | return this._angle; | 139 | return this._angle; |
143 | }; | 140 | }; |
@@ -200,7 +197,21 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
200 | // Methods | 197 | // Methods |
201 | /////////////////////////////////////////////////////////////////////// | 198 | /////////////////////////////////////////////////////////////////////// |
202 | // duplcate method requirde | 199 | // duplcate method requirde |
203 | this.dup = function () { return new LinearGradientMaterial(); }; | 200 | this.dup = function () { |
201 | // allocate a new material | ||
202 | var newMat = new LinearGradientMaterial(); | ||
203 | |||
204 | // copy over the current values; | ||
205 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
206 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
207 | var n = propNames.length; | ||
208 | for (var i=0; i<n; i++) { | ||
209 | newMat.setProperty( propNames[i], propValues[i] ); | ||
210 | } | ||
211 | newMat._textureTransform = this._textureTransform.slice(); | ||
212 | |||
213 | return newMat; | ||
214 | }; | ||
204 | 215 | ||
205 | this.init = function (world) { | 216 | this.init = function (world) { |
206 | this.setWorld(world); | 217 | this.setWorld(world); |
@@ -245,7 +256,9 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
245 | this._shader['default'].u_colorStop4.set([s]); | 256 | this._shader['default'].u_colorStop4.set([s]); |
246 | 257 | ||
247 | this.setAngle(this.getAngle()); | 258 | this.setAngle(this.getAngle()); |
248 | } | 259 | |
260 | this._shader['default'].u_texTransform.set( this._textureTransform ); | ||
261 | } | ||
249 | }; | 262 | }; |
250 | 263 | ||
251 | this.exportJSON = function () { | 264 | this.exportJSON = function () { |
@@ -261,7 +274,8 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
261 | 'colorStop2': this.getColorStop2(), | 274 | 'colorStop2': this.getColorStop2(), |
262 | 'colorStop3': this.getColorStop3(), | 275 | 'colorStop3': this.getColorStop3(), |
263 | 'colorStop4': this.getColorStop4(), | 276 | 'colorStop4': this.getColorStop4(), |
264 | 'angle': this.getAngle() | 277 | 'angle': this.getAngle(), |
278 | 'textureTransform': this._textureTransform | ||
265 | }; | 279 | }; |
266 | 280 | ||
267 | return jObj; | 281 | return jObj; |
@@ -281,6 +295,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() { | |||
281 | colorStop3 = jObj.colorStop3, | 295 | colorStop3 = jObj.colorStop3, |
282 | colorStop4 = jObj.colorStop4, | 296 | colorStop4 = jObj.colorStop4, |
283 | angle = jObj.angle; | 297 | angle = jObj.angle; |
298 | this._textureTransform = jObj.textureTransform; | ||
284 | 299 | ||
285 | this.setProperty("color1", color1); | 300 | this.setProperty("color1", color1); |
286 | this.setProperty("color2", color2); | 301 | this.setProperty("color2", color2); |
@@ -367,7 +382,8 @@ var linearGradientMaterialDef = | |||
367 | 'u_colorStop2': { 'type' : 'float' }, | 382 | 'u_colorStop2': { 'type' : 'float' }, |
368 | 'u_colorStop3': { 'type' : 'float' }, | 383 | 'u_colorStop3': { 'type' : 'float' }, |
369 | 'u_colorStop4': { 'type' : 'float' }, | 384 | 'u_colorStop4': { 'type' : 'float' }, |
370 | 'u_cos_sin_angle' : { 'type' : 'vec2' } | 385 | 'u_cos_sin_angle': { 'type' : 'vec2' }, |
386 | 'u_texTransform': { 'type' : 'mat3' } | ||
371 | //'u_colorCount': {'type' : 'int' } | 387 | //'u_colorCount': {'type' : 'int' } |
372 | 388 | ||
373 | }, | 389 | }, |