aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/draw-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/draw-utils.js')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js27
1 files changed, 19 insertions, 8 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 7bd77c3a..81a740e0 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);
@@ -662,6 +670,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
662 var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt); 670 var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt);
663 offset[2] = 0; 671 offset[2] = 0;
664 this.viewUtils.setViewportObj(this._sourceSpaceElt); 672 this.viewUtils.setViewportObj(this._sourceSpaceElt);
673 var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt );
665 for (var i = 0; i < nLines; i++) { 674 for (var i = 0; i < nLines; i++) {
666 // transform the points from working plane space to world space 675 // transform the points from working plane space to world space
667 //var t0 = mat.multiply(p0), 676 //var t0 = mat.multiply(p0),
@@ -671,8 +680,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
671 680
672 // transform from world space to global screen space 681 // transform from world space to global screen space
673 if (this._sourceSpaceElt) { 682 if (this._sourceSpaceElt) {
674 t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); 683// t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt);
675 t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); 684// t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt);
685 t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat);
686 t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat);
676 } 687 }
677 688
678 // create a line from the endpoints 689 // create a line from the endpoints