From 335ce503996e3ccbd2909086328d0a31fbd03370 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 31 May 2012 17:07:10 -0700 Subject: Added the flag shader to the runtime. --- js/lib/rdge/materials/flag-material.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'js/lib/rdge/materials') diff --git a/js/lib/rdge/materials/flag-material.js b/js/lib/rdge/materials/flag-material.js index fa844cc3..d1788fb8 100644 --- a/js/lib/rdge/materials/flag-material.js +++ b/js/lib/rdge/materials/flag-material.js @@ -160,6 +160,37 @@ var FlagMaterial = function FlagMaterial() { this.updateTexture(); this.update( 0 ); } + + this.exportJSON = function () { + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + + 'texMap' : this._propValues[this._propNames[0]], + 'waveWidth' : this._propValues[this._propNames[1]], + 'waveHeight' : this._propValues[this._propNames[2]], + 'speed' : this._propValues[this._propNames[3]] + }; + + return jObj; + }; + + this.importJSON = function (jObj) { + if (this.getShaderName() != jObj.material) throw new Error("ill-formed material"); + this.setName(jObj.name); + + try { + + this._texMap = this._propValues[this._propNames[0]] = jObj.texMap; + this._waveWidth = this._propValues[this._propNames[1]] = jObj.waveWidth; + this._waveHeight = this._propValues[this._propNames[2]] = jObj.waveHeight; + this._speed = this._propValues[this._propNames[3]] = jObj.speed; + } + catch (e) { + throw new Error("could not import material: " + importStr); + } + }; }; /////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3