aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js8
-rwxr-xr-xjs/controllers/elements/shapes-controller.js28
2 files changed, 31 insertions, 5 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 539fd13e..d5556fa8 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -64,10 +64,16 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
64 64
65 this.eventManager.addEventListener("styleSheetDirty", this, false); 65 this.eventManager.addEventListener("styleSheetDirty", this, false);
66 66
67 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
67 } 68 }
68 }, 69 },
69 70
70 71 handleAddComponentFirstDraw: {
72 value: function (e) {
73 //TODO: Add logic to reparse the document for dynamically added styles
74 console.log(e);
75 }
76 },
71 77
72 78
73 79
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});