From 96bfeee2e6b735b87e8482d6e2cf24d5224c6417 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 5 Apr 2012 17:03:14 -0700 Subject: translate3DObject tool fixes. --- js/helper-classes/3D/view-utils.js | 45 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'js/helper-classes/3D/view-utils.js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index a72b7906..392de0be 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -112,6 +112,13 @@ exports.ViewUtils = Montage.create(Component, { var mat = this.getMatrixFromElement(elt); var plane = [mat[8], mat[9], mat[10], mat[11]]; + var stage = this.application.ninja.currentDocument.documentRoot; + if (elt === stage) + { + xVec = [1,0,0]; + yVec = [0,1,0]; + } + // The translation value is a point on the plane this.pushViewportObj( elt ); var ptOnPlane = this.getCenterOfProjection(); @@ -137,6 +144,12 @@ exports.ViewUtils = Montage.create(Component, { var stageMat = this.getMatrixFromElement(stage); var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]]; + if (elt === stage) + { + xVec = [1,0,0]; + yVec = [0,1,0]; + } + var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane)); var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane)); @@ -788,35 +801,23 @@ exports.ViewUtils = Montage.create(Component, { } }, - getStageWorldToGlobalMatrix: { - value: function() { + getStageWorldToGlobalMatrix: + { + value: function() + { var stage = this.application.ninja.currentDocument.documentRoot; this.pushViewportObj( stage ); - - // get the matrix to the parent - var mat = Matrix.I(4); - //var projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(stage) ); - var p = this.getPerspectiveDistFromElement(stage); - var projMat = glmat4.scale( Matrix.I(4), [p,p,p], [] ); - projMat[11] = -1; + + // put the point into screen space of the stage - requires + // a translation to the top/left only var cop = this.getCenterOfProjection(); var v2s = Matrix.Translation([cop[0], cop[1], 0]); - //mat = v2s.multiply( projMat ); - mat = glmat4.multiply( v2s, projMat, [] ); - - // offset to the parent - var offset = this.getElementOffset( stage ); - var offMat = Matrix.Translation([offset[0], offset[1], 0]); - //mat = offMat.multiply( mat ); - glmat4.multiply( offMat, mat, mat ); - this.popViewportObj(); - // var mat2 = this.getLocalToGlobalMatrix( stage.parentElement ); - var mat2 = this.getLocalToGlobalMatrix( this._rootElement ); - //var mat = mat2.multiply( mat ); - glmat4.multiply( mat2, mat, mat ); + // append the localToGlobal matrix of the stage. + var mat = this.getLocalToGlobalMatrix( stage ); + glmat4.multiply( mat, v2s ); return mat; } -- cgit v1.2.3 From 2bf707156eafeb5f6166c6f28cd385ef2c4b5a50 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 11 Apr 2012 11:05:12 -0700 Subject: offsets should be calculated on offsetParent instead of parentElement. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/view-utils.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'js/helper-classes/3D/view-utils.js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 55ecbc59..4a6c2503 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -259,7 +259,7 @@ exports.ViewUtils = Montage.create(Component, { // transform the point up the tree var child = elt; - var parent = elt.parentElement; + var parent = elt.offsetParent; while ( parent ) { // go to screen space of the current child @@ -287,7 +287,7 @@ exports.ViewUtils = Montage.create(Component, { } child = parent; - parent = parent.parentElement; + parent = parent.offsetParent; } return pt; @@ -303,7 +303,7 @@ exports.ViewUtils = Montage.create(Component, { // transform the bounds up the tree var child = elt; - var parent = elt.parentElement; + var parent = elt.offsetParent; while ( parent ) { pt = this.childToParent( pt, child ); @@ -311,7 +311,7 @@ exports.ViewUtils = Montage.create(Component, { if (parent === this._rootElement) break; child = parent; - parent = parent.parentElement; + parent = parent.offsetParent; } ///////////////////////////////////////////////////////// @@ -346,7 +346,7 @@ exports.ViewUtils = Montage.create(Component, { if (pt.length == 2) pt[2] = 0; // transform the bounds up the tree - var parent = child.parentElement; + var parent = child.offsetParent; if ( parent ) { this.setViewportObj( child ); @@ -394,7 +394,7 @@ exports.ViewUtils = Montage.create(Component, { pt[3] = 1; // transform the bounds up the tree - var parent = child.parentElement; + var parent = child.offsetParent; if ( parent ) { this.setViewportObj( child ); @@ -429,7 +429,7 @@ exports.ViewUtils = Montage.create(Component, { /* this.pushViewportObj( elt ); - var parent = elt.parentElement; + var parent = elt.offsetParent; var offset = this.getElementOffset( elt ); offset[2] = 0; var localEyePt = this.getCenterOfProjection(); @@ -987,7 +987,7 @@ exports.ViewUtils = Montage.create(Component, { if (elt === this._stageElement) break; if (elt === this._rootElement) break; - elt = elt.parentElement; + elt = elt.offsetParent; if (elt === this._rootElement) break; } @@ -1040,7 +1040,7 @@ exports.ViewUtils = Montage.create(Component, { //mat = offMat.multiply( mat ); glmat4.multiply( offMat, mat, mat ); - elt = elt.parentElement; + elt = elt.offsetParent; } return mat; -- cgit v1.2.3 From 3bbf32b285405562471fa594c283e271d347734e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 12 Apr 2012 10:52:32 -0700 Subject: Borders are not factored into offset calculations by the browser, so we have to adjust for them. Also, we should set webkit-transform-style to preserve-3d if elements are rotated (until we also support flattened mode). Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/view-utils.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/helper-classes/3D/view-utils.js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 4a6c2503..addabba5 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -658,6 +658,21 @@ exports.ViewUtils = Montage.create(Component, { // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; var offset = [xOff, yOff]; + if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) + { + var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); + + var border = parseInt(pS.getPropertyValue("border")); + + if(border) + { + var bl = parseInt(pS.getPropertyValue("border-left-width")), + bt = parseInt(pS.getPropertyValue("border-top-width")); + + offset[0] += bl; + offset[1] += bt; + } + } if(elt === this._stageElement) { -- cgit v1.2.3 From 77c6ab76ffe9fc380ed6fdb7b29ccd40acaee74d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 12 Apr 2012 14:24:25 -0700 Subject: Fixing selection/tag layout drawing when canvas and image elements have borders. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/view-utils.js | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'js/helper-classes/3D/view-utils.js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index addabba5..1cd1c313 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -603,19 +603,6 @@ exports.ViewUtils = Montage.create(Component, { w = elt.offsetWidth, h = elt.offsetHeight; - if(elt.width) - w = elt.width; - if(elt.height) - h = elt.height; - - if (elt.style) - { - if (elt.style.left) left = MathUtils.styleToNumber(elt.style.left); - if (elt.style.top) top = MathUtils.styleToNumber(elt.style.top); - if (elt.style.width) w = MathUtils.styleToNumber(elt.style.width); - if (elt.style.height) h = MathUtils.styleToNumber(elt.style.height); - } - // if (elt instanceof SVGSVGElement) { if(elt.nodeName.toLowerCase() === "svg") { if(w instanceof SVGAnimatedLength) -- cgit v1.2.3 From 521df0ed9242efff45715998837068c87aca7efd Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 13 Apr 2012 11:12:40 -0700 Subject: 3D Rotate changes --- js/helper-classes/3D/view-utils.js | 7 ------- 1 file changed, 7 deletions(-) (limited to 'js/helper-classes/3D/view-utils.js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 392de0be..f803a274 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -112,13 +112,6 @@ exports.ViewUtils = Montage.create(Component, { var mat = this.getMatrixFromElement(elt); var plane = [mat[8], mat[9], mat[10], mat[11]]; - var stage = this.application.ninja.currentDocument.documentRoot; - if (elt === stage) - { - xVec = [1,0,0]; - yVec = [0,1,0]; - } - // The translation value is a point on the plane this.pushViewportObj( elt ); var ptOnPlane = this.getCenterOfProjection(); -- cgit v1.2.3