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/radial-blur-material.js | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'js/lib/rdge/materials/radial-blur-material.js') diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index 46cdda74..e76b302f 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js @@ -157,6 +157,42 @@ var RadialBlurMaterial = function RadialBlurMaterial() { } }; + this.exportJSON = function() + { + var world = this.getWorld(); + if (!world) + throw new Error( "no world in material.export, " + this.getName() ); + + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + 'color' : this._propValues["color"], + 'texture' : this._propValues[this._propNames[0]] + }; + + return jObj; + }; + + this.importJSON = function( importStr ) + { + if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); + this.setName( jObj.name ); + + var rtnStr; + try + { + this._propValues[this._propNames[0]] = jObj.texture; + this.updateTexture(); + } + catch (e) + { + throw new Error( "could not import material: " + importStr ); + } + + return rtnStr; + } + this.export = function() { // every material needs the base type and instance name var exportStr = "material: " + this.getShaderName() + "\n"; -- cgit v1.2.3