aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-19 14:12:45 -0700
committerPushkar Joshi2012-04-19 14:12:45 -0700
commit9f32d7e5454db3189209fc68a286a7fdb0c31fe8 (patch)
treea51c2bf67839a25158c30752b44fdea0eac28b9d /js
parentdc1e8dde18c40cf740bd2fe09165784e0d415fab (diff)
parent6d33345a9e609e36539d2efa25569f5eeb04a2af (diff)
downloadninja-9f32d7e5454db3189209fc68a286a7fdb0c31fe8.tar.gz
Merge branch 'master' into pentool
Conflicts: js/helper-classes/3D/view-utils.js
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/canvas-controller.js8
-rwxr-xr-xjs/controllers/elements/shapes-controller.js50
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js79
-rwxr-xr-xjs/helper-classes/3D/hit-record.js55
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js11
-rwxr-xr-xjs/helper-classes/3D/view-utils.js48
-rwxr-xr-xjs/lib/geom/brush-stroke.js3
-rwxr-xr-xjs/lib/geom/geom-obj.js3
-rwxr-xr-xjs/lib/geom/line.js2
-rwxr-xr-xjs/panels/components-panel.reel/components-panel.js2
-rwxr-xr-xjs/tools/Rotate3DToolBase.js386
-rwxr-xr-xjs/tools/RotateObject3DTool.js4
-rwxr-xr-xjs/tools/RotateStage3DTool.js7
-rwxr-xr-xjs/tools/Translate3DToolBase.js134
-rwxr-xr-xjs/tools/TranslateObject3DTool.js1
-rwxr-xr-xjs/tools/modifier-tool-base.js17
16 files changed, 634 insertions, 176 deletions
diff --git a/js/controllers/elements/canvas-controller.js b/js/controllers/elements/canvas-controller.js
index 7af7e824..b8894c18 100755
--- a/js/controllers/elements/canvas-controller.js
+++ b/js/controllers/elements/canvas-controller.js
@@ -33,5 +33,13 @@ exports.CanvasController = Montage.create(ElementController, {
33 ElementController.setProperty(el, p, value); 33 ElementController.setProperty(el, p, value);
34 } 34 }
35 } 35 }
36 },
37
38 setProperties: {
39 value: function(element, properties) {
40 for(var property in properties) {
41 this.setProperty(element, property, properties[property]);
42 }
43 }
36 } 44 }
37}); \ No newline at end of file 45}); \ No newline at end of file
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index cd7fa16d..e9dde5fc 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -396,8 +396,8 @@ exports.ShapesController = Montage.create(CanvasController, {
396 if(isFill) 396 if(isFill)
397 { 397 {
398 // Properties Panel asks for fill color even for shapes that only have strokes 398 // Properties Panel asks for fill color even for shapes that only have strokes
399 // Check that shape object has a getFillColor method before getting fills 399 // Check that shape object supports fills
400 if(el.elementModel.shapeModel.GLGeomObj.getFillColor) 400 if(el.elementModel.shapeModel.GLGeomObj.canFill)
401 { 401 {
402 return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getFillColor()); 402 return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getFillColor());
403 } 403 }
@@ -494,28 +494,36 @@ exports.ShapesController = Montage.create(CanvasController, {
494 webGl; 494 webGl;
495 if(isFill) 495 if(isFill)
496 { 496 {
497 if(mode) 497 // skip shape types that don't have fill color
498 if(el.elementModel.shapeModel.GLGeomObj.canFill)
498 { 499 {
499 switch (mode) { 500 if(mode)
500 case 'nocolor': 501 {
501 el.elementModel.shapeModel.GLGeomObj.setFillColor(null); 502 switch (mode) {
502 break; 503 case 'nocolor':
503 case 'gradient': 504 el.elementModel.shapeModel.GLGeomObj.setFillColor(null);
504 if(el.elementModel.shapeModel.useWebGl) 505 break;
505 { 506 case 'gradient':
506 this._setGradientMaterial(el, color.color.gradientMode, isFill); 507 if(el.elementModel.shapeModel.useWebGl)
507 } 508 {
508 el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops}); 509 this._setGradientMaterial(el, color.color.gradientMode, isFill);
509 break; 510 }
510 default: 511 el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops});
511 if(el.elementModel.shapeModel.useWebGl) 512 break;
512 { 513 default:
513 this._setFlatMaterial(el, isFill); 514 if(el.elementModel.shapeModel.useWebGl)
514 } 515 {
515 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); 516 this._setFlatMaterial(el, isFill);
516 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); 517 }
518 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color);
519 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl);
520 }
517 } 521 }
518 } 522 }
523 else
524 {
525 return;
526 }
519 } 527 }
520 else 528 else
521 { 529 {
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index a5428ea3..7bd77c3a 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -111,6 +111,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
111 this.eventManager.addEventListener("elementAdded", this, false); 111 this.eventManager.addEventListener("elementAdded", this, false);
112 this.eventManager.addEventListener("elementsRemoved", this, false); 112 this.eventManager.addEventListener("elementsRemoved", this, false);
113 this.eventManager.addEventListener("elementChange", this, false); 113 this.eventManager.addEventListener("elementChange", this, false);
114 this.eventManager.addEventListener("elementChanging", this, false);
114 this.eventManager.addEventListener("closeDocument", this, false); 115 this.eventManager.addEventListener("closeDocument", this, false);
115 this.eventManager.addEventListener("elementReplaced", this, false); 116 this.eventManager.addEventListener("elementReplaced", this, false);
116 } 117 }
@@ -227,20 +228,26 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
227 // TODO - Check why handleElementChange is being fired before handleAddElement 228 // TODO - Check why handleElementChange is being fired before handleAddElement
228 handleElementChange: { 229 handleElementChange: {
229 value: function(event) { 230 value: function(event) {
230 if(!event.detail || !event.detail.data) 231 this._elementChangeHelper(event);
231 { 232 }
233 },
234
235 handleElementChanging: {
236 value: function(event) {
237 this._elementChangeHelper(event);
238 }
239 },
240
241 _elementChangeHelper: {
242 value: function(event) {
243 if(!event.detail || !event.detail.data) {
232 return; 244 return;
233 } 245 }
234 var els = event.detail.data.els; 246 var els = event.detail.data.els;
235 if(els && this._shouldUpdatePlanes(event.detail.data.prop)) 247 if(els && this._shouldUpdatePlanes(event.detail.data.prop)) {
236 { 248 var len = els.length;
237 var len = els.length, 249 for(var i=0; i < len; i++) {
238 i = 0, 250 if(els[i].elementModel.props3D.elementPlane) {
239 item;
240
241 for(i=0; i < len; i++) {
242 if(els[i].elementModel.props3D.elementPlane)
243 {
244 els[i].elementModel.props3D.elementPlane.init(); 251 els[i].elementModel.props3D.elementPlane.init();
245 } 252 }
246 } 253 }
@@ -796,20 +803,21 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
796 context.stroke(); 803 context.stroke();
797 804
798 this._selectionCtr = MathUtils.getCenterFromBounds(3, bounds3D); 805 this._selectionCtr = MathUtils.getCenterFromBounds(3, bounds3D);
799 console.log("selection center, single elt case - ", this._selectionCtr); 806// console.log("selection center, single elt case - ", this._selectionCtr);
800 807
801 this.viewUtils.popViewportObj(); 808 this.viewUtils.popViewportObj();
802 } 809 }
803 else 810 else
804 { 811 {
805 // get the plane from the first element to compare against the other elements 812 // get the plane from the first element to compare against the other elements
813 var dot;
806 var flat = true; 814 var flat = true;
807 var plane = this.viewUtils.getElementPlane( eltArray[0] ); 815 var plane = this.viewUtils.getUnprojectedElementPlane( eltArray[0] );
808 for (i=1; i<len; i++) 816 for (i=1; i<len; i++)
809 { 817 {
810 elt = eltArray[i]; 818 elt = eltArray[i];
811 var plane2 = this.viewUtils.getElementPlane( elt ); 819 var plane2 = this.viewUtils.getUnprojectedElementPlane( elt );
812 var dot = MathUtils.dot3(plane,plane2); 820 dot = Math.abs( MathUtils.dot3(plane,plane2) );
813 if (MathUtils.fpCmp(dot, 1) != 0) 821 if (MathUtils.fpCmp(dot, 1) != 0)
814 { 822 {
815 flat = false; 823 flat = false;
@@ -825,6 +833,19 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
825 } 833 }
826 } 834 }
827 835
836 // if all of the planes are aligned, check if they are aligned with the view direction
837 if (flat)
838 {
839 var stage = this.application.ninja.currentDocument.documentRoot;
840 var stageMat = this.viewUtils.getMatrixFromElement(stage);
841 var viewDir = [ stageMat[8], stageMat[9], stageMat[10] ];
842 viewDir = vecUtils.vecNormalize( 3, viewDir );
843 dot = Math.abs( MathUtils.dot3(plane,viewDir) );
844 if (MathUtils.fpCmp(dot, 1) != 0)
845 flat = false;
846 }