aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/linear-gradient-material.js
diff options
context:
space:
mode:
authorJonathan Duran2012-05-24 09:35:02 -0700
committerJonathan Duran2012-05-24 09:35:02 -0700
commit458714f5bf2ab095f6e96dfec3f9ff7042527c04 (patch)
tree779ba55d14f059572cb81d27024ca8b8a92956e0 /js/lib/rdge/materials/linear-gradient-material.js
parent2e4831cf0fe04f37a179f84b098ae0899d4e40b8 (diff)
parent862ee363584dfba4bdd9abacbc3a3244c7ec66b5 (diff)
downloadninja-458714f5bf2ab095f6e96dfec3f9ff7042527c04.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/lib/rdge/materials/linear-gradient-material.js')
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js36
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
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; 7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material; 8var Material = require("js/lib/rdge/materials/material").Material;
9var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive;
9 10
10var LinearGradientMaterial = function LinearGradientMaterial() { 11var 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 },