aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorhwc4872012-05-14 10:00:52 -0700
committerhwc4872012-05-14 10:00:52 -0700
commit5fcb96cae89007c684df3ce948831e2fcf9fd8b7 (patch)
treef179b73bdc878d7f5a6799b2b1826e836168b805 /js/lib/geom
parent137bfc9d4c41cc918d969565bec28a834fe10472 (diff)
downloadninja-5fcb96cae89007c684df3ce948831e2fcf9fd8b7.tar.gz
Fixing merge issues
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/geom-obj.js36
1 files changed, 7 insertions, 29 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index 803dbb53..6f37ad1c 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -11,7 +11,6 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel;
11// Super class for all geometry classes 11// Super class for all geometry classes
12/////////////////////////////////////////////////////////////////////// 12///////////////////////////////////////////////////////////////////////
13exports.GeomObj = Object.create(Object.prototype, { 13exports.GeomObj = Object.create(Object.prototype, {
14{
15 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
16 // Constants 15 // Constants
17 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
@@ -181,14 +180,12 @@ exports.GeomObj = Object.create(Object.prototype, {
181 /////////////////////////////////////////////////////////////////////// 180 ///////////////////////////////////////////////////////////////////////
182 // Methods 181 // Methods
183 /////////////////////////////////////////////////////////////////////// 182 ///////////////////////////////////////////////////////////////////////
184 setMaterialColor: { 183 setMaterialColor: {
185 value: function(c, type) { 184 value: function(c, type) {
186 var i = 0, 185 var i = 0,
187 nMats = 0; 186 nMats = 0;
188 if (c) { 187 if (c) {
189 if (c.gradientMode) { 188 if (c.gradientMode) {
190 if (c.gradientMode)
191 {
192 // Gradient support 189 // Gradient support
193 if (this._materialArray && this._materialTypeArray) { 190 if (this._materialArray && this._materialTypeArray) {
194 nMats = this._materialArray.length; 191 nMats = this._materialArray.length;
@@ -204,7 +201,6 @@ exports.GeomObj = Object.create(Object.prototype, {
204 } 201 }
205 202
206 for (var n = 0; n < len; n++) { 203 for (var n = 0; n < len; n++) {
207 {
208 var position = colors[n].position / 100; 204 var position = colors[n].position / 100;
209 var cs = colors[n].value; 205 var cs = colors[n].value;
210 var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a]; 206 var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a];
@@ -213,9 +209,6 @@ exports.GeomObj = Object.create(Object.prototype, {
213 if (nMats === this._materialTypeArray.length) { 209 if (nMats === this._materialTypeArray.length) {
214 for (i = 0; i < nMats; i++) { 210 for (i = 0; i < nMats; i++) {
215 if (this._materialTypeArray[i] == type) { 211 if (this._materialTypeArray[i] == type) {
216 {
217 if (this._materialTypeArray[i] == type)
218 {
219 this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0)); 212 this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0));
220 this._materialArray[i].setProperty("colorStop" + (n + 1), position); 213 this._materialArray[i].setProperty("colorStop" + (n + 1), position);
221 } 214 }
@@ -225,15 +218,12 @@ exports.GeomObj = Object.create(Object.prototype, {
225 if (type === "fill") { 218 if (type === "fill") {
226 this._fillColor = c; 219 this._fillColor = c;
227 } else { 220 } else {
228 else {
229 this._strokeColor = c; 221 this._strokeColor = c;
230 } 222 }
231 } else { 223 } else {
232 else {
233 if (type === "fill") { 224 if (type === "fill") {
234 this._fillColor = c.slice(0); 225 this._fillColor = c.slice(0);
235 } else { 226 } else {
236 else {
237 this._strokeColor = c.slice(0); 227 this._strokeColor = c.slice(0);
238 } 228 }
239 229
@@ -241,7 +231,6 @@ exports.GeomObj = Object.create(Object.prototype, {
241 nMats = this._materialArray.length; 231 nMats = this._materialArray.length;
242 if (nMats === this._materialTypeArray.length) { 232 if (nMats === this._materialTypeArray.length) {
243 for (i = 0; i < nMats; i++) { 233 for (i = 0; i < nMats; i++) {
244 {
245 if (this._materialTypeArray[i] == type) { 234 if (this._materialTypeArray[i] == type) {
246 this._materialArray[i].setProperty("color", c.slice(0)); 235 this._materialArray[i].setProperty("color", c.slice(0));
247 } 236 }
@@ -250,24 +239,17 @@ exports.GeomObj = Object.create(Object.prototype, {
250 } 239 }
251 } 240 }
252 } else { 241 } else {
253 else
254 {
255 if (type === "fill") { 242 if (type === "fill") {
256 this._fillColor = null; 243 this._fillColor = null;
257 } else { 244 } else {
258 else {
259 this._strokeColor = null; 245 this._strokeColor = null;
260 } 246 }
261 247
262 if (this._materialArray && this._materialTypeArray) { 248 if (this._materialArray && this._materialTypeArray) {
263 {
264 nMats = this._materialArray.length; 249 nMats = this._materialArray.length;
265 if (nMats === this._materialTypeArray.length) { 250 if (nMats === this._materialTypeArray.length) {
266 for (i = 0; i < nMats; i++) { 251 for (i = 0; i < nMats; i++) {
267 if (this._materialTypeArray[i] == type) { 252 if (this._materialTypeArray[i] == type) {
268 {
269 if (this._materialTypeArray[i] == type)
270 {
271 // TODO - Not sure how to set color to null values in shaders 253 // TODO - Not sure how to set color to null values in shaders
272 this._materialArray[i].setProperty("color", [0, 0, 0, 0]); 254 this._materialArray[i].setProperty("color", [0, 0, 0, 0]);
273 } 255 }
@@ -289,7 +271,6 @@ exports.GeomObj = Object.create(Object.prototype, {
289 if (this.getStrokeMaterial()) { 271 if (this.getStrokeMaterial()) {
290 strokeMaterial = this.getStrokeMaterial().dup(); 272 strokeMaterial = this.getStrokeMaterial().dup();
291 } else { 273 } else {
292 else {
293 strokeMaterial = MaterialsModel.exportFlatMaterial(); 274 strokeMaterial = MaterialsModel.exportFlatMaterial();
294 } 275 }
295 276
@@ -304,7 +285,7 @@ exports.GeomObj = Object.create(Object.prototype, {
304 this.setStrokeColor(this._strokeColor); 285 this.setStrokeColor(this._strokeColor);
305 } 286 }
306 287
307 this._strokeMaterial = strokeMaterial; 288 this._strokeMaterial = strokeMaterial;
308 289
309 return strokeMaterial; 290 return strokeMaterial;
310 } 291 }
@@ -316,7 +297,6 @@ exports.GeomObj = Object.create(Object.prototype, {
316 if (this.getFillMaterial()) { 297 if (this.getFillMaterial()) {
317 fillMaterial = this.getFillMaterial().dup(); 298 fillMaterial = this.getFillMaterial().dup();
318 } else { 299 } else {
319 else {
320 fillMaterial = MaterialsModel.exportFlatMaterial(); 300 fillMaterial = MaterialsModel.exportFlatMaterial();
321 } 301 }
322 302
@@ -339,17 +319,17 @@ exports.GeomObj = Object.create(Object.prototype, {
339 319
340 exportMaterialsJSON: { 320 exportMaterialsJSON: {
341 value: function() { 321 value: function() {
342 MaterialsModel = require("js/models/materials-model").MaterialsModel; 322 MaterialsModel = require("js/models/materials-model").MaterialsModel;
343 323
344 var jObj; 324 var jObj;
345 if (this._materialArray && this._materialNodeArray && this.getWorld().isWebGL()) { 325 if (this._materialArray && this._materialNodeArray && this.getWorld().isWebGL()) {
346 var nMats = this._materialArray.length; 326 var nMats = this._materialArray.length;
347 if (nMats > 0) { 327 if (nMats > 0) {
348 { 328 {
349 var arr = []; 329 var arr = [];
350 330
351 for (var i = 0; i < nMats; i++) { 331 for (var i = 0; i < nMats; i++) {
352 { 332 {
353 var matObj = 333 var matObj =
354 { 334 {
355 'materialNodeName':this._materialNodeArray[i].name, 335 'materialNodeName':this._materialNodeArray[i].name,
@@ -373,7 +353,7 @@ exports.GeomObj = Object.create(Object.prototype, {
373 353
374 importMaterialsJSON: { 354 importMaterialsJSON: {
375 value: function(jObj) { 355 value: function(jObj) {
376 MaterialsModel = require("js/models/materials-model").MaterialsModel; 356 MaterialsModel = require("js/models/materials-model").MaterialsModel;
377 357
378 this._materialArray = []; 358 this._materialArray = [];
379 this._materialTypeArray = []; 359 this._materialTypeArray = [];
@@ -383,12 +363,10 @@ exports.GeomObj = Object.create(Object.prototype, {
383 var nMaterials = jObj.nMaterials; 363 var nMaterials = jObj.nMaterials;
384 var matArray = jObj.materials; 364 var matArray = jObj.materials;
385 for (var i = 0; i < nMaterials; i++) { 365 for (var i = 0; i < nMaterials; i++) {
386 {
387 var mat; 366 var mat;
388 var matObj = matArray[i].material; 367 var matObj = matArray[i].material;
389 var shaderName = matObj.material; 368 var shaderName = matObj.material;
390 switch (shaderName) { 369 switch (shaderName) {
391 {
392 case "flat": 370 case "flat":
393 case "radialGradient": 371 case "radialGradient":
394 case "linearGradient": 372 case "linearGradient":
@@ -402,7 +380,7 @@ exports.GeomObj = Object.create(Object.prototype, {
402 case "tunnel": 380 case "tunnel":
403 case "reliefTunnel": 381 case "reliefTunnel":
404 case "squareTunnel": 382 case "squareTunnel":
405 case "flag": 383 case "flag":
406 case "twist": 384 case "twist":
407 case "fly": 385 case "fly":
408 case "julia": 386 case "julia":