aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-02 18:00:45 -0800
committerJose Antonio Marquez2012-02-02 18:00:45 -0800
commit04d89daed90c35a4393773ca2e2d0ac3a4c15cd4 (patch)
treed0041abc7379ef38b20cce148e5dea6f531b8569 /js/helper-classes
parent4d8306b638c53899403a4f0328c02bf1ab893e8f (diff)
parentc630ead20487c3948fa36448d3e7d5f7b5cba782 (diff)
downloadninja-04d89daed90c35a4393773ca2e2d0ac3a4c15cd4.tar.gz
Merge branch 'refs/heads/NinjaInternal' into FileIO
Conflicts: .gitignore js/ninja.reel/ninja.js
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js28
-rwxr-xr-xjs/helper-classes/3D/math-utils.js54
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js11
-rwxr-xr-xjs/helper-classes/Properties3D.js82
-rwxr-xr-xjs/helper-classes/RDGE/GLBrushStroke.js1
-rwxr-xr-xjs/helper-classes/RDGE/GLSubpath.js1
6 files changed, 68 insertions, 109 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 3fd6e8fc..fd96af4d 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -107,6 +107,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
107 107
108 this.eventManager.addEventListener("elementAdded", this, false); 108 this.eventManager.addEventListener("elementAdded", this, false);
109 this.eventManager.addEventListener("elementDeleted", this, false); 109 this.eventManager.addEventListener("elementDeleted", this, false);
110 this.eventManager.addEventListener("elementChange", this, false);
110 } 111 }
111 }, 112 },
112 113
@@ -124,6 +125,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
124 }, 125 },
125 126
126 127
128 handleElementChange: {
129 value: function(event) {
130 var els = event.detail.data.els;
131 if(els)
132 {
133 var len = els.length,
134 i = 0,
135 item,
136 el;
137
138 for(i=0; i < len; i++) {
139 item = els[i];
140 el = item._element || item;
141 el.elementModel.props3D.elementPlane.init();
142 }
143
144 this.drawWorkingPlane();
145 }
146 }
147 },
148
127 /////////////////////////////////////////////////////////////////////// 149 ///////////////////////////////////////////////////////////////////////
128 // Methods 150 // Methods
129 /////////////////////////////////////////////////////////////////////// 151 ///////////////////////////////////////////////////////////////////////
@@ -150,6 +172,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
150 plane.setElement( elt ); 172 plane.setElement( elt );
151 plane.init(); 173 plane.init();
152 this._planesArray.push( plane ); 174 this._planesArray.push( plane );
175 elt.elementModel.props3D.elementPlane = plane;
153 } 176 }
154 }, 177 },
155 178
@@ -166,6 +189,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
166 189
167 // Then remove the element 190 // Then remove the element
168 this._eltArray.splice(i, 1); 191 this._eltArray.splice(i, 1);
192
193 // TODO - May need to delete props3D and elementPlane as well
169 return; 194 return;
170 } 195 }
171 } 196 }
@@ -1064,7 +1089,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1064 var resMat = glmat4.multiply( tMat, mat, [] ); 1089 var resMat = glmat4.multiply( tMat, mat, [] );
1065 var origin = [0,0,0,1]; 1090 var origin = [0,0,0,1];
1066 1091
1067 var arrowSize = 50; 1092 var zoomFactor = this.application.ninja.documentBar.zoomFactor/100.0;
1093 var arrowSize = 50 / zoomFactor;
1068 var xAxis = [arrowSize,0,0,1]; 1094 var xAxis = [arrowSize,0,0,1];
1069 //var rO = resMat.multiply(origin); 1095 //var rO = resMat.multiply(origin);
1070 var rO = glmat4.multiplyVec3( resMat, origin, []); 1096 var rO = glmat4.multiplyVec3( resMat, origin, []);
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js
index 49c77c41..71ed62a0 100755
--- a/js/helper-classes/3D/math-utils.js
+++ b/js/helper-classes/3D/math-utils.js
@@ -891,36 +891,32 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
891 } 891 }
892 }, 892 },
893 893
894/**
895* decompose matrix in javascript found at https://github.com/joelambert/morf/blob/master/js/src/WebkitCSSMatrix.ext.js
896* used with permission from Joe Lambert: "as long as the original licence text and attribution is left in then you're
897* good to use it as you see fit."
898*
899* WebKitCSSMatrix Extensions
900*
901* Copyright 2011, Joe Lambert (http://www.joelambert.co.uk)
902* Free to use under the MIT license.
903* http://joelambert.mit-license.org/
904*/
905
906/**
907* Decomposes the matrix into its component parts.
908* A Javascript implementation of the pseudo code available from http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition
909* @author Joe Lambert
910* @returns {Object} An object with each of the components of the matrix (perspective, translate, skew, scale, rotate) or identity matrix on failure
911*/
912
894// Input: matrix ; a 4x4 matrix 913// Input: matrix ; a 4x4 matrix
895// Output: translation ; a 3 component vector 914// Output: translation ; a 3 component vector
896// rotation ; Euler angles, represented as a 3 component vector 915// rotation ; Euler angles, represented as a 3 component vector
897// scale ; a 3 component vector 916// scale ; a 3 component vector
898// skew ; skew factors XY,XZ,YZ represented as a 3 component vector 917// skew ; skew factors XY,XZ,YZ represented as a 3 component vector
899// perspective ; a 4 component vector 918// perspective ; a 4 component vector
900// Returns false if the matrix cannot be decomposed, an object with the above output values if it can 919// Returns false if the matrix cannot be decomposed. An object with the above output values if it can.
901//
902// Supporting functions (point is a 3 component vector, matrix is a 4x4 matrix):
903// float determinant(matrix) returns the 4x4 determinant of the matrix
904// matrix inverse(matrix) returns the inverse of the passed matrix
905// matrix transpose(matrix) returns the transpose of the passed matrix
906// point multVecMatrix(point, matrix) multiplies the passed point by the passed matrix
907// and returns the transformed point
908// float length(point) returns the length of the passed vector
909// point normalize(point) normalizes the length of the passed point to 1
910// float dot(point, point) returns the dot product of the passed points
911// float cos(float) returns the cosine of the passed angle in radians
912// float asin(float) returns the arcsine in radians of the passed value
913// float atan2(float y, float x) returns the principal value of the arc tangent of
914// y/x, using the signs of both arguments to determine
915// the quadrant of the return value
916//
917// Decomposition also makes use of the following function:
918// point combine(point a, point b, float ascl, float bscl)
919// result[0] = (ascl * a[0]) + (bscl * b[0])
920// result[1] = (ascl * a[1]) + (bscl * b[1])
921// result[2] = (ascl * a[2]) + (bscl * b[2])
922// return result
923//
924 decomposeMatrix2: { 920 decomposeMatrix2: {
925 value: function(m) 921 value: function(m)
926 { 922 {
@@ -1077,7 +1073,6 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
1077 rotate[2] = 0; 1073 rotate[2] = 0;
1078 } 1074 }
1079 1075
1080// return true;
1081 return {translation: translate, 1076 return {translation: translate,
1082 rotation: rotate, 1077 rotation: rotate,
1083 scale: scale, 1078 scale: scale,
@@ -1087,6 +1082,15 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
1087 } 1082 }
1088 }, 1083 },
1089 1084
1085/**
1086* Helper function required for matrix decomposition
1087* A Javascript implementation of pseudo code available from http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition
1088* @param {Vector4} aPoint A 3D point
1089* @param {float} ascl
1090* @param {float} bscl
1091* @author Joe Lambert
1092* @returns {Vector4}
1093*/
1090 combine: { 1094 combine: {
1091 value: function(a, b, ascl, bscl) 1095 value: function(a, b, ascl, bscl)
1092 { 1096 {
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 3ed96082..8819f637 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -1780,7 +1780,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1780 var mergedSnap = this.mergeHitRecords( hitRecs ); 1780 var mergedSnap = this.mergeHitRecords( hitRecs );
1781 if (mergedSnap) 1781 if (mergedSnap)
1782 { 1782 {
1783 while (hitRecs.length > 0) hitRecs.pop(); 1783 while (hitRecs.length > 0) hitRecs.pop();
1784 hitRecs.push( mergedSnap ); 1784 hitRecs.push( mergedSnap );
1785 //console.log( "merged snaps" ); 1785 //console.log( "merged snaps" );
1786 } 1786 }
@@ -1836,6 +1836,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1836 hSnap.setLocalPoint( localPt ); 1836 hSnap.setLocalPoint( localPt );
1837 hSnap.setScreenPoint( scrPt ); 1837 hSnap.setScreenPoint( scrPt );
1838 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); 1838 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED );
1839 hSnap.setElement( stage );
1840 hSnap.setPlane( [0,0,1,0] );
1841 hSnap.setPlaneMatrix( Matrix.I(4) );
1839 if (vSnap.hasAssociatedScreenPoint() ) 1842 if (vSnap.hasAssociatedScreenPoint() )
1840 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); 1843 hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() );
1841 if (vSnap.hasAssociatedScreenPoint2() ) 1844 if (vSnap.hasAssociatedScreenPoint2() )
@@ -1882,6 +1885,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1882 hSnap.setLocalPoint( localPt ); 1885 hSnap.setLocalPoint( localPt );
1883 hSnap.setScreenPoint( scrPt ); 1886 hSnap.setScreenPoint( scrPt );
1884 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); 1887 hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED );
1888 hSnap.setElement( stage );
1889 hSnap.setPlane( [0,0,1,0] );
1890 hSnap.setPlaneMatrix( Matrix.I(4) );
1885 if (vSnap.hasAssociatedScreenPoint() ) 1891