aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/pulse-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/pulse-material.js')
-rw-r--r--js/lib/rdge/materials/pulse-material.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js
index 81db36c6..1e2cd2a9 100644
--- a/js/lib/rdge/materials/pulse-material.js
+++ b/js/lib/rdge/materials/pulse-material.js
@@ -174,6 +174,38 @@ var PulseMaterial = function PulseMaterial() {
174 } 174 }
175 }; 175 };
176 176
177 // JSON export
178 this.exportJSON = function()
179 {
180 var world = this.getWorld();
181 if (!world)
182 throw new Error( "no world in material.export, " + this.getName() );
183
184 var jObj =
185 {
186 'material' : this.getShaderName(),
187 'name' : this.getName(),
188 'texture' : this._propValues[this._propNames[0]]
189 };
190
191 return jObj;
192 };
193
194 this.importJSON = function( jObj )
195 {
196 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
197 this.setName( jObj.name );
198
199 try {
200 this._propValues[this._propNames[0]] = jObj.texture;
201 }
202 catch (e)
203 {
204 throw new Error( "could not import material: " + jObj );
205 }
206 }
207
208
177 this.export = function() { 209 this.export = function() {
178 // every material needs the base type and instance name 210 // every material needs the base type and instance name
179 var exportStr = "material: " + this.getShaderName() + "\n"; 211 var exportStr = "material: " + this.getShaderName() + "\n";