From dde27659a9028c131884f0654f01206347512a81 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 19 Jun 2012 16:32:42 -0700 Subject: Added logic to handle grid drawing where grid line starts on an object boundary --- js/helper-classes/3D/StageLine.js | 309 ++++++++++++++++++++++---------------- 1 file changed, 177 insertions(+), 132 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js index b86673d1..23e8cf5b 100755 --- a/js/helper-classes/3D/StageLine.js +++ b/js/helper-classes/3D/StageLine.js @@ -184,138 +184,183 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { }, doCoplanarIntersection: { - value: function( plane ) - { - // get the boundary points for the plane - var boundaryPts = plane.getBoundaryPoints(); - var planeEq = plane.getPlaneEq(); - - if (plane.isBackFacing()) - { - var tmp; - tmp = boundaryPts[0]; boundaryPts[0] = boundaryPts[3]; boundaryPts[3] = tmp; - tmp = boundaryPts[1]; boundaryPts[1] = boundaryPts[2]; boundaryPts[2] = tmp; - } - - var pt0 = this.getPoint0(), - pt1 = this.getPoint1(); - - // keep a couple flags to prevent counting crossings twice in edge cases - var gotEnter = false, - gotExit = false; - - var bp1 = boundaryPts[3]; - for (var i=0; i<4; i++) - { - var bp0 = bp1; - bp1 = boundaryPts[i]; - var vec = vecUtils.vecSubtract(3, bp1, bp0); - var nrm = vecUtils.vecCross(3, vec, planeEq); - nrm[3] = -vecUtils.vecDot(3, bp0, nrm); - - var d0 = vecUtils.vecDot(3, nrm, pt0) + nrm[3], - d1 = vecUtils.vecDot(3, nrm, pt1) + nrm[3]; - - var s0 = MathUtils.fpSign(d0), - s1 = MathUtils.fpSign(d1); - - if (s0 != s1) - { - var t = Math.abs(d0)/( Math.abs(d0) + Math.abs(d1) ); - if ( (MathUtils.fpSign(t) >= 0) && (MathUtils.fpCmp(t,1.0) <= 0)) - { - // get the point where the line crosses the edge of the element plane - var pt = MathUtils.interpolateLine3D(pt0, pt1, t ); - - // we know that the line crosses the infinite extension of the edge. Determine - // if that crossing is within the bounds of the edge - var dot0 = vecUtils.vecDot(3, vecUtils.vecSubtract(3,pt, bp0), vec), - dot1 = vecUtils.vecDot(3, vecUtils.vecSubtract(3,pt, bp1), vec); - if ((MathUtils.fpSign(dot0) > 0) && (MathUtils.fpSign(dot1) < 0)) - { - // determine if the line is entering or exiting - if (s0 <= 0) // entering - { - if (!gotEnter) - { - gotEnter = true; - this.addIntersection( plane, t, 1 ); - } - } - else if (s0 > 0) // exiting - { - if (!gotExit) - { - gotExit = true; - this.addIntersection( plane, t, -1 ); - } - } - else // s0 == 0 - { - // TODO - } - } - else if ((MathUtils.fpSign(dot0) == 0) && (MathUtils.fpSign(dot1) < 0)) - { - var j = i - 2; - if (j < 0) j += 4; - var bp = boundaryPts[j]; - - var v0 = vecUtils.vecSubtract( 3, bp, bp0 ), - v1 = vec; - - if (s0 <= 0) - { - var v = vecUtils.vecSubtract(3, pt1, pt0); - if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) > 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) > 0)) - { - gotEnter = true; - this.addIntersection( plane, t, 1 ); - } - } - else if (s0 > 0) - { - var v = vecUtils.vecSubtract(3, pt0, pt1); // note the reversed order from the previous case - if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) > 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) > 0)) - { - gotEnter = true; - this.addIntersection( plane, t, -1 ); - } - } - } - else if ((MathUtils.fpSign(dot0) > 0) && (MathUtils.fpSign(dot1) == 0)) - { - var j = (i + 1) % 4; - var bp = boundaryPts[j]; - - var v1 = vec.slice(0), - v0 = vecUtils.vecSubtract( 3, bp, bp1 ), - v1 = vecUtils.vecNegate(3, v1); - - if (s0 <= 0) - { - var v = vecUtils.vecSubtract(3, pt1, pt0); - if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) < 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) < 0)) - { - gotEnter = true; - this.addIntersection( plane, t, 1 ); - } - } - else if (s0 > 0) - { - var v = vecUtils.vecSubtract(3, pt0, pt1); // note the reversed order from the previous case - if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) > 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) > 0)) - { - gotEnter = true; - this.addIntersection( plane, t, -1 ); - } - } - } - } - } - } - } - }, + value: function( plane ) + { + // get the boundary points for the plane + var boundaryPts = plane.getBoundaryPoints(); + var planeEq = plane.getPlaneEq(); + + if (plane.isBackFacing()) + { + var tmp; + tmp = boundaryPts[0]; boundaryPts[0] = boundaryPts[3]; boundaryPts[3] = tmp; + tmp = boundaryPts[1]; boundaryPts[1] = boundaryPts[2]; boundaryPts[2] = tmp; + } + + var pt0 = this.getPoint0(), + pt1 = this.getPoint1(); + + // keep a couple flags to prevent counting crossings twice in edge cases + var gotEnter = false, + gotExit = false; + + var bp1 = boundaryPts[3]; + for (var i=0; i<4; i++) + { + var bp0 = bp1; + bp1 = boundaryPts[i]; + var vec = vecUtils.vecSubtract(3, bp1, bp0); + var nrm = vecUtils.vecCross(3, vec, planeEq); + nrm[3] = -vecUtils.vecDot(3, bp0, nrm); + + var d0 = vecUtils.vecDot(3, nrm, pt0) + nrm[3], + d1 = vecUtils.vecDot(3, nrm, pt1) + nrm[3]; + + var s0 = MathUtils.fpSign(d0), + s1 = MathUtils.fpSign(d1); + + if (s0 != s1) + { + var t = Math.abs(d0)/( Math.abs(d0) + Math.abs(d1) ); + if (t == 0) + { + if (s1 > 0) // entering the material from the beginning of the line that is to be drawn + { + // see if the start point of the line is at a corner of the bounded plane + var lineDir = vecUtils.vecSubtract(3, pt1, pt0); + vecUtils.vecNormalize(3, lineDir); + var dist = vecUtils.vecDist( 3, pt0, bp1 ); + var bp2, bv0, bv1, cross1, cross2, cross3; + if ( MathUtils.fpSign(dist) == 0) + { + bp2 = boundaryPts[(i+1) % 4]; + bv0 = vecUtils.vecSubtract(3, bp2, bp1); + bv1 = vecUtils.vecSubtract(3, bp0, bp1); + cross1 = vecUtils.vecCross(3, bv0, lineDir); + cross2 = vecUtils.vecCross(3, lineDir, bv1); + cross3 = vecUtils.vecCross(3, bv0, bv1); + if ( (MathUtils.fpSign(vecUtils.vecDot(3, cross1, cross3)) == 0) && (MathUtils.fpSign(vecUtils.vecDot(3, cross2, cross3)) == 0)) + { + gotEnter = true; + this.addIntersection( plane, t, 1 ); + } + } + else if (MathUtils.fpSign( vecUtils.vecDist(3, pt0, bp0)) === 0) + { + bp2 = boundaryPts[(i+2) % 4]; + bv0 = vecUtils.vecSubtract(3, bp2, bp0); + bv1 = vecUtils.vecSubtract(3, bp1, bp0); + cross1 = vecUtils.vecCross(3, bv0, lineDir); + cross2 = vecUtils.vecCross(3, lineDir, bv1); + cross3 = vecUtils.vecCross(3, bv0, bv1); + if ( (MathUtils.fpSign(vecUtils.vecDot(3, cross1, cross3)) == 0) && (MathUtils.fpSign(vecUtils.vecDot(3, cross2, cross3)) == 0)) + { + gotEnter = true; + this.addIntersection( plane, t, 1 ); + } + } + else + { + // check if the line is on the edge of the boundary or goes to the interior + gotEnter = true; + this.addIntersection( plane, t, 1 ); + } + } + } + else if ( (MathUtils.fpSign(t) > 0) && (MathUtils.fpCmp(t,1.0) <= 0)) + { + // get the point where the line crosses the edge of the element plane + var pt = MathUtils.interpolateLine3D(pt0, pt1, t ); + + // we know that the line crosses the infinite extension of the edge. Determine + // if that crossing is within the bounds of the edge + var dot0 = vecUtils.vecDot(3, vecUtils.vecSubtract(3,pt, bp0), vec), + dot1 = vecUtils.vecDot(3, vecUtils.vecSubtract(3,pt, bp1), vec); + if ((MathUtils.fpSign(dot0) > 0) && (MathUtils.fpSign(dot1) < 0)) + { + // determine if the line is entering or exiting + if (s0 <= 0) // entering + { + if (!gotEnter) + { + gotEnter = true; + this.addIntersection( plane, t, 1 ); + } + } + else if (s0 > 0) // exiting + { + if (!gotExit) + { + gotExit = true; + this.addIntersection( plane, t, -1 ); + } + } + else // s0 == 0 + { + // TODO + } + } + else if ((MathUtils.fpSign(dot0) == 0) && (MathUtils.fpSign(dot1) < 0)) + { + var j = i - 2; + if (j < 0) j += 4; + var bp = boundaryPts[j]; + + var v0 = vecUtils.vecSubtract( 3, bp, bp0 ), + v1 = vec; + + if (s0 <= 0) + { + var v = vecUtils.vecSubtract(3, pt1, pt0); + if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) > 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) > 0)) + { + gotEnter = true; + this.addIntersection( plane, t, 1 ); + } + } + else if (s0 > 0) + { + var v = vecUtils.vecSubtract(3, pt0, pt1); // note the reversed order from the previous case + if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) > 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) > 0)) + { + gotEnter = true; + this.addIntersection( plane, t, -1 ); + } + } + } + else if ((MathUtils.fpSign(dot0) > 0) && (MathUtils.fpSign(dot1) == 0)) + { + var j = (i + 1) % 4; + var bp = boundaryPts[j]; + + var v1 = vec.slice(0), + v0 = vecUtils.vecSubtract( 3, bp, bp1 ), + v1 = vecUtils.vecNegate(3, v1); + + if (s0 <= 0) + { + var v = vecUtils.vecSubtract(3, pt1, pt0); + if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) < 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) < 0)) + { + gotEnter = true; + this.addIntersection( plane, t, 1 ); + } + } + else if (s0 > 0) + { + var v = vecUtils.vecSubtract(3, pt0, pt1); // note the reversed order from the previous case + if ((MathUtils.fpSign(vecUtils.vecCross(3, v0,v)) > 0) && (MathUtils.fpSign(vecUtils.vecCross(3, v,v1)) > 0)) + { + gotEnter = true; + this.addIntersection( plane, t, -1 ); + } + } + } + } + } + } + } + }, removeIntersections: { value: function() -- cgit v1.2.3 From 22e664cdbb4bdf54cde87c0c3223e321e18ea372 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 19 Jun 2012 21:34:35 -0700 Subject: IKNINJA-1671 - GIO: 3D rotate widget is offset from the object when rotated in negative space. I fixed this temporarily by disabling the auto stage scroll calculations when we modify matrices. The correct fix will be to update any matrices and local2Global caches if we update the stage's padding (which I'm doing in a separate fix for a single draw cycle for the stage, but that fix is not ready yet). Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 46 +++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 6a84c86b..177c844f 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -247,18 +247,18 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // TODO - Check why handleElementChange is being fired before handleAddElement handleElementChange: { value: function(event) { - this._elementChangeHelper(event); + this._elementChangeHelper(event, false); } }, handleElementChanging: { value: function(event) { - this._elementChangeHelper(event); + this._elementChangeHelper(event, true); } }, _elementChangeHelper: { - value: function(event) { + value: function(event, isChanging) { if(!event.detail || !event.detail.data) { return; } @@ -273,35 +273,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { l, t, plane, - changed = false; + changed = false, + adjustStagePadding = !isChanging || (event.detail.data.prop !== "matrix"); for(var i=0; i < len; i++) { plane = els[i].elementModel.props3D.elementPlane; if(plane) { plane.init(); - l = plane._rect.m_left - docLeft; - t = plane._rect.m_top - docTop; - if(l < minLeft) { - minLeft = l; - } - if(t < minTop) { - minTop = t; + if(adjustStagePadding) { + l = plane._rect.m_left - docLeft; + t = plane._rect.m_top - docTop; + if(l < minLeft) { + minLeft = l; + } + if(t < minTop) { + minTop = t; + } } } } - if(minLeft !== stage.userPaddingLeft) { - stage.userPaddingLeft = minLeft; - changed = true; - } - if(minTop !== stage.userPaddingTop) { - stage.userPaddingTop = minTop; - changed = true; + if(adjustStagePadding) { + if(minLeft !== stage.userPaddingLeft) { + stage.userPaddingLeft = minLeft; + changed = true; + } + if(minTop !== stage.userPaddingTop) { + stage.userPaddingTop = minTop; + changed = true; + } } if(!changed) { this.drawWorkingPlane(); this.draw3DCompass(); } + + // TODO - Remove this once all stage drawing is consolidated into a single draw cycle + if(!isChanging) { + this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn(null); + } } } }, -- cgit v1.2.3 From 6a0a5f6e7dec5e8ced6e228e7bbfcc1181f46c26 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 20 Jun 2012 11:55:55 -0700 Subject: Fix for error when using ZoomTool. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 177c844f..8ddd0d52 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -309,7 +309,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } // TODO - Remove this once all stage drawing is consolidated into a single draw cycle - if(!isChanging) { + if(!isChanging && this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn) { this.application.ninja.toolsData.selectedToolInstance.captureSelectionDrawn(null); } } -- cgit v1.2.3 From cf3b17036985243ecbcafdf55189530c797c78a7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 21 Jun 2012 15:33:18 -0700 Subject: Draw stage left and top references lines. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 65 ++++++++++++++++++-------------------- js/helper-classes/3D/math-utils.js | 4 +-- js/helper-classes/3D/view-utils.js | 32 +++++++++++++++++++ 3 files changed, 65 insertions(+), 36 deletions(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 8ddd0d52..c31424eb 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, { value: function () { this.application.ninja.stage.clearGridCanvas(); + this.drawStageOutline(); if (!this.isDrawingGrid()) return; var saveContext = this.getDrawingSurfaceElement(); @@ -701,21 +702,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this._lineColor = saveColor; this._drawingContext.lineWidth = saveLineWidth; - if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { - // draw an outline around the body - var stagePt = MathUtils.getPointOnPlane([0,0,1,0]); - var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt); - // glmat4.multiply( tMat, stageMat, stageMat); - pt0 = [0, 0, 0]; - pt1 = [0, height, 0]; - delta = [width, 0, 0]; - this.drawGridLines(pt0, pt1, delta, stageMat, 2); - pt0 = [0, 0, 0]; - pt1 = [width, 0, 0]; - delta = [0, height, 0]; - this.drawGridLines(pt0, pt1, delta, stageMat, 2); - } - // draw the lines this.redrawGridLines(); @@ -738,15 +724,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); for (var i = 0; i < nLines; i++) { // transform the points from working plane space to world space - //var t0 = mat.multiply(p0), - // t1 = mat.multiply(p1); var t0 = glmat4.multiplyVec3( mat, p0, [] ), t1 = glmat4.multiplyVec3( mat, p1, [] ); // transform from world space to global screen space if (this._sourceSpaceElt) { -// t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); -// t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); } @@ -764,9 +746,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { line.setVisibility(vis); // increment the points to the next position -// p0 = p0.add(d); p0[3] = 1.0; p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0; -// p1 = p1.add(d); p1[3] = 1.0; p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0; } } @@ -819,25 +799,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // draw the lines var line, nLines = this._gridLineArray.length; - if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { - nLines = this._gridLineArray.length-4; - } for (var i = 0; i < nLines; i++) { line = this._gridLineArray[i]; this.drawIntersectedLine(line, this._drawingContext); } - if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { - this._lineColor = "red"; - i = nLines; - nLines += 4; - for (; i < nLines; i++) { - line = this._gridLineArray[i]; - this.drawIntersectedLine(line, this._drawingContext); - } - } - this.popState(); } }, @@ -1213,6 +1180,36 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } }, + drawStageOutline : { + value: function() { + var context = this.application.ninja.stage.gridContext; + var stage = this.application.ninja.stage; + var stageRoot = this.application.ninja.currentDocument.model.documentRoot; + var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot); + + var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); + var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); + + var t = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, 0, 0], [stage.canvas.width, 0, 0], 0.1); + var b = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, stage.canvas.height, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); + context.save(); + context.strokeStyle = "#333"; + context.lineWidth = 0.5; + + context.beginPath(); + + context.moveTo(l[0], l[1]); + context.lineTo(r[0], r[1]); + + context.moveTo(t[0], t[1]); + context.lineTo(b[0], b[1]); + + context.closePath(); + context.stroke(); + context.restore(); + } + }, + draw3DCompass : { value: function() { // 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, { //returns the intersection point between the two segments (null if no intersection) segSegIntersection2D: { - value: function (seg0Start, seg0End, seg1Start, seg1End, epsilon) { + value: function (seg0Start, seg0End, seg1Start, seg1End, epsilon, mustLieInSegements) { //check for parallel segments var denom = (seg1End[1] - seg1Start[1]) * (seg0End[0] - seg0Start[0]) - (seg1End[0] - seg1Start[0]) * (seg0End[1] - seg0Start[1]); if (Math.abs(denom) <= epsilon) { @@ -349,7 +349,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { paramSeg1 /= denom; //check whether the parameters are both between 0 and 1 - if (Math.abs(paramSeg0) > 1.0 || Math.abs(paramSeg1) > 1.0) { + if (mustLieInSegements && (Math.abs(paramSeg0) > 1.0 || Math.abs(paramSeg1) > 1.0)) { return null; //no intersection unless the the intersection point lies on both segments } 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, { } }, + getElementBoundsInGlobal: { + value: function (elt) { + this.pushViewportObj(elt); + var bounds3D = this.getElementViewBounds3D(elt); + var tmpMat = this.getLocalToGlobalMatrix(elt); + + var zoomFactor = 1; + var stage = this.application.ninja.stage; + if (stage._viewport && stage._viewport.style && stage._viewport.style.zoom) { + zoomFactor = Number(stage._viewport.style.zoom); + } + + var sSL = stage._scrollLeft; + var sST = stage._scrollTop; + + for (var j=0; j<4; j++) { + var localPt = bounds3D[j]; + var tmpPt = this.localToGlobal2(localPt, tmpMat); + + if(zoomFactor !== 1) { + tmpPt = vecUtils.vecScale(3, tmpPt, zoomFactor); + + tmpPt[0] += sSL*(zoomFactor - 1); + tmpPt[1] += sST*(zoomFactor - 1); + } + bounds3D[j] = tmpPt; + } + this.popViewportObj(); + return bounds3D; + } + }, + getCenterOfProjection: { value: function() { var cop; -- cgit v1.2.3 From 330a954e92dfc95fae6ae5cf10dd5998f346b304 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 22 Jun 2012 10:59:17 -0700 Subject: Have to guard against cases when stage lines are parallel to the canvas and the line intersection routine returns null. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index c31424eb..168d550d 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -1188,10 +1188,15 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot); var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); + if(!l) return; var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); + if(!r) return; var t = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, 0, 0], [stage.canvas.width, 0, 0], 0.1); + if(!t) return; var b = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, stage.canvas.height, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); + if(!b) return; + context.save(); context.strokeStyle = "#333"; context.lineWidth = 0.5; -- cgit v1.2.3 From cd7ba9648312a3f55fae9c33285be1d9540e13f9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 22 Jun 2012 11:15:46 -0700 Subject: Display "(0, 0)" where the origin is. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 168d550d..bd47ffc3 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -1211,6 +1211,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { context.closePath(); context.stroke(); + + context.fillText("(0, 0)", bounds3D[0][0] + 4, bounds3D[0][1] - 6); context.restore(); } }, -- cgit v1.2.3