diff options
Diffstat (limited to 'js/controllers/elements/shapes-controller.js')
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b3ac9ddb..5b9e4672 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,13 +504,14 @@ 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 | world.import(worldData); | 514 | world.importJSON(worldData); |
499 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 515 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
500 | 516 | ||
501 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); | 517 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); |
@@ -525,13 +541,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
525 | return; | 541 | return; |
526 | } | 542 | } |
527 | var world, | 543 | var world, |
528 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 544 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
529 | if(worldData) | 545 | if(worldData) |
530 | { | 546 | { |
547 | worldData = this.flip3DSense (worldData ); | ||
531 | world = new World(el, false); | 548 | world = new World(el, false); |
532 | el.elementModel.shapeModel.GLWorld = world; | 549 | el.elementModel.shapeModel.GLWorld = world; |
533 | el.elementModel.shapeModel.useWebGl = false; | 550 | el.elementModel.shapeModel.useWebGl = false; |
534 | world.import(worldData); | 551 | world.importJSON(worldData); |
535 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 552 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
536 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); | 553 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); |
537 | el.elementModel.shapeModel.strokeMaterial = null; | 554 | el.elementModel.shapeModel.strokeMaterial = null; |
@@ -543,6 +560,24 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
543 | } | 560 | } |
544 | } | 561 | } |
545 | } | 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 | } | ||
546 | } | 581 | } |
547 | 582 | ||
548 | }); | 583 | }); |