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.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js
index 8e05e23d..0db6fc90 100755
--- a/js/lib/rdge/materials/linear-gradient-material.js
+++ b/js/lib/rdge/materials/linear-gradient-material.js
@@ -249,6 +249,59 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
249 } 249 }
250 }; 250 };
251 251
252 this.exportJSON = function()
253 {
254 var jObj =
255 {
256 'material' : this.getShaderName(),
257 'name' : this.getName(),
258 'color1' : this.getColor1(),
259 'color2' : this.getColor2(),
260 'color3' : this.getColor3(),
261 'color4' : this.getColor4(),
262 'colorStop1' : this.getColorStop1(),
263 'colorStop2' : this.getColorStop2(),
264 'colorStop3' : this.getColorStop3(),
265 'colorStop4' : this.getColorStop4(),
266 'angle' : this.getAngle()
267 };
268
269 return jObj;
270 };
271
272 this.importJSON = function( jObj )
273 {
274 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
275 this.setName( jObj.name );
276
277 try
278 {
279 var color1 = jObj.color1,
280 color2 = jObj.color2,
281 color3 = jObj.color3,
282 color4 = jObj.color4,
283 colorStop1 = jObj.colorStop1,
284 colorStop2 = jObj.colorStop2,
285 colorStop3 = jObj.colorStop3,
286 colorStop4 = jObj.colorStop4,
287 angle = jObj.angle;
288
289 this.setProperty( "color1", color1 );
290 this.setProperty( "color2", color2 );
291 this.setProperty( "color3", color3 );
292 this.setProperty( "color4", color4 );
293 this.setProperty( "colorStop1", colorStop1 );
294 this.setProperty( "colorStop2", colorStop2 );
295 this.setProperty( "colorStop3", colorStop3 );
296 this.setProperty( "colorStop4", colorStop4 );
297 this.setProperty( "angle", angle );
298 }
299 catch (e)
300 {
301 throw new Error( "could not import material: " + importStr );
302 }
303 };
304
252 this.export = function() { 305 this.export = function() {
253 // every material needs the base type and instance name 306 // every material needs the base type and instance name
254 var exportStr = "material: " + this.getShaderName() + "\n"; 307 var exportStr = "material: " + this.getShaderName() + "\n";