aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
authorhwc4872012-06-06 16:34:41 -0700
committerhwc4872012-06-06 16:34:41 -0700
commit6c994c4b90023cecf4fd0caafb404b859fe28f54 (patch)
tree75a4d813441ca6a3eb529dc88a749776459bb76e /js/models
parent920436977433ea55c01ce1e73895d1db0a6abac1 (diff)
downloadninja-6c994c4b90023cecf4fd0caafb404b859fe28f54.tar.gz
material cleanup and rearchitecture
Diffstat (limited to 'js/models')
-rwxr-xr-xjs/models/materials-model.js89
1 files changed, 49 insertions, 40 deletions
diff --git a/js/models/materials-model.js b/js/models/materials-model.js
index 20ef317a..c3b111f4 100755
--- a/js/models/materials-model.js
+++ b/js/models/materials-model.js
@@ -27,7 +27,7 @@ var FlagMaterial = require("js/lib/rdge/materials/flag-material").FlagMaterial;
27var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; 27var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
28var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; 28var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
29var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; 29var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
30var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial; 30//var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial;
31var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; 31var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
32var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; 32var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
33var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; 33var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
@@ -60,7 +60,7 @@ exports.MaterialsModel = Montage.create(Component, {
60 this.addMaterial(new MandelMaterial()); 60 this.addMaterial(new MandelMaterial());
61 this.addMaterial(new PlasmaMaterial()); 61 this.addMaterial(new PlasmaMaterial());
62 this.addMaterial(new PulseMaterial()); 62 this.addMaterial(new PulseMaterial());
63 this.addMaterial(new ParisMaterial()); 63 //this.addMaterial(new ParisMaterial());
64 this.addMaterial(new RadialGradientMaterial()); 64 this.addMaterial(new RadialGradientMaterial());
65 this.addMaterial(new RadialBlurMaterial()); 65 this.addMaterial(new RadialBlurMaterial());
66 this.addMaterial(new RaidersMaterial()); 66 this.addMaterial(new RaidersMaterial());
@@ -210,6 +210,51 @@ exports.MaterialsModel = Montage.create(Component, {
210 } 210 }
211 }, 211 },
212 212
213 createMaterialByShaderName:
214 {
215 value: function(shaderName)
216 {
217 var mat;
218 switch (shaderName)
219 {
220 case "flat": mat = new FlatMaterial(); break;
221 case "linearGradient": mat = new LinearGradientMaterial(); break;
222 case "radialGradient": mat = new RadialGradientMaterial(); break;
223 case "bumpMetal": mat = new BumpMetalMaterial(); break;
224 case "uber": mat = new UberMaterial(); break;
225 case "cloud": mat = new CloudMaterial(); break;
226
227 case "taper": mat = new TaperMaterial(); break;
228 case "twistVert": mat = new TwistVertMaterial(); break;
229 case "radialBlur": mat = new RadialBlurMaterial(); break;
230 case "plasma": mat = new PlasmaMaterial(); break;
231 case "pulse": mat = new PulseMaterial(); break;
232 case "tunnel": mat = new TunnelMaterial(); break;
233 case "reliefTunnel": mat = new ReliefTunnelMaterial(); break;
234 case "squareTunnel": mat = new SquareTunnelMaterial(); break;
235 case "flag": mat = new FlagMaterial(); break;
236 case "fly": mat = new FlyMaterial(); break;
237 case "water": mat = new WaterMaterial(); break;
238 //case "paris": mat = new ParisMaterial(); break;
239 case "raiders": mat = new RaidersMaterial(); break;
240 case "zinvert": mat = new ZInvertMaterial(); break;
241 case "deform": mat = new DeformMaterial(); break;
242 case "star": mat = new StarMaterial(); break;
243 case "twist": mat = new TwistMaterial(); break;
244 case "julia": mat = new JuliaMaterial(); break;
245 case "keleidoscope": mat = new KeleidoscopeMaterial(); break;
246 case "mandel": mat = new MandelMaterial(); break;
247
248
249 default:
250 console.log( "Unrecognized shader name: " + shaderName );
251 break;
252 }
253
254 return mat;
255 }
256 },
257
213 importMaterials: { 258 importMaterials: {
214 value: function( jObj ) 259 value: function( jObj )
215 { 260 {
@@ -224,45 +269,9 @@ exports.MaterialsModel = Montage.create(Component, {
224 var nMats = matArray.length; 269 var nMats = matArray.length;
225 for (var i=0; i<nMats; i++) 270 for (var i=0; i<nMats; i++)
226 { 271 {
227 var mat = null; 272 var jMatObj = matArray[i];
228 var jMatObj = matArray[i];
229 var type = jMatObj.material; 273 var type = jMatObj.material;
230 switch (type) 274 var mat = this.createMaterialByShaderName( type );
231 {
232 case "flat": mat = new FlatMaterial(); break;
233 case "linearGradient": mat = new LinearGradientMaterial(); break;
234 case "radialGradient": mat = new RadialGradientMaterial(); break;
235 case "bumpMetal": mat = new BumpMetalMaterial(); break;
236 case "uber": mat = new UberMaterial(); break;
237 case "cloud": mat = new CloudMaterial(); break;
238
239 case "taper": mat = new TaperMaterial(); break;
240 case "twistVert": mat = new TwistVertMaterial(); break;
241 case "radialBlur": mat = new RadialBlurMaterial(); break;
242 case "plasma": mat = new PlasmaMaterial(); break;
243 case "pulse": mat = new PulseMaterial(); break;
244 case "tunnel": mat = new TunnelMaterial(); break;
245 case "reliefTunnel": mat = new ReliefTunnelMaterial(); break;
246 case "squareTunnel": mat = new SquareTunnelMaterial(); break;
247 case "flag": mat = new FlagMaterial(); break;
248 case "fly": mat = new FlyMaterial(); break;
249 case "water": mat = new WaterMaterial(); break;
250 case "paris": mat = new ParisMaterial(); break;
251 case "raiders": mat = new RaidersMaterial(); break;
252 case "zinvert": mat = new ZInvertMaterial(); break;
253 case "deform": mat = new DeformMaterial(); break;
254 case "star": mat = new StarMaterial(); break;
255 case "twist": mat = new TwistMaterial(); break;
256 case "julia": mat = new JuliaMaterial(); break;
257 case "keleidoscope": mat = new KeleidoscopeMaterial(); break;
258 case "mandel": mat = new MandelMaterial(); break;
259
260
261 default:
262 throw new Error( "Unrecognized material type: " + type );
263 break;
264 }
265
266 if (mat) { 275 if (mat) {
267 importStr = mat.importJSON( jMatObj ); 276 importStr = mat.importJSON( jMatObj );
268 this.addMaterial( mat ); 277 this.addMaterial( mat );