diff options
Diffstat (limited to 'js/models')
-rwxr-xr-x | js/models/materials-model.js | 151 |
1 files changed, 85 insertions, 66 deletions
diff --git a/js/models/materials-model.js b/js/models/materials-model.js index 44364aa2..0f214356 100755 --- a/js/models/materials-model.js +++ b/js/models/materials-model.js | |||
@@ -16,20 +16,24 @@ var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-mate | |||
16 | var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial; | 16 | var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial; |
17 | var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; | 17 | var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; |
18 | var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; | 18 | var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; |
19 | //var CloudMaterial = require("js/lib/rdge/materials/cloud-material").CloudMaterial; | ||
19 | var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; | 20 | var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; |
20 | var RaidersMaterial = require("js/lib/rdge/materials/radial-blur-material").RaidersMaterial; | 21 | var RaidersMaterial = require("js/lib/rdge/materials/radial-blur-material").RaidersMaterial; |
21 | var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; | 22 | var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; |
22 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | 23 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; |
23 | var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; | 24 | var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; |
24 | var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial; | 25 | var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial; |
26 | var FlagMaterial = require("js/lib/rdge/materials/flag-material").FlagMaterial; | ||
25 | var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; | 27 | var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; |
26 | var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; | 28 | var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; |
27 | var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; | 29 | var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; |
28 | var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial; | 30 | //var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial; |
29 | var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; | 31 | var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; |
30 | var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; | 32 | var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; |
31 | var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; | 33 | var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; |
32 | var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial; | 34 | var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial; |
35 | var TwistVertMaterial = require("js/lib/rdge/materials/twist-vert-material").TwistVertMaterial; | ||
36 | var TaperMaterial = require("js/lib/rdge/materials/taper-material").TaperMaterial; | ||
33 | var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial; | 37 | var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial; |
34 | var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial; | 38 | var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial; |
35 | var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial; | 39 | var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial; |
@@ -41,33 +45,37 @@ exports.MaterialsModel = Montage.create(Component, { | |||
41 | value: false | 45 | value: false |
42 | }, | 46 | }, |
43 | 47 | ||
44 | deserializedFromTemplate: { | 48 | deserializedFromTemplate: { |
45 | value: function() { | 49 | value: function() { |
46 | // Load all the materials | 50 | // Load all the materials |
47 | this.addMaterial(new FlatMaterial()); | 51 | this.addMaterial(new FlatMaterial()); |
48 | this.addMaterial(new LinearGradientMaterial()); | 52 | this.addMaterial(new BumpMetalMaterial()); |
49 | this.addMaterial(new RadialGradientMaterial()); | 53 | //this.addMaterial(new CloudMaterial()); |
50 | this.addMaterial(new BumpMetalMaterial()); | 54 | this.addMaterial(new DeformMaterial()); |
51 | this.addMaterial(new UberMaterial()); | 55 | this.addMaterial(new FlagMaterial()); |
52 | this.addMaterial(new RadialBlurMaterial()); | 56 | this.addMaterial(new FlyMaterial()); |
53 | this.addMaterial(new RaidersMaterial()); | 57 | this.addMaterial(new JuliaMaterial()); |
54 | this.addMaterial(new PlasmaMaterial()); | 58 | this.addMaterial(new KeleidoscopeMaterial()); |
55 | this.addMaterial(new PulseMaterial()); | 59 | this.addMaterial(new LinearGradientMaterial()); |
56 | this.addMaterial(new TunnelMaterial()); | 60 | this.addMaterial(new MandelMaterial()); |
57 | this.addMaterial(new ReliefTunnelMaterial()); | 61 | this.addMaterial(new PlasmaMaterial()); |
58 | this.addMaterial(new SquareTunnelMaterial()); | 62 | this.addMaterial(new PulseMaterial()); |
59 | this.addMaterial(new FlyMaterial()); | 63 | //this.addMaterial(new ParisMaterial()); |
60 | this.addMaterial(new WaterMaterial()); | 64 | this.addMaterial(new RadialGradientMaterial()); |
61 | this.addMaterial(new ParisMaterial()); | 65 | this.addMaterial(new RadialBlurMaterial()); |
62 | this.addMaterial(new ZInvertMaterial()); | 66 | this.addMaterial(new RaidersMaterial()); |
63 | this.addMaterial(new DeformMaterial()); | 67 | this.addMaterial(new ReliefTunnelMaterial()); |
64 | this.addMaterial(new StarMaterial()); | 68 | this.addMaterial(new SquareTunnelMaterial()); |
65 | this.addMaterial(new TwistMaterial()); | 69 | this.addMaterial(new StarMaterial()); |
66 | this.addMaterial(new JuliaMaterial()); | 70 | this.addMaterial(new TaperMaterial()); |
67 | this.addMaterial(new KeleidoscopeMaterial()); | 71 | this.addMaterial(new TunnelMaterial()); |
68 | this.addMaterial(new MandelMaterial()); | 72 | this.addMaterial(new TwistMaterial()); |
69 | } | 73 | this.addMaterial(new TwistVertMaterial()); |
70 | }, | 74 | this.addMaterial(new WaterMaterial()); |
75 | this.addMaterial(new ZInvertMaterial()); | ||
76 | this.addMaterial(new UberMaterial()); | ||
77 | } | ||
78 | }, | ||
71 | 79 | ||
72 | _materials : { | 80 | _materials : { |
73 | value: AppModel.materials | 81 | value: AppModel.materials |
@@ -116,7 +124,7 @@ exports.MaterialsModel = Montage.create(Component, { | |||
116 | value: function (materialName) { | 124 | value: function (materialName) { |
117 | var index = this.getIndexOfMaterial(materialName); | 125 | var index = this.getIndexOfMaterial(materialName); |
118 | if(index !== -1) { | 126 | if(index !== -1) { |
119 | return this._materials[index].dup(); | 127 | return this._materials[index]; |
120 | } | 128 | } |
121 | } | 129 | } |
122 | }, | 130 | }, |
@@ -127,7 +135,7 @@ exports.MaterialsModel = Montage.create(Component, { | |||
127 | { | 135 | { |
128 | var index = this.getIndexOfMaterialByShader( shaderName ); | 136 | var index = this.getIndexOfMaterialByShader( shaderName ); |
129 | if (index >= 0) | 137 | if (index >= 0) |
130 | return this._materials[index].dup(); | 138 | return this._materials[index]; |
131 | } | 139 | } |
132 | }, | 140 | }, |
133 | 141 | ||
@@ -202,6 +210,51 @@ exports.MaterialsModel = Montage.create(Component, { | |||
202 | } | 210 | } |
203 | }, | 211 | }, |
204 | 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 | |||
205 | importMaterials: { | 258 | importMaterials: { |
206 | value: function( jObj ) | 259 | value: function( jObj ) |
207 | { | 260 | { |
@@ -216,43 +269,9 @@ exports.MaterialsModel = Montage.create(Component, { | |||
216 | var nMats = matArray.length; | 269 | var nMats = matArray.length; |
217 | for (var i=0; i<nMats; i++) | 270 | for (var i=0; i<nMats; i++) |
218 | { | 271 | { |
219 | var mat = null; | 272 | var jMatObj = matArray[i]; |
220 | var jMatObj = matArray[i]; | ||
221 | var type = jMatObj.material; | 273 | var type = jMatObj.material; |
222 | switch (type) | 274 | var mat = this.createMaterialByShaderName( type ); |
223 | { | ||
224 | case "flat": mat = new FlatMaterial(); break; | ||
225 | case "linearGradient": mat = new LinearGradientMaterial(); break; | ||
226 | case "radialGradient": mat = new RadialGradientMaterial(); break; | ||
227 | case "bumpMetal": mat = new BumpMetalMaterial(); break; | ||
228 | case "uber": mat = new UberMaterial(); break; | ||
229 | |||
230 | case "taper": mat = new TaperMaterial(); break; | ||
231 | case "twistVert": mat = new TwistVertMaterial(); break; | ||
232 | case "radialBlur": mat = new RadialBlurMaterial(); break; | ||
233 | case "plasma": mat = new PlasmaMaterial(); break; | ||
234 | case "pulse": mat = new PulseMaterial(); break; | ||
235 | case "tunnel": mat = new TunnelMaterial(); break; | ||
236 | case "reliefTunnel": mat = new ReliefTunnelMaterial(); break; | ||
237 | case "squareTunnel": mat = new SquareTunnelMaterial(); break; | ||
238 | case "fly": mat = new FlyMaterial(); break; | ||
239 | case "water": mat = new WaterMaterial(); break; | ||
240 | case "paris": mat = new ParisMaterial(); break; | ||
241 | case "raiders": mat = new RaidersMaterial(); break; | ||
242 | case "zinvert": mat = new ZInvertMaterial(); break; | ||
243 | case "deform": mat = new DeformMaterial(); break; | ||
244 | case "star": mat = new StarMaterial(); break; | ||
245 | case "twist": mat = new TwistMaterial(); break; | ||
246 | case "julia": mat = new JuliaMaterial(); break; | ||
247 | case "keleidoscope": mat = new KeleidoscopeMaterial(); break; | ||
248 | case "mandel": mat = new MandelMaterial(); break; | ||
249 | |||
250 | |||