aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js44
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js21
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js53
-rw-r--r--js/lib/rdge/materials/pulse-material.js32
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js36
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js54
-rw-r--r--js/lib/rdge/materials/taper-material.js27
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js28
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js185
9 files changed, 475 insertions, 5 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index fa6f5300..4a6e9ab8 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -152,6 +152,50 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
152 } 152 }
153 }; 153 };
154 154
155 this.exportJSON = function()
156 {
157 var world = this.getWorld();
158 if (!world)
159 throw new Error( "no world in material.export, " + this.getName() );
160
161 var jObj =
162 {
163 'material' : this.getShaderName(),
164 'name' : this.getName(),
165 'lightDiff' : this.getLightDiff(),
166 'diffuseTexture' : this.getDiffuseTexture(),
167 'specularTexture' : this.getSpecularTexture(),
168 'normalMap' : this.getNormalTexture()
169 };
170
171 return jObj;
172 };
173
174 this.importJSON = function( jObj )
175 {
176 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
177 this.setName( jObj.name );
178
179 try
180 {
181 var lightDiff = jObj.lightDiff,
182 dt = jObj.diffuseTexture,
183 st = jObj.specularTexture,
184 nt = jObj.normalMap;
185
186 this.setProperty( "lightDiff", lightDiff);
187 this.setProperty( "diffuseTexture", dt );
188 this.setProperty( "specularTexture", st );
189 this.setProperty( "normalMap", nt );
190 }
191 catch (e)
192 {
193 throw new Error( "could not import BumpMetal material: " + jObj );
194 }
195
196 return;
197 };
198
155 this.export = function() 199 this.export = function()
156 { 200 {
157 // every material needs the base type and instance name 201 // every material needs the base type and instance name
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js
index fff0e68e..5030cc88 100755
--- a/js/lib/rdge/materials/flat-material.js
+++ b/js/lib/rdge/materials/flat-material.js
@@ -112,6 +112,27 @@ var FlatMaterial = function FlatMaterial() {
112 return rtnStr; 112 return rtnStr;
113 }; 113 };
114 114
115 this.exportJSON = function()
116 {
117 var jObj =
118 {
119 'material' : this.getShaderName(),
120 'name' : this.getName(),
121 'color' : this._propValues["color"]
122 };
123
124 return jObj;
125 }
126
127 this.importJSON = function( jObj )
128 {
129 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
130 this.setName( jObj.name );
131
132 var color = jObj.color;
133 this.setProperty( "color", color);
134 }
135
115 this.update = function( time ) 136 this.update = function( time )
116 { 137 {
117 }; 138 };
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js
index 8e05e23d..0db6fc90 100755
--- a/js/lib/rdge/materials/linear-gradient-material.js
+++ b/js/lib/rdge/materials/linear-gradient-material.js
@@ -249,6 +249,59 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
249 } 249 }
250 }; 250 };
251 251
252 this.exportJSON = function()
253 {
254 var jObj =
255 {
256 'material' : this.getShaderName(),
257 'name' : this.getName(),
258 'color1' : this.getColor1(),
259 'color2' : this.getColor2(),
260 'color3' : this.getColor3(),
261 'color4' : this.getColor4(),
262 'colorStop1' : this.getColorStop1(),
263 'colorStop2' : this.getColorStop2(),
264 'colorStop3' : this.getColorStop3(),
265 'colorStop4' : this.getColorStop4(),
266 'angle' : this.getAngle()
267 };
268
269 return jObj;
270 };
271
272 this.importJSON = function( jObj )
273 {
274 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
275 this.setName( jObj.name );
276
277 try
278 {
279 var color1 = jObj.color1,
280 color2 = jObj.color2,
281 color3 = jObj.color3,
282 color4 = jObj.color4,
283 colorStop1 = jObj.colorStop1,
284 colorStop2 = jObj.colorStop2,
285 colorStop3 = jObj.colorStop3,
286 colorStop4 = jObj.colorStop4,
287 angle = jObj.angle;
288
289 this.setProperty( "color1", color1 );
290 this.setProperty( "color2", color2 );
291 this.setProperty( "color3", color3 );
292 this.setProperty( "color4", color4 );
293 this.setProperty( "colorStop1", colorStop1 );
294 this.setProperty( "colorStop2", colorStop2 );
295 this.setProperty( "colorStop3", colorStop3 );
296 this.setProperty( "colorStop4", colorStop4 );
297 this.setProperty( "angle", angle );
298 }
299 catch (e)
300 {
301 throw new Error( "could not import material: " + importStr );
302 }
303 };
304
252 this.export = function() { 305 this.export = function() {
253 // every material needs the base type and instance name 306 // every material needs the base type and instance name
254 var exportStr = "material: " + this.getShaderName() + "\n"; 307 var exportStr = "material: " + this.getShaderName() + "\n";
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";
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() {
157 } 157 }
158 }; 158 };
159 159
160 this.exportJSON = function()
161 {
162 var world = this.getWorld();
163 if (!world)
164