aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/component-controller.js13
-rwxr-xr-xjs/controllers/elements/element-controller.js16
-rwxr-xr-xjs/controllers/elements/shapes-controller.js56
-rwxr-xr-xjs/controllers/elements/stage-controller.js41
4 files changed, 97 insertions, 29 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 83450d0f..260ee8a0 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,6 +11,8 @@ exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: { 12 getProperty: {
13 value: function(el, prop) { 13 value: function(el, prop) {
14 var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el);
15
14 switch(prop) { 16 switch(prop) {
15 case "id": 17 case "id":
16 case "class": 18 case "class":
@@ -19,18 +21,20 @@ exports.ComponentController = Montage.create(ElementController, {
19 case "width": 21 case "width":
20 case "height": 22 case "height":
21 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { 23 if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) {
22 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 24 return component[prop];
23 } else { 25 } else {
24 return ElementController.getProperty(el, prop, true); 26 return ElementController.getProperty(el, prop, true);
25 } 27 }
26 default: 28 default:
27 return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; 29 return component[prop];
28 } 30 }
29 } 31 }
30 }, 32 },
31 33
32 setProperty: { 34 setProperty: {
33 value: function(el, p, value) { 35 value: function(el, p, value) {
36 var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el);
37
34 switch(p) { 38 switch(p) {
35 case "id": 39 case "id":
36 case "class": 40 case "class":
@@ -39,15 +43,14 @@ exports.ComponentController = Montage.create(ElementController, {
39 case "width": 43 case "width":
40 case "height": 44 case "height":
41 if(el.nodeName === "IMG" && (p === "width" || p === "height")) { 45 if(el.nodeName === "IMG" && (p === "width" || p === "height")) {
42 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; 46 component[p] = value;
43 } else { 47 } else {
44 ElementController.setProperty(el, p, value); 48 ElementController.setProperty(el, p, value);
45 } 49 }
46 break; 50 break;
47 default: 51 default:
48 if(p === "min" || p === "max") value = parseFloat(value); 52 if(p === "min" || p === "max") value = parseFloat(value);
49 53 component[p] = value;
50 this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value;
51 break; 54 break;
52 55
53 } 56 }
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 70aba54e..b35251ad 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -228,22 +228,6 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
228 mat = this.transformStringToMat( xformStr ); 228 mat = this.transformStringToMat( xformStr );
229 if (!mat) 229 if (!mat)
230 mat = Matrix.I(4); 230 mat = Matrix.I(4);
231
232 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
233 if (zoom)
234 {
235 zoom = Number(zoom);
236 if (zoom != 1)
237 {
238 var zoomMat = Matrix.create( [
239 [ zoom, 0, 0, 0],
240 [ 0, zoom, 0, 0],
241 [ 0, 0, zoom, 0],
242 [ 0, 0, 0, 1]
243 ] );
244 glmat4.multiply( zoomMat, mat, mat );
245 }
246 }
247 } 231 }
248 232
249 el.elementModel.props3D.matrix3d = mat; 233 el.elementModel.props3D.matrix3d = mat;
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
7var Montage = require("montage/core/core").Montage, 7var 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,
11var World = require("js/lib/drawing/world").World; 11 MaterialsModel = require("js/models/materials-model").MaterialsModel;
12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
13 12
14exports.ShapesController = Montage.create(CanvasController, { 13exports.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 );