From a0d23354802ebc6b437698acb4b18d3395d47cd1 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 16 Mar 2012 12:26:30 -0700 Subject: Conversion to JSON based file IO for canvas2D and WebGL rendering --- js/lib/rdge/materials/taper-material.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'js/lib/rdge/materials/taper-material.js') diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js index 03a7ba9c..15b7b2b0 100644 --- a/js/lib/rdge/materials/taper-material.js +++ b/js/lib/rdge/materials/taper-material.js @@ -96,6 +96,33 @@ function TaperMaterial() } } /////////////////////////////////////////////////////////////////////// + this.exportJSON = function() + { + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + 'color' : this._propValues["color"] + }; + + return jObj; + } + + this.importJSON = function( jObj ) + { + if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); + this.setName( jObj.name ); + + try + { + var color = jObj.color; + this.setProperty( "color", color); + } + catch (e) + { + throw new Error( "could not import material: " + jObj ); + } + } this.export = function() { -- cgit v1.2.3