aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-06-22 16:21:20 -0700
committerJose Antonio Marquez2012-06-22 16:21:20 -0700
commitd94c2ebbcd44e7970102d6dc58a9f316692f9767 (patch)
tree22985c8362329c2a3b9aeb2be49c1b84817ce7d6
parent8d0c07b6734d874b481bb4866466de8f863a67a7 (diff)
parentf5b8f2cc5f2b7e9cff892d7487ce56019bf66d4c (diff)
downloadninja-d94c2ebbcd44e7970102d6dc58a9f316692f9767.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into Document
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js72
-rwxr-xr-xjs/helper-classes/3D/math-utils.js4
-rwxr-xr-xjs/helper-classes/3D/view-utils.js32
-rwxr-xr-xjs/stage/layout.js3
-rw-r--r--node_modules/montage-google/picasa-carousel.reel/image.reel/image.html1
-rwxr-xr-xnode_modules/montage-google/picasa-carousel.reel/picasa-carousel.css38
-rwxr-xr-xnode_modules/montage-google/picasa-carousel.reel/picasa-carousel.html45
-rw-r--r--node_modules/montage-google/picasa-carousel.reel/picasa-carousel.js2
-rw-r--r--node_modules/montage-google/youtube-channel.reel/youtube-channel.js22
9 files changed, 114 insertions, 105 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 8ddd0d52..bd47ffc3 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -630,6 +630,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
630 value: function () 630 value: function ()
631 { 631 {
632 this.application.ninja.stage.clearGridCanvas(); 632 this.application.ninja.stage.clearGridCanvas();
633 this.drawStageOutline();
633 if (!this.isDrawingGrid()) return; 634 if (!this.isDrawingGrid()) return;
634 635
635 var saveContext = this.getDrawingSurfaceElement(); 636 var saveContext = this.getDrawingSurfaceElement();
@@ -701,21 +702,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
701 this._lineColor = saveColor; 702 this._lineColor = saveColor;
702 this._drawingContext.lineWidth = saveLineWidth; 703 this._drawingContext.lineWidth = saveLineWidth;
703 704
704 if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") {
705 // draw an outline around the body
706 var stagePt = MathUtils.getPointOnPlane([0,0,1,0]);
707 var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt);
708 // glmat4.multiply( tMat, stageMat, stageMat);
709 pt0 = [0, 0, 0];
710 pt1 = [0, height, 0];
711 delta = [width, 0, 0];
712 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
713 pt0 = [0, 0, 0];
714 pt1 = [width, 0, 0];
715 delta = [0, height, 0];
716 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
717 }
718
719 // draw the lines 705 // draw the lines
720 this.redrawGridLines(); 706 this.redrawGridLines();
721 707
@@ -738,15 +724,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
738 var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); 724 var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt );
739 for (var i = 0; i < nLines; i++) { 725 for (var i = 0; i < nLines; i++) {
740 // transform the points from working plane space to world space 726 // transform the points from working plane space to world space
741 //var t0 = mat.multiply(p0),
742 // t1 = mat.multiply(p1);
743 var t0 = glmat4.multiplyVec3( mat, p0, [] ), 727 var t0 = glmat4.multiplyVec3( mat, p0, [] ),
744 t1 = glmat4.multiplyVec3( mat, p1, [] ); 728 t1 = glmat4.multiplyVec3( mat, p1, [] );
745 729
746 // transform from world space to global screen space 730 // transform from world space to global screen space
747 if (this._sourceSpaceElt) { 731 if (this._sourceSpaceElt) {
748// t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt);
749// t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt);
750 t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); 732 t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat);
751 t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); 733 t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat);
752 } 734 }
@@ -764,9 +746,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
764 line.setVisibility(vis); 746 line.setVisibility(vis);
765 747
766 // increment the points to the next position 748 // increment the points to the next position
767// p0 = p0.add(d); p0[3] = 1.0;
768 p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0; 749 p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0;
769// p1 = p1.add(d); p1[3] = 1.0;
770 p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0; 750 p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0;
771 } 751 }
772 } 752 }
@@ -819,25 +799,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
819 // draw the lines 799 // draw the lines
820 var line, 800 var line,
821 nLines = this._gridLineArray.length; 801 nLines = this._gridLineArray.length;
822 if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") {
823 nLines = this._gridLineArray.length-4;
824 }
825 802
826 for (var i = 0; i < nLines; i++) { 803 for (var i = 0; i < nLines; i++) {
827 line = this._gridLineArray[i]; 804 line = this._gridLineArray[i];
828 this.drawIntersectedLine(line, this._drawingContext); 805 this.drawIntersectedLine(line, this._drawingContext);
829 } 806 }
830 807
831 if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") {
832 this._lineColor = "red";
833 i = nLines;
834 nLines += 4;
835 for (; i < nLines; i++) {
836 line = this._gridLineArray[i];
837 this.drawIntersectedLine(line, this._drawingContext);
838 }
839 }
840
841 this.popState(); 808 this.popState();
842 } 809 }
843 }, 810 },
@@ -1213,6 +1180,43 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1213 } 1180 }
1214 }, 1181 },
1215 1182
1183 drawStageOutline : {
1184 value: function() {
1185 var context = this.application.ninja.stage.gridContext;
1186 var stage = this.application.ninja.stage;
1187 var stageRoot = this.application.ninja.currentDocument.model.documentRoot;
1188 var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot);
1189
1190 var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1);
1191 if(!l) return;
1192 var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1);
1193 if(!r) return;
1194
1195 var t = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, 0, 0], [stage.canvas.width, 0, 0], 0.1);
1196 if(!t) return;
1197 var b = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, stage.canvas.height, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1);
1198 if(!b) return;
1199
1200 context.save();
1201 context.strokeStyle = "#333";
1202 context.lineWidth = 0.5;
1203
1204 context.beginPath();
1205
1206 context.moveTo(l[0], l[1]);
1207 context.lineTo(r[0], r[1]);
1208
1209 context.moveTo(t[0], t[1]);
1210 context.lineTo(b[0], b[1]);
1211
1212 context.closePath();
1213 context.stroke();
1214
1215 context.fillText("(0, 0)", bounds3D[0][0] + 4, bounds3D[0][1] - 6);
1216 context.restore();
1217 }
1218 },
1219
1216 draw3DCompass : { 1220 draw3DCompass : {
1217 value: function() { 1221 value: function() {
1218 // set the element to be the viewport object - temporarily 1222 // set the element to be the viewport object - temporarily
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js
index 35ee8112..44e2499d 100755
--- a/js/helper-classes/3D/math-utils.js
+++ b/js/helper-classes/3D/math-utils.js
@@ -333,7 +333,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
333 333
334 //returns the intersection point between the two segments (null if no intersection) 334 //returns the intersection point between the two segments (null if no intersection)
335 segSegIntersection2D: { 335 segSegIntersection2D: {
336 value: function (seg0Start, seg0End, seg1Start, seg1End, epsilon) { 336 value: function (seg0Start, seg0End, seg1Start, seg1End, epsilon, mustLieInSegements) {
337 //check for parallel segments 337 //check for parallel segments
338 var denom = (seg1End[1] - seg1Start[1]) * (seg0End[0] - seg0Start[0]) - (seg1End[0] - seg1Start[0]) * (seg0End[1] - seg0Start[1]); 338 var denom = (seg1End[1] - seg1Start[1]) * (seg0End[0] - seg0Start[0]) - (seg1End[0] - seg1Start[0]) * (seg0End[1] - seg0Start[1]);
339 if (Math.abs(denom) <= epsilon) { 339 if (Math.abs(denom) <= epsilon) {
@@ -349,7 +349,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
349 paramSeg1 /= denom; 349 paramSeg1 /= denom;
350 350
351 //check whether the parameters are both between 0 and 1 351 //check whether the parameters are both between 0 and 1
352 if (Math.abs(paramSeg0) > 1.0 || Math.abs(paramSeg1) > 1.0) { 352 if (mustLieInSegements && (Math.abs(paramSeg0) > 1.0 || Math.abs(paramSeg1) > 1.0)) {
353 return null; //no intersection unless the the intersection point lies on both segments 353 return null; //no intersection unless the the intersection point lies on both segments
354 } 354 }
355 355
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 5a128408..d7f29caa 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -244,6 +244,38 @@ exports.ViewUtils = Montage.create(Component, {
244 } 244 }
245 }, 245 },
246 246
247 getElementBoundsInGlobal: {
248 value: function (elt) {
249 this.pushViewportObj(elt);
250 var bounds3D = this.getElementViewBounds3D(elt);
251 var tmpMat = this.getLocalToGlobalMatrix(elt);
252
253 var zoomFactor = 1;
254 var stage = this.application.ninja.stage;
255 if (stage._viewport && stage._viewport.style && stage._viewport.style.zoom) {
256 zoomFactor = Number(stage._viewport.style.zoom);
257 }
258
259 var sSL = stage._scrollLeft;
260 var sST = stage._scrollTop;
261
262 for (var j=0; j<4; j++) {
263 var localPt = bounds3D[j];
264 var tmpPt = this.localToGlobal2(localPt, tmpMat);
265
266 if(zoomFactor !== 1) {
267 tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor);
268
269 tmpPt[0] += sSL*(zoomFactor - 1);