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/twist-vert-material.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'js/lib/rdge/materials/twist-vert-material.js') diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js index 05172a1b..2d2cdcc5 100644 --- a/js/lib/rdge/materials/twist-vert-material.js +++ b/js/lib/rdge/materials/twist-vert-material.js @@ -102,6 +102,34 @@ function TwistVertMaterial() } /////////////////////////////////////////////////////////////////////// + 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: " + importStr ); + } + } + this.export = function() { // this function should be overridden by subclasses -- cgit v1.2.3