aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D
diff options
context:
space:
mode:
authorJon Reid2012-05-04 14:56:24 -0700
committerJon Reid2012-05-04 14:56:24 -0700
commita6dd2917edcfeca1be7553e03281ddd538422ae1 (patch)
treee6846626bf1e967e80bcd652f6a76bb97abb1789 /js/helper-classes/3D
parent7fc185cc08b2ba912dbc7bce96f6a465c1dd6dbf (diff)
parent8964e070fa760d23c2de272ca36b8d9beba6007d (diff)
downloadninja-a6dd2917edcfeca1be7553e03281ddd538422ae1.tar.gz
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js61
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js12
2 files changed, 61 insertions, 12 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 7bd77c3a..88830964 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -583,17 +583,25 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
583 // get a point that lies on the plane 583 // get a point that lies on the plane
584 var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane); 584 var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane);
585 585
586 // define the grid parameters
587 var width,
588 height,
589 nLines = 10;
590
591// if(this.application.ninja.documentController.webTemplate) {
592 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
593 width = this.application.ninja.currentDocument.documentRoot.scrollWidth;
594 height = this.application.ninja.currentDocument.documentRoot.scrollHeight;
595 } else {
596 width = this.snapManager.getStageWidth();
597 height = this.snapManager.getStageHeight();
598 }
586 // get a matrix from working plane space to the world 599 // get a matrix from working plane space to the world
587 var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); 600 var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane);
588 var tMat = Matrix.Translation( [0.5*this.snapManager.getStageWidth(), 0.5*this.snapManager.getStageHeight(),0] ); 601 var tMat = Matrix.Translation( [0.5*width, 0.5*height, 0] );
589 //mat = tMat.multiply(mat); 602 //mat = tMat.multiply(mat);
590 glmat4.multiply( tMat, mat, mat); 603 glmat4.multiply( tMat, mat, mat);
591 604
592 // define the grid parameters
593 var width = this.snapManager.getStageWidth(),
594 height = this.snapManager.getStageHeight();
595 var nLines = 10;
596
597 // the positioning of the grid may depend on the view direction. 605 // the positioning of the grid may depend on the view direction.
598 var stage = this.snapManager.getStage(); 606 var stage = this.snapManager.getStage();
599 var viewMat = this.viewUtils.getMatrixFromElement(stage); 607 var viewMat = this.viewUtils.getMatrixFromElement(stage);
@@ -643,6 +651,21 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
643 this._lineColor = saveColor; 651 this._lineColor = saveColor;
644 this._drawingContext.lineWidth = saveLineWidth; 652 this._drawingContext.lineWidth = saveLineWidth;
645 653
654 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
655 // draw an outline around the body
656 var stagePt = MathUtils.getPointOnPlane([0,0,1,0]);
657 var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt);
658 // glmat4.multiply( tMat, stageMat, stageMat);
659 pt0 = [0, 0, 0];
660 pt1 = [0, height, 0];
661 delta = [width, 0, 0];
662 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
663 pt0 = [0, 0, 0];
664 pt1 = [width, 0, 0];
665 delta = [0, height, 0];
666 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
667 }
668
646 // draw the lines 669 // draw the lines
647 this.redrawGridLines(); 670 this.redrawGridLines();
648 671
@@ -662,6 +685,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
662 var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt); 685 var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt);
663 offset[2] = 0; 686 offset[2] = 0;
664 this.viewUtils.setViewportObj(this._sourceSpaceElt); 687 this.viewUtils.setViewportObj(this._sourceSpaceElt);
688 var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt );
665 for (var i = 0; i < nLines; i++) { 689 for (var i = 0; i < nLines; i++) {
666 // transform the points from working plane space to world space 690 // transform the points from working plane space to world space
667 //var t0 = mat.multiply(p0), 691 //var t0 = mat.multiply(p0),
@@ -671,8 +695,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
671 695
672 // transform from world space to global screen space 696 // transform from world space to global screen space
673 if (this._sourceSpaceElt) { 697 if (this._sourceSpaceElt) {
674 t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); 698// t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt);
675 t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); 699// t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt);
700 t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat);
701 t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat);
676 } 702 }
677 703
678 // create a line from the endpoints 704 // create a line from the endpoints
@@ -741,12 +767,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
741 this._drawingContext.lineWidth = 0.25; 767 this._drawingContext.lineWidth = 0.25;
742 768
743 // draw the lines 769 // draw the lines
744 var nLines = this._gridLineArray.length; 770 var line,
771 nLines = this._gridLineArray.length;
772 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
773 nLines = this._gridLineArray.length-4;
774 }
775
745 for (var i = 0; i < nLines; i++) { 776 for (var i = 0; i < nLines; i++) {
746 var line = this._gridLineArray[i]; 777 line = this._gridLineArray[i];
747 this.drawIntersectedLine(line, this._drawingContext); 778 this.drawIntersectedLine(line, this._drawingContext);
748 } 779 }
749 780
781 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
782 this._lineColor = "red";
783 i = nLines;
784 nLines += 4;
785 for (; i < nLines; i++) {
786 line = this._gridLineArray[i];
787 this.drawIntersectedLine(line, this._drawingContext);
788 }
789 }
790
750 this.popState(); 791 this.popState();
751 } 792 }
752 }, 793 },
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 7fc492a5..f4bfc12b 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -1617,7 +1617,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1617 if (x > y) { 1617 if (x > y) {
1618 if (x > z) { 1618 if (x > z) {
1619 plane[0] = 1; 1619 plane[0] = 1;
1620 plane[3] = this.getStageWidth() / 2.0; 1620 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
1621 plane[3] = stage.scrollWidth / 2.0;
1622 } else {
1623 plane[3] = this.getStageWidth() / 2.0;
1624 }
1621 if (dir[0] > 0) plane[3] = -plane[3]; 1625 if (dir[0] > 0) plane[3] = -plane[3];
1622 change = !drawUtils.drawYZ; 1626 change = !drawUtils.drawYZ;
1623 drawUtils.drawXY = drawUtils.drawXZ = false; 1627 drawUtils.drawXY = drawUtils.drawXZ = false;
@@ -1635,7 +1639,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1635 else { 1639 else {
1636 if (y > z) { 1640 if (y > z) {
1637 plane[1] = 1; 1641 plane[1] = 1;
1638 plane[3] = this.getStageHeight() / 2.0; 1642 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") {
1643 plane[3] = stage.scrollHeight / 2.0;
1644 } else {
1645 plane[3] = this.getStageHeight() / 2.0;
1646 }
1639 if (dir[1] > 0) plane[3] = -plane[3]; 1647 if (dir[1] > 0) plane[3] = -plane[3];
1640 change = !drawUtils.drawXZ; 1648 change = !drawUtils.drawXZ;
1641 drawUtils.drawXY = drawUtils.drawYZ = false; 1649 drawUtils.drawXY = drawUtils.drawYZ = false;