aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-23 15:32:47 -0700
committerValerio Virgillito2012-03-23 15:32:47 -0700
commit7ee75fef18c21275cf29740a6fdd81ea90e41f45 (patch)
treec480e35abe9065733be9dd6326b91b46896b9e3a /js
parentbc8b0c17023ddea6d77150694a777e104ef99cbc (diff)
parent86770d0dba6b137e651cbf5c8d240856be65857c (diff)
downloadninja-7ee75fef18c21275cf29740a6fdd81ea90e41f45.tar.gz
Merge pull request #140 from ericmueller/integration
Integration
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/shapes-controller.js28
-rwxr-xr-xjs/lib/drawing/world.js2
-rwxr-xr-xjs/lib/geom/geom-obj.js2
-rwxr-xr-xjs/lib/geom/rectangle.js4
4 files changed, 30 insertions, 6 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index b060b751..5b9e4672 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -504,13 +504,14 @@ exports.ShapesController = Montage.create(CanvasController, {
504 var sm, 504 var sm,
505 fm, 505 fm,
506 world, 506 world,
507 worldData = el.elementModel.shapeModel.GLWorld.export(); 507 worldData = el.elementModel.shapeModel.GLWorld.exportJSON();
508 if(worldData) 508 if(worldData)
509 { 509 {
510 worldData = this.flip3DSense (worldData );
510 world = new World(el, true); 511 world = new World(el, true);
511 el.elementModel.shapeModel.GLWorld = world; 512 el.elementModel.shapeModel.GLWorld = world;
512 el.elementModel.shapeModel.useWebGl = true; 513 el.elementModel.shapeModel.useWebGl = true;
513 world.import(worldData); 514 world.importJSON(worldData);
514 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 515 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
515 516
516 sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); 517 sm = Object.create(MaterialsModel.getMaterial("FlatMaterial"));
@@ -540,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, {
540 return; 541 return;
541 } 542 }
542 var world, 543 var world,
543 worldData = el.elementModel.shapeModel.GLWorld.export(); 544 worldData = el.elementModel.shapeModel.GLWorld.exportJSON();
544 if(worldData) 545 if(worldData)
545 { 546 {
547 worldData = this.flip3DSense (worldData );
546 world = new World(el, false); 548 world = new World(el, false);
547 el.elementModel.shapeModel.GLWorld = world; 549 el.elementModel.shapeModel.GLWorld = world;
548 el.elementModel.shapeModel.useWebGl = false; 550 el.elementModel.shapeModel.useWebGl = false;
549 world.import(worldData); 551 world.importJSON(worldData);
550 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 552 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
551 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); 553 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
552 el.elementModel.shapeModel.strokeMaterial = null; 554 el.elementModel.shapeModel.strokeMaterial = null;
@@ -558,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, {
558 } 560 }
559 } 561 }
560 } 562 }
563 },
564
565 flip3DSense: {
566 value: function( importStr )
567 {
568 var jObj;
569 var index = importStr.indexOf( ';' );
570 if ((importStr[0] === 'v') && (index < 24))
571 {
572 // JSON format. separate the version info from the JSON info
573 //var vStr = importStr.substr( 0, index+1 );
574 var jStr = importStr.substr( index+1 );
575 jObj = JSON.parse( jStr );
576 jObj.webGL = !jObj.webGL;
577 }
578
579 return jObj;
580 }
561 } 581 }
562 582
563}); 583});
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index b87c6272..73273adc 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -736,6 +736,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) {
736 } 736 }
737}; 737};
738 738
739
740
739World.prototype.exportJSON = function() 741World.prototype.exportJSON = function()
740{ 742{
741 // world properties 743 // world properties
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index dbef4859..a87bdbf5 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -248,7 +248,7 @@ var GeomObj = function GLGeomObj() {
248 this.exportMaterialsJSON = function() 248 this.exportMaterialsJSON = function()
249 { 249 {
250 var jObj; 250 var jObj;
251 if (this._materialArray && this._materialNodeArray) 251 if (this._materialArray && this._materialNodeArray && this.getWorld().isWebGL())
252 { 252 {
253 var nMats = this._materialArray.length; 253 var nMats = this._materialArray.length;
254 if (nMats > 0) 254 if (nMats > 0)
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 38e428bd..e511d5f4 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -187,7 +187,8 @@ var Rectangle = function GLRectangle() {
187 /////////////////////////////////////////////////////////////////////// 187 ///////////////////////////////////////////////////////////////////////
188 // Methods 188 // Methods
189 /////////////////////////////////////////////////////////////////////// 189 ///////////////////////////////////////////////////////////////////////
190 this.export = function() { 190 /*
191 this.export = function() {
191 var rtnStr = "type: " + this.geomType() + "\n"; 192 var rtnStr = "type: " + this.geomType() + "\n";
192 193
193 ///////////////////////////////////////////////////////////////////////// 194 /////////////////////////////////////////////////////////////////////////
@@ -243,6 +244,7 @@ var Rectangle = function GLRectangle() {
243 244
244 return rtnStr; 245 return rtnStr;
245 }; 246 };
247 */
246 248
247 // JSON export 249 // JSON export
248 this.exportJSON = function() 250 this.exportJSON = function()