aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/body-controller.js40
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js26
-rwxr-xr-xjs/tools/RotateStage3DTool.js16
3 files changed, 72 insertions, 10 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 839d0787..14aeae24 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -51,5 +51,45 @@ exports.BodyController = Montage.create(ElementController, {
51 return dist; 51 return dist;
52 } 52 }
53 } 53 }
54 },
55
56 getMatrix: {
57 value: function(el) {
58 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d)
59 {
60 return el.elementModel.props3D.matrix3d.slice(0);
61 }
62 else
63 {
64 var mat;
65
66 if (el)
67 {
68 mat = this.application.ninja.stylesController.getMatrixFromElement(el, true);
69 if (!mat) {
70 mat = Matrix.I(4);
71 }
72
73 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
74 if (zoom)
75 {
76 zoom = Number(zoom);
77 if (zoom != 1)
78 {
79 var zoomMat = Matrix.create( [
80 [ zoom, 0, 0, 0],
81 [ 0, zoom, 0, 0],
82 [ 0, 0, zoom, 0],
83 [ 0, 0, 0, 1]
84 ] );
85 glmat4.multiply( zoomMat, mat, mat );
86 }
87 }
88 }
89
90 el.elementModel.props3D.matrix3d = mat;
91 return mat;
92 }
93 }
54 } 94 }
55}); 95});
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 7bd77c3a..f7b02485 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -583,17 +583,24 @@ 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 width = this.application.ninja.currentDocument.documentRoot.scrollWidth;
593 height = this.application.ninja.currentDocument.documentRoot.scrollHeight;
594 } else {
595 width = this.snapManager.getStageWidth();
596 height = this.snapManager.getStageHeight();
597 }
586 // get a matrix from working plane space to the world 598 // get a matrix from working plane space to the world
587 var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); 599 var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane);
588 var tMat = Matrix.Translation( [0.5*this.snapManager.getStageWidth(), 0.5*this.snapManager.getStageHeight(),0] ); 600 var tMat = Matrix.Translation( [0.5*width, 0.5*height, 0] );
589 //mat = tMat.multiply(mat); 601 //mat = tMat.multiply(mat);
590 glmat4.multiply( tMat, mat, mat); 602 glmat4.multiply( tMat, mat, mat);
591 603
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. 604 // the positioning of the grid may depend on the view direction.
598 var stage = this.snapManager.getStage(); 605 var stage = this.snapManager.getStage();
599 var viewMat = this.viewUtils.getMatrixFromElement(stage); 606 var viewMat = this.viewUtils.getMatrixFromElement(stage);
@@ -662,6 +669,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
662 var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt); 669 var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt);
663 offset[2] = 0; 670 offset[2] = 0;
664 this.viewUtils.setViewportObj(this._sourceSpaceElt); 671 this.viewUtils.setViewportObj(this._sourceSpaceElt);
672 var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt );
665 for (var i = 0; i < nLines; i++) { 673 for (var i = 0; i < nLines; i++) {
666 // transform the points from working plane space to world space 674 // transform the points from working plane space to world space
667 //var t0 = mat.multiply(p0), 675 //var t0 = mat.multiply(p0),
@@ -671,8 +679,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
671 679
672 // transform from world space to global screen space 680 // transform from world space to global screen space
673 if (this._sourceSpaceElt) { 681 if (this._sourceSpaceElt) {
674 t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); 682// t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt);
675 t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); 683// t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt);
684 t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat);
685 t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat);
676 } 686 }
677 687
678 // create a line from the endpoints 688 // create a line from the endpoints
diff --git a/js/tools/RotateStage3DTool.js b/js/tools/RotateStage3DTool.js
index d1701304..0210289f 100755
--- a/js/tools/RotateStage3DTool.js
+++ b/js/tools/RotateStage3DTool.js
@@ -96,6 +96,11 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
96 viewUtils.pushViewportObj( stage ); 96 viewUtils.pushViewportObj( stage );
97 var eltCtr = viewUtils.getCenterOfProjection(); 97 var eltCtr = viewUtils.getCenterOfProjection();
98 viewUtils.popViewportObj(); 98 viewUtils.popViewportObj();
99 if(this.application.ninja.documentController.webTemplate)
100 {
101 eltCtr[0] = stage.scrollWidth/2;
102 eltCtr[1] = stage.scrollHeight/2;
103 }
99 104
100 var curMat = viewUtils.getMatrixFromElement(stage); 105 var curMat = viewUtils.getMatrixFromElement(stage);
101 var curMatInv = glmat4.inverse(curMat, []); 106 var curMatInv = glmat4.inverse(curMat, []);
@@ -113,8 +118,15 @@ exports.RotateStage3DTool = Montage.create(Rotate3DToolBase, {
113 118
114 this._origin = viewUtils.localToGlobal(eltCtr, stage); 119 this._origin = viewUtils.localToGlobal(eltCtr, stage);
115 120
116 this._setTransformOrigin(false); 121 if(this.application.ninja.documentController.webTemplate)
117 122 {
123 this._startOriginArray = [];
124 this._startOriginArray.push(this._origin.slice());
125 }
126 else
127 {
128 this._setTransformOrigin(false);
129 }
118 this.DrawHandles(); 130 this.DrawHandles();
119 } 131 }
120 }, 132 },