diff options
author | Pushkar Joshi | 2012-03-27 09:10:58 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-03-27 09:10:58 -0700 |
commit | 0c26aff9c19c2b39fca06fa6b3bc76b672204065 (patch) | |
tree | e778f2b9d5d525aa364360d5996536a0a06379bd /js/controllers/elements/shapes-controller.js | |
parent | 753244b4713243ab19ca246be674f0b45fb85b72 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-0c26aff9c19c2b39fca06fa6b3bc76b672204065.tar.gz |
Merge branch 'master' into brushtool
Conflicts:
js/controllers/elements/shapes-controller.js
Diffstat (limited to 'js/controllers/elements/shapes-controller.js')
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 46e337b7..68a82762 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -6,10 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, | 8 | CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, |
9 | njModule = require("js/lib/NJUtils"); | 9 | njModule = require("js/lib/NJUtils"), |
10 | 10 | World = require("js/lib/drawing/world").World, | |
11 | var World = require("js/lib/drawing/world").World; | 11 | MaterialsModel = require("js/models/materials-model").MaterialsModel; |
12 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
13 | 12 | ||
14 | exports.ShapesController = Montage.create(CanvasController, { | 13 | exports.ShapesController = Montage.create(CanvasController, { |
15 | 14 | ||
@@ -100,6 +99,26 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
100 | el.elementModel.shapeModel.GLWorld.render(); | 99 | el.elementModel.shapeModel.GLWorld.render(); |
101 | } | 100 | } |
102 | break; | 101 | break; |
102 | case "editStrokeMaterial": | ||
103 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.strokeMaterial.getName()}); | ||
104 | break; | ||
105 | case "editFillMaterial": | ||
106 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); | ||
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; | ||
103 | case "strokeHardness": | 122 | case "strokeHardness": |
104 | this.setShapeProperty(el, "strokeHardness", value); | 123 | this.setShapeProperty(el, "strokeHardness", value); |
105 | el.elementModel.shapeModel.GLGeomObj.setStrokeHardness(val); | 124 | el.elementModel.shapeModel.GLGeomObj.setStrokeHardness(val); |
@@ -143,6 +162,7 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
143 | case "border": | 162 | case "border": |
144 | case "background": | 163 | case "background": |
145 | case "useWebGl": | 164 | case "useWebGl": |
165 | case "animate": | ||
146 | return this.getShapeProperty(el, p); | 166 | return this.getShapeProperty(el, p); |
147 | case "strokeHardness": | 167 | case "strokeHardness": |
148 | if (el.elementModel && el.elementModel.shapeModel){ | 168 | if (el.elementModel && el.elementModel.shapeModel){ |
@@ -546,13 +566,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
546 | var sm, | 566 | var sm, |
547 | fm, | 567 | fm, |
548 | world, | 568 | world, |
549 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 569 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
550 | if(worldData) | 570 | if(worldData) |
551 | { | 571 | { |
572 | worldData = this.flip3DSense (worldData ); | ||
552 | world = new World(el, true); | 573 | world = new World(el, true); |
553 | el.elementModel.shapeModel.GLWorld = world; | 574 | el.elementModel.shapeModel.GLWorld = world; |
554 | el.elementModel.shapeModel.useWebGl = true; | 575 | el.elementModel.shapeModel.useWebGl = true; |
555 | world.import(worldData); | 576 | world.importJSON(worldData); |
556 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 577 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
557 | 578 | ||
558 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); | 579 | sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); |
@@ -582,13 +603,14 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
582 | return; | 603 | return; |
583 | } | 604 | } |
584 | var world, | 605 | var world, |
585 | worldData = el.elementModel.shapeModel.GLWorld.export(); | 606 | worldData = el.elementModel.shapeModel.GLWorld.exportJSON(); |
586 | if(worldData) | 607 | if(worldData) |
587 | { | 608 | { |
609 | worldData = this.flip3DSense (worldData ); | ||
588 | world = new World(el, false); | 610 | world = new World(el, false); |
589 | el.elementModel.shapeModel.GLWorld = world; | 611 | el.elementModel.shapeModel.GLWorld = world; |
590 | el.elementModel.shapeModel.useWebGl = false; | 612 | el.elementModel.shapeModel.useWebGl = false; |
591 | world.import(worldData); | 613 | world.importJSON(worldData); |
592 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); | 614 | el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); |
593 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); | 615 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); |
594 | el.elementModel.shapeModel.strokeMaterial = null; | 616 | el.elementModel.shapeModel.strokeMaterial = null; |
@@ -600,6 +622,24 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
600 | } | 622 | } |
601 | } | 623 | } |
602 | } | 624 | } |
625 | }, | ||
626 | |||
627 | flip3DSense: { | ||
628 | value: function( importStr ) | ||
629 | { | ||
630 | var jObj; | ||
631 | var index = importStr.indexOf( ';' ); | ||
632 | if ((importStr[0] === 'v') && (index < 24)) | ||
633 | { | ||
634 | // JSON format. separate the version info from the JSON info | ||
635 | //var vStr = importStr.substr( 0, index+1 ); | ||
636 | var jStr = importStr.substr( index+1 ); | ||
637 | jObj = JSON.parse( jStr ); | ||
638 | jObj.webGL = !jObj.webGL; | ||
639 | } | ||
640 | |||
641 | return jObj; | ||
642 | } | ||
603 | } | 643 | } |
604 | 644 | ||
605 | }); | 645 | }); |