diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/models/materials-model.js | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/models/materials-model.js')
-rwxr-xr-x | js/models/materials-model.js | 279 |
1 files changed, 140 insertions, 139 deletions
diff --git a/js/models/materials-model.js b/js/models/materials-model.js index 244db3c5..833eb08f 100755 --- a/js/models/materials-model.js +++ b/js/models/materials-model.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -69,37 +70,37 @@ exports.MaterialsModel = Montage.create(Component, { | |||
69 | value: false | 70 | value: false |
70 | }, | 71 | }, |
71 | 72 | ||
72 | deserializedFromTemplate: { | 73 | deserializedFromTemplate: { |
73 | value: function() { | 74 | value: function() { |
74 | // Load all the materials | 75 | // Load all the materials |
75 | this.addMaterial(new FlatMaterial()); | 76 | this.addMaterial(new FlatMaterial()); |
76 | this.addMaterial(new BumpMetalMaterial()); | 77 | this.addMaterial(new BumpMetalMaterial()); |
77 | //this.addMaterial(new CloudMaterial()); | 78 | //this.addMaterial(new CloudMaterial()); |
78 | this.addMaterial(new DeformMaterial()); | 79 | this.addMaterial(new DeformMaterial()); |
79 | this.addMaterial(new FlagMaterial()); | 80 | this.addMaterial(new FlagMaterial()); |
80 | this.addMaterial(new FlyMaterial()); | 81 | this.addMaterial(new FlyMaterial()); |
81 | this.addMaterial(new JuliaMaterial()); | 82 | this.addMaterial(new JuliaMaterial()); |
82 | this.addMaterial(new KeleidoscopeMaterial()); | 83 | this.addMaterial(new KeleidoscopeMaterial()); |
83 | this.addMaterial(new LinearGradientMaterial()); | 84 | this.addMaterial(new LinearGradientMaterial()); |
84 | this.addMaterial(new MandelMaterial()); | 85 | this.addMaterial(new MandelMaterial()); |
85 | this.addMaterial(new ParisMaterial()); | 86 | this.addMaterial(new ParisMaterial()); |
86 | this.addMaterial(new PlasmaMaterial()); | 87 | this.addMaterial(new PlasmaMaterial()); |
87 | this.addMaterial(new PulseMaterial()); | 88 | this.addMaterial(new PulseMaterial()); |
88 | this.addMaterial(new RadialBlurMaterial()); | 89 | this.addMaterial(new RadialBlurMaterial()); |
89 | this.addMaterial(new RadialGradientMaterial()); | 90 | this.addMaterial(new RadialGradientMaterial()); |
90 | this.addMaterial(new RaidersMaterial()); | 91 | this.addMaterial(new RaidersMaterial()); |
91 | this.addMaterial(new ReliefTunnelMaterial()); | 92 | this.addMaterial(new ReliefTunnelMaterial()); |
92 | this.addMaterial(new SquareTunnelMaterial()); | 93 | this.addMaterial(new SquareTunnelMaterial()); |
93 | this.addMaterial(new StarMaterial()); | 94 | this.addMaterial(new StarMaterial()); |
94 | this.addMaterial(new TaperMaterial()); | 95 | this.addMaterial(new TaperMaterial()); |
95 | this.addMaterial(new TunnelMaterial()); | 96 | this.addMaterial(new TunnelMaterial()); |
96 | this.addMaterial(new TwistMaterial()); | 97 | this.addMaterial(new TwistMaterial()); |
97 | this.addMaterial(new TwistVertMaterial()); | 98 | this.addMaterial(new TwistVertMaterial()); |
98 | this.addMaterial(new UberMaterial()); | 99 | this.addMaterial(new UberMaterial()); |
99 | this.addMaterial(new WaterMaterial()); | 100 | this.addMaterial(new WaterMaterial()); |
100 | this.addMaterial(new ZInvertMaterial()); | 101 | this.addMaterial(new ZInvertMaterial()); |
101 | } | 102 | } |
102 | }, | 103 | }, |
103 | 104 | ||
104 | _materials : { | 105 | _materials : { |
105 | value: AppModel.materials | 106 | value: AppModel.materials |
@@ -110,7 +111,7 @@ exports.MaterialsModel = Montage.create(Component, { | |||
110 | return this._materials; | 111 | return this._materials; |
111 | } | 112 | } |
112 | }, | 113 | }, |
113 | 114 | ||
114 | addMaterial: { | 115 | addMaterial: { |
115 | value: function (material) { | 116 | value: function (material) { |
116 | this._materials.push(material); | 117 | this._materials.push(material); |
@@ -152,16 +153,16 @@ exports.MaterialsModel = Montage.create(Component, { | |||
152 | } | 153 | } |
153 | } | 154 | } |
154 | }, | 155 | }, |
155 | 156 | ||
156 | getMaterialByShader: | 157 | getMaterialByShader: |
157 | { | 158 | { |
158 | value: function( shaderName ) | 159 | value: function( shaderName ) |
159 | { | 160 | { |
160 | var index = this.getIndexOfMaterialByShader( shaderName ); | 161 | var index = this.getIndexOfMaterialByShader( shaderName ); |
161 | if (index >= 0) | 162 | if (index >= 0) |
162 | return this._materials[index]; | 163 | return this._materials[index]; |
163 | } | 164 | } |
164 | }, | 165 | }, |
165 | 166 | ||
166 | getIndexOfMaterialByShader: { | 167 | getIndexOfMaterialByShader: { |
167 | value: function (shaderName) { | 168 | value: function (shaderName) { |
@@ -191,11 +192,11 @@ exports.MaterialsModel = Montage.create(Component, { | |||
191 | } | 192 | } |
192 | }, | 193 | }, |
193 | 194 | ||
194 | clearAllMaterials: { | 195 | clearAllMaterials: { |
195 | value: function() { | 196 | value: function() { |
196 | this._materials = []; | 197 | this._materials = []; |
197 | } | 198 | } |
198 | }, | 199 | }, |
199 | 200 | ||
200 | exportFlatMaterial: { | 201 | exportFlatMaterial: { |
201 | value: function() { | 202 | value: function() { |
@@ -203,108 +204,108 @@ exports.MaterialsModel = Montage.create(Component, { | |||
203 | } | 204 | } |
204 | }, | 205 | }, |
205 | 206 | ||
206 | getDefaultMaterialName: { | 207 | getDefaultMaterialName: { |
207 | value: function() { | 208 | value: function() { |
208 | return "Flat"; | 209 | return "Flat"; |
209 | } | 210 | } |
210 | }, | 211 | }, |
211 | 212 | ||
212 | exportMaterials: { | 213 | exportMaterials: { |
213 | value: function() | 214 | value: function() |
214 | { | 215 | { |
215 | var matArray = []; | 216 | var matArray = []; |
216 | var nMats = this._materials.length; | 217 | var nMats = this._materials.length; |
217 | for (var i=0; i<nMats; i++) { | 218 | for (var i=0; i<nMats; i++) { |
218 | var material = this._materials[i]; | 219 | var material = this._materials[i]; |
219 | var matObj = material.exportJSON(); | 220 | var matObj = material.exportJSON(); |
220 | matArray.push( matObj ); | 221 | matArray.push( matObj ); |
221 | } | 222 | } |
222 | 223 | ||
223 | var jObj = | 224 | var jObj = |
224 | { | 225 | { |
225 | 'materialLibrary': 1.0, | 226 | 'materialLibrary': 1.0, |
226 | 'materials': matArray | 227 | 'materials': matArray |
227 | }; | 228 | }; |
228 | 229 | ||
229 | // prepend an identifiable string to aid parsing when the | 230 | // prepend an identifiable string to aid parsing when the |
230 | // material model is loaded. | 231 | // material model is loaded. |
231 | var jStr = "materialLibrary;" + JSON.stringify( jObj ); | 232 | var jStr = "materialLibrary;" + JSON.stringify( jObj ); |
232 | 233 | ||
233 | return jStr; | 234 | return jStr; |
234 | } | 235 | } |
235 | }, | 236 | }, |
236 | 237 | ||
237 | createMaterialByShaderName: | 238 | createMaterialByShaderName: |
238 | { | 239 | { |
239 | value: function(shaderName) | 240 | value: function(shaderName) |
240 | { | 241 | { |
241 | var mat; | 242 | var mat; |
242 | switch (shaderName) | 243 | switch (shaderName) |
243 | { | 244 | { |
244 | case "flat": mat = new FlatMaterial(); break; | 245 | case "flat": mat = new FlatMaterial(); break; |
245 | case "linearGradient": mat = new LinearGradientMaterial(); break; | 246 | case "linearGradient": mat = new LinearGradientMaterial(); break; |
246 | case "radialGradient": mat = new RadialGradientMaterial(); break; | 247 | case "radialGradient": mat = new RadialGradientMaterial(); break; |