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/io/system/ninjalibrary.json | 2 +- js/lib/rdge/materials/flag-material.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index 9547c1e8..bee603ae 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json @@ -1,6 +1,6 @@ { "libraries": [ {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.8.0.0"}, - {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.4"} + {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.6"} ] } \ No newline at end of file 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