aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/linear-gradient-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/linear-gradient-material.js')
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js46
1 files changed, 23 insertions, 23 deletions
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js
index 586948bb..2df76d61 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 ///////////////////////////////////////////////////////////////////////
@@ -136,12 +139,6 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
136 } 139 }
137 }; 140 };
138 141
139 // this.getColorCount = function() { return this._colorCount; };
140 // this.setColorCount = function(c) { this._colorCount = c;
141 // if (this._shader && this._shader['default'])
142 // this._shader['default'].u_colorCount.set([c]);
143 // };
144
145 this.getAngle = function () { 142 this.getAngle = function () {
146 return this._angle; 143 return this._angle;
147 }; 144 };
@@ -204,23 +201,21 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
204 // Methods 201 // Methods
205 /////////////////////////////////////////////////////////////////////// 202 ///////////////////////////////////////////////////////////////////////
206 // duplcate method requirde 203 // duplcate method requirde
207 this.dup = function () 204 this.dup = function () {
208 { 205 // allocate a new material
209 // get the current values; 206 var newMat = new LinearGradientMaterial();
210 var propNames = [], propValues = [], propTypes = [], propLabels = [];
211 this.getAllProperties(propNames, propValues, propTypes, propLabels);
212
213 // allocate a new material
214 var newMat = new LinearGradientMaterial();
215 207
216 // copy over the current values; 208 // copy over the current values;
217 var n = propNames.length; 209 var propNames = [], propValues = [], propTypes = [], propLabels = [];
218 for (var i = 0; i < n; i++) 210 this.getAllProperties( propNames, propValues, propTypes, propLabels);
219 newMat.setProperty(propNames[i], propValues[i]); 211 var n = propNames.length;
220 212 for (var i=0; i<n; i++) {
221 return newMat; 213 newMat.setProperty( propNames[i], propValues[i] );
222 } 214 }
215 newMat._textureTransform = this._textureTransform.slice();
223 216
217 return newMat;
218 };
224 219
225 this.init = function (world) { 220 this.init = function (world) {
226 this.setWorld(world); 221 this.setWorld(world);
@@ -265,7 +260,9 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
265 this._shader['default'].u_colorStop4.set([s]); 260 this._shader['default'].u_colorStop4.set([s]);
266 261
267 this.setAngle(this.getAngle()); 262 this.setAngle(this.getAngle());
268 } 263
264 this._shader['default'].u_texTransform.set( this._textureTransform );
265 }
269 }; 266 };
270 267
271 this.exportJSON = function () { 268 this.exportJSON = function () {
@@ -281,7 +278,8 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
281 'colorStop2': this.getColorStop2(), 278 'colorStop2': this.getColorStop2(),
282 'colorStop3': this.getColorStop3(), 279 'colorStop3': this.getColorStop3(),
283 'colorStop4': this.getColorStop4(), 280 'colorStop4': this.getColorStop4(),
284 'angle': this.getAngle() 281 'angle': this.getAngle(),
282 'textureTransform': this._textureTransform
285 }; 283 };
286 284
287 return jObj; 285 return jObj;
@@ -301,6 +299,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
301 colorStop3 = jObj.colorStop3, 299 colorStop3 = jObj.colorStop3,
302 colorStop4 = jObj.colorStop4, 300 colorStop4 = jObj.colorStop4,
303 angle = jObj.angle; 301 angle = jObj.angle;
302 this._textureTransform = jObj.textureTransform;
304 303
305 this.setProperty("color1", color1); 304 this.setProperty("color1", color1);
306 this.setProperty("color2", color2); 305 this.setProperty("color2", color2);
@@ -387,7 +386,8 @@ var linearGradientMaterialDef =
387 'u_colorStop2': { 'type' : 'float' }, 386 'u_colorStop2': { 'type' : 'float' },
388 'u_colorStop3': { 'type' : 'float' }, 387 'u_colorStop3': { 'type' : 'float' },
389 'u_colorStop4': { 'type' : 'float' }, 388 'u_colorStop4': { 'type' : 'float' },
390 'u_cos_sin_angle' : { 'type' : 'vec2' } 389 'u_cos_sin_angle': { 'type' : 'vec2' },
390 'u_texTransform': { 'type' : 'mat3' }
391 //'u_colorCount': {'type' : 'int' } 391 //'u_colorCount': {'type' : 'int' }
392 392
393 }, 393 },