aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
authorhwc4872012-05-17 09:51:11 -0700
committerhwc4872012-05-17 09:51:11 -0700
commit9321b1d7ab2d23e165ac90e9eea3287f72463948 (patch)
tree0b50e138dfc1044dde01fbec401bfdabcdd65c26 /js/lib/rdge
parenta73034090b30d79a0722fc5d32e081f35d2c7f5c (diff)
downloadninja-9321b1d7ab2d23e165ac90e9eea3287f72463948.tar.gz
Linear & radial gradients for runtime fixes
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js
index 79f323db..9b331fa7 100755
--- a/js/lib/rdge/materials/linear-gradient-material.js
+++ b/js/lib/rdge/materials/linear-gradient-material.js
@@ -26,6 +26,8 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
26 // this._colorCount = 4; 26 // this._colorCount = 4;
27 this._angle = 0.0; // the shader takes [cos(a), sin(a)] 27 this._angle = 0.0; // the shader takes [cos(a), sin(a)]
28 28
29 this._textureTransform = [1,0,0, 0,1,0, 0,0,1];
30
29 /////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////
30 // Property Accessors 32 // Property Accessors
31 /////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////
@@ -195,7 +197,21 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
195 // Methods 197 // Methods
196 /////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////
197 // duplcate method requirde 199 // duplcate method requirde
198 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 };
199 215
200 this.init = function (world) { 216 this.init = function (world) {
201 this.setWorld(world); 217 this.setWorld(world);
@@ -241,7 +257,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
241 257
242 this.setAngle(this.getAngle()); 258 this.setAngle(this.getAngle());
243 259
244 this._shader['default'].u_texTransform.set( [1,0,0, 0,1,0, 0,0,1] ); 260 this._shader['default'].u_texTransform.set( this._textureTransform );
245 } 261 }
246 }; 262 };
247 263
@@ -258,7 +274,8 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
258 'colorStop2': this.getColorStop2(), 274 'colorStop2': this.getColorStop2(),
259 'colorStop3': this.getColorStop3(), 275 'colorStop3': this.getColorStop3(),
260 'colorStop4': this.getColorStop4(), 276 'colorStop4': this.getColorStop4(),
261 'angle': this.getAngle() 277 'angle': this.getAngle(),
278 'textureTransform': this._textureTransform
262 }; 279 };
263 280
264 return jObj; 281 return jObj;
@@ -278,6 +295,7 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
278 colorStop3 = jObj.colorStop3, 295 colorStop3 = jObj.colorStop3,
279 colorStop4 = jObj.colorStop4, 296 colorStop4 = jObj.colorStop4,
280 angle = jObj.angle; 297 angle = jObj.angle;
298 this._textureTransform = jObj.textureTransform;
281 299
282 this.setProperty("color1", color1); 300 this.setProperty("color1", color1);
283 this.setProperty("color2", color2); 301 this.setProperty("color2", color2);