aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js26
1 files changed, 18 insertions, 8 deletions
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