aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/helper-classes/3D/hit-record.js46
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js1
-rwxr-xr-xjs/helper-classes/3D/view-utils.js45
-rwxr-xr-xjs/tools/Translate3DToolBase.js7
-rwxr-xr-xjs/tools/modifier-tool-base.js2
5 files changed, 75 insertions, 26 deletions
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js
index 2c60adc6..96f87c24 100755
--- a/js/helper-classes/3D/hit-record.js
+++ b/js/helper-classes/3D/hit-record.js
@@ -284,6 +284,50 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
284 284
285 return str; 285 return str;
286 } 286 }
287 } 287 },
288
289 test:
290 {
291 value: function()
292 {
293 var elt = this.getElement();
294 var stage = viewUtils.getStage();
295 if (elt === stage) return;
296
297 var localPt = this.calculateElementPreTransformScreenPoint();
298 var stageWorldPt = this.calculateStageWorldPoint();
299 var globalPt = this.getScreenPoint();
300 var err = false;
301
302 var test1 = viewUtils.localToGlobal( localPt, elt );
303 var dist = vecUtils.vecDist(3, test1, globalPt);
304 if (MathUtils.fpSign(dist) != 0)
305 {
306 err = true;
307 console.log( "**** transform error 1 ***** " + dist + ", localPt: " + localPt );
308 }
309
310 var stageWorldToGlobal = viewUtils.getStageWorldToGlobalMatrix();
311 var test2 = MathUtils.transformAndDivideHomogeneousPoint( stageWorldPt, stageWorldToGlobal );
312 dist = vecUtils.vecDist(3, test2, globalPt);
313 if (MathUtils.fpSign(dist) != 0)
314 {
315 err = true;
316 console.log( "**** transform error 2 ***** " + dist + ", localPt: " + localPt );
317 }
318
319 var localToGlobal = viewUtils.getLocalToGlobalMatrix( elt );
320 var globalToLocal = glmat4.inverse( localToGlobal, [] );
321 var test3 = MathUtils.transformAndDivideHomogeneousPoint( globalPt, globalToLocal );
322 dist = vecUtils.vecDist(3, test3, localPt);
323 if (MathUtils.fpSign( vecUtils.vecDist(3, test3, localPt)) != 0)
324 {
325 err = true;
326 console.log( "**** transform error 3 ***** " + dist + ", localPt: " + localPt );
327 }
328
329 if (!err) console.log( "no hitRecord error" );
330 }
331 }
288}); 332});
289 333
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 9f6b9ed1..8eafa7e9 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -300,6 +300,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
300 this.deactivateDragPlane(); 300 this.deactivateDragPlane();
301 301
302 this.setLastHit( rtnHit ); 302 this.setLastHit( rtnHit );
303 //rtnHit.test(); // DEBUG CODE. REMOVE THIS
303 return rtnHit; 304 return rtnHit;
304 } 305 }
305 }, 306 },
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, {
112 var mat = this.getMatrixFromElement(elt); 112 var mat = this.getMatrixFromElement(elt);
113 var plane = [mat[8], mat[9], mat[10], mat[11]]; 113 var plane = [mat[8], mat[9], mat[10], mat[11]];
114 114
115 var stage = this.application.ninja.currentDocument.documentRoot;
116 if (elt === stage)
117 {
118 xVec = [1,0,0];
119 yVec = [0,1,0];
120 }
121
115 // The translation value is a point on the plane 122 // The translation value is a point on the plane
116 this.pushViewportObj( elt ); 123 this.pushViewportObj( elt );
117 var ptOnPlane = this.getCenterOfProjection(); 124 var ptOnPlane = this.getCenterOfProjection();
@@ -137,6 +144,12 @@ exports.ViewUtils = Montage.create(Component, {
137 var stageMat = this.getMatrixFromElement(stage); 144 var stageMat = this.getMatrixFromElement(stage);
138 var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]]; 145 var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]];
139 146
147 if (elt === stage)
148 {
149 xVec = [1,0,0];
150 yVec = [0,1,0];
151 }
152
140 var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane)); 153 var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane));
141 var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane)); 154 var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane));
142 155
@@ -788,35 +801,23 @@ exports.ViewUtils = Montage.create(Component, {
788 } 801 }
789 }, 802 },
790 803
791 getStageWorldToGlobalMatrix: { 804 getStageWorldToGlobalMatrix:
792 value: function() { 805 {
806 value: function()
807 {
793 var stage = this.application.ninja.currentDocument.documentRoot; 808 var stage = this.application.ninja.currentDocument.documentRoot;
794 this.pushViewportObj( stage ); 809 this.pushViewportObj( stage );
795 810
796 // get the matrix to the parent 811 // put the point into screen space of the stage - requires
797 var mat = Matrix.I(4); 812 // a translation to the top/left only
798 //var projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(stage) );
799 var p = this.getPerspectiveDistFromElement(stage);
800 var projMat = glmat4.scale( Matrix.I(4), [p,p,p], [] );
801 projMat[11] = -1;
802 var cop = this.getCenterOfProjection(); 813 var cop = this.getCenterOfProjection();
803 var v2s = Matrix.Translation([cop[0], cop[1], 0]); 814 var v2s = Matrix.Translation([cop[0], cop[1], 0]);
804 815
805 //mat = v2s.multiply( projMat );
806 mat = glmat4.multiply( v2s, projMat, [] );
807
808 // offset to the parent
809 var offset = this.getElementOffset( stage );
810 var offMat = Matrix.Translation([offset[0], offset[1], 0]);
811 //mat = offMat.multiply( mat );
812 glmat4.multiply( offMat, mat, mat );
813
814 this.popViewportObj(); 816 this.popViewportObj();
815 817
816 // var mat2 = this.getLocalToGlobalMatrix( stage.parentElement ); 818 // append the localToGlobal matrix of the stage.
817 var mat2 = this.getLocalToGlobalMatrix( this._rootElement ); 819 var mat = this.getLocalToGlobalMatrix( stage );
818 //var mat = mat2.multiply( mat ); 820 glmat4.multiply( mat, v2s );
819 glmat4.multiply( mat2, mat, mat );
820 821
821 return mat; 822 return mat;
822 } 823 }
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 4799b840..2276178c 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -71,6 +71,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
71 this._delta = delta.slice(0); 71 this._delta = delta.slice(0);
72 } 72 }
73 73
74 //console.log( "modifyElements delta: " + delta );
74 var transMat = Matrix.Translation( delta ); 75 var transMat = Matrix.Translation( delta );
75 76
76 if(this._inLocalMode && (this._targets.length === 1) ) 77 if(this._inLocalMode && (this._targets.length === 1) )
@@ -79,7 +80,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
79 } 80 }
80 else 81 else
81 { 82 {
82 console.log( "modifyElements delta: " + delta );
83 this._translateGlobally(transMat); 83 this._translateGlobally(transMat);
84 } 84 }
85 } 85 }
@@ -148,7 +148,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
148 _translateGlobally: { 148 _translateGlobally: {
149 value: function (transMat) { 149 value: function (transMat) {
150 //console.log( "_translateGlobally, transMat: " + transMat ); 150 //console.log( "_translateGlobally, transMat: " + transMat );
151 //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); 151 //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat[12] + ", " + transMat[13] + ", " + transMat[14] );
152 var len = this._targets.length, 152 var len = this._targets.length,
153 i = 0, 153 i = 0,
154 item, 154 item,
@@ -167,7 +167,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
167 167
168 var shouldUpdateStartMat = true; 168 var shouldUpdateStartMat = true;
169 169
170 if(this._clickedOnStage) 170 //if (this._clickedOnStage)
171 if(this._clickedOnStage || ((this._handleMode === 2) && (this._targets.length > 1)))
171 { 172 {
172 shouldUpdateStartMat = false; 173 shouldUpdateStartMat = false;
173 } 174 }
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 2c9b484e..f9fd001c 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -405,6 +405,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
405 var index = this._snapIndex; 405 var index = this._snapIndex;
406 var pt0; 406 var pt0;
407 var useViewPoint = (this._inLocalMode && (this._targets.length === 1)); 407 var useViewPoint = (this._inLocalMode && (this._targets.length === 1));
408 //console.log( "useViewPoint: " + useViewPoint );
408 if (this._useQuadPt) 409 if (this._useQuadPt)
409 { 410 {
410 pt0 = this.GetQuadrantPoint(useViewPoint); 411 pt0 = this.GetQuadrantPoint(useViewPoint);
@@ -427,6 +428,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
427 pt1 = MathUtils.transformPoint( pt1, this._startMat ); 428 pt1 = MathUtils.transformPoint( pt1, this._startMat );
428 } 429 }
429 430
431 //console.log( "getMousePoints, useViewPoint: " + useViewPoint + ", " + pt0 + " => " + pt1 );
430 return {pt0:pt0, pt1:pt1}; 432 return {pt0:pt0, pt1:pt1};
431 } 433 }
<