aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements/shapes-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements/shapes-controller.js')
-rwxr-xr-xjs/controllers/elements/shapes-controller.js45
1 files changed, 40 insertions, 5 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 689bc421..3f8f27d3 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -105,6 +105,20 @@ exports.ShapesController = Montage.create(CanvasController, {
105 case "editFillMaterial": 105 case "editFillMaterial":
106 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); 106 NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()});
107 break; 107 break;
108 case "animate":
109 if(value)
110 {
111 el.elementModel.shapeModel.animate = true;
112 el.elementModel.shapeModel.GLWorld._previewAnimation = true;
113 el.elementModel.shapeModel.GLWorld.restartRenderLoop();
114 }
115 else
116 {
117 el.elementModel.shapeModel.animate = false;
118 el.elementModel.shapeModel.GLWorld._previewAnimation = false;
119 el.elementModel.shapeModel.GLWorld._canvas.task.stop();
120 }
121 break;
108 default: 122 default:
109 CanvasController.setProperty(el, p, value); 123 CanvasController.setProperty(el, p, value);
110 } 124 }
@@ -123,6 +137,7 @@ exports.ShapesController = Montage.create(CanvasController, {
123 case "border": 137 case "border":
124 case "background": 138 case "background":
125 case "useWebGl": 139 case "useWebGl":
140 case "animate":
126 return this.getShapeProperty(el, p); 141 return this.getShapeProperty(el, p);
127 case "strokeMaterial": 142 case "strokeMaterial":
128 case "fillMaterial": 143 case "fillMaterial":
@@ -489,14 +504,15 @@ exports.ShapesController = Montage.create(CanvasController, {
489 var sm, 504 var sm,
490 fm, 505 fm,
491 world, 506 world,
492 worldData = el.elementModel.shapeModel.GLWorld.export(); 507 worldData = el.elementModel.shapeModel.GLWorld.exportJSON();
493 if(worldData) 508 if(worldData)
494 { 509 {
510 worldData = this.flip3DSense (worldData );
495 world = new World(el, true); 511 world = new World(el, true);
496 el.elementModel.shapeModel.GLWorld = world; 512 el.elementModel.shapeModel.GLWorld = world;
497 el.elementModel.shapeModel.useWebGl = true; 513 el.elementModel.shapeModel.useWebGl = true;
498 el.elementModel.controller.setProperty(el, "-webkit-transform-style", "preserve-3d"); 514 el.elementModel.controller.setProperty(el, "-webkit-transform-style", "preserve-3d");
499 world.import(worldData, true); 515 world.importJSON(worldData);
500 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 516 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
501 517
502 sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); 518 sm = Object.create(MaterialsModel.getMaterial("FlatMaterial"));
@@ -526,13 +542,14 @@ exports.ShapesController = Montage.create(CanvasController, {
526 return; 542 return;
527 } 543 }
528 var world, 544 var world,
529 worldData = el.elementModel.shapeModel.GLWorld.export(); 545 worldData = el.elementModel.shapeModel.GLWorld.exportJSON();
530 if(worldData) 546 if(worldData)
531 { 547 {
548 worldData = this.flip3DSense (worldData );
532 world = new World(el, false); 549 world = new World(el, false);
533 el.elementModel.shapeModel.GLWorld = world; 550 el.elementModel.shapeModel.GLWorld = world;
534 el.elementModel.shapeModel.useWebGl = false; 551 el.elementModel.shapeModel.useWebGl = false;
535 world.import(worldData, true); 552 world.importJSON(worldData);
536 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 553 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
537 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); 554 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
538 el.elementModel.shapeModel.strokeMaterial = null; 555 el.elementModel.shapeModel.strokeMaterial = null;
@@ -544,6 +561,24 @@ exports.ShapesController = Montage.create(CanvasController, {
544 } 561 }
545 } 562 }
546 } 563 }
564 },
565
566 flip3DSense: {
567 value: function( importStr )
568 {
569 var jObj;
570 var index = importStr.indexOf( ';' );
571 if ((importStr[0] === 'v') && (index < 24))
572 {
573 // JSON format. separate the version info from the JSON info
574 //var vStr = importStr.substr( 0, index+1 );
575 var jStr = importStr.substr( index+1 );
576 jObj = JSON.parse( jStr );
577 jObj.webGL = !jObj.webGL;
578 }
579
580 return jObj;
581 }
547 } 582 }
548 583
549}); 584});