diff options
Diffstat (limited to 'js/lib')
-rw-r--r-- | js/lib/rdge/materials/flag-material.js | 31 |
1 files changed, 31 insertions, 0 deletions
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() { | |||
160 | this.updateTexture(); | 160 | this.updateTexture(); |
161 | this.update( 0 ); | 161 | this.update( 0 ); |
162 | } | 162 | } |
163 | |||
164 | this.exportJSON = function () { | ||
165 | var jObj = | ||
166 | { | ||
167 | 'material' : this.getShaderName(), | ||
168 | 'name' : this.getName(), | ||
169 | |||
170 | 'texMap' : this._propValues[this._propNames[0]], | ||
171 | 'waveWidth' : this._propValues[this._propNames[1]], | ||
172 | 'waveHeight' : this._propValues[this._propNames[2]], | ||
173 | 'speed' : this._propValues[this._propNames[3]] | ||
174 | }; | ||
175 | |||
176 | return jObj; | ||
177 | }; | ||
178 | |||
179 | this.importJSON = function (jObj) { | ||
180 | if (this.getShaderName() != jObj.material) throw new Error("ill-formed material"); | ||
181 | this.setName(jObj.name); | ||
182 | |||
183 | try { | ||
184 | |||
185 | this._texMap = this._propValues[this._propNames[0]] = jObj.texMap; | ||
186 | this._waveWidth = this._propValues[this._propNames[1]] = jObj.waveWidth; | ||
187 | this._waveHeight = this._propValues[this._propNames[2]] = jObj.waveHeight; | ||
188 | this._speed = this._propValues[this._propNames[3]] = jObj.speed; | ||
189 | } | ||
190 | catch (e) { | ||
191 | throw new Error("could not import material: " + importStr); | ||
192 | } | ||
193 | }; | ||
163 | }; | 194 | }; |
164 | 195 | ||
165 | /////////////////////////////////////////////////////////////////////////////////////// | 196 | /////////////////////////////////////////////////////////////////////////////////////// |