aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D
diff options
context:
space:
mode:
authorJonathan Duran2012-04-10 08:13:00 -0700
committerJonathan Duran2012-04-10 08:13:00 -0700
commit58e049b68e03abbacde93206d2666361022c0858 (patch)
treef1ce6b8a378674d4abcac68acd0bcca93b838a39 /js/helper-classes/3D
parenta9050f96d814469f420bcf3630d16d576b62258e (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-58e049b68e03abbacde93206d2666361022c0858.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js31
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js9
-rwxr-xr-xjs/helper-classes/3D/view-utils.js48
3 files changed, 37 insertions, 51 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index c7c1c08d..a5428ea3 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -112,6 +112,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
112 this.eventManager.addEventListener("elementsRemoved", this, false); 112 this.eventManager.addEventListener("elementsRemoved", this, false);
113 this.eventManager.addEventListener("elementChange", this, false); 113 this.eventManager.addEventListener("elementChange", this, false);
114 this.eventManager.addEventListener("closeDocument", this, false); 114 this.eventManager.addEventListener("closeDocument", this, false);
115 this.eventManager.addEventListener("elementReplaced", this, false);
115 } 116 }
116 }, 117 },
117 118
@@ -170,13 +171,41 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
170 this.removeElement(element); 171 this.removeElement(element);
171 }, this); 172 }, this);
172 } else { 173 } else {
173 this.removeElement(elements._element || elements); 174 this.removeElement(elements);
174 } 175 }
175 176
176 this.drawWorkingPlane(); 177 this.drawWorkingPlane();
177 } 178 }
178 }, 179 },
179 180
181 handleElementReplaced: {
182 value: function(event) {
183 var oldElement = event.detail.data.oldChild;
184 var newElement = event.detail.data.newChild;
185
186 // check if we already know about this object
187 var n = this._eltArray.length,
188 plane;
189 for (var i=0; i<n; i++) {
190 if (oldElement === this._eltArray[i]) {
191 this._eltArray[i] = newElement;
192 plane = this._planesArray[i];
193 break;
194 }
195 }
196
197 if(!plane) {
198 this._eltArray.push( newElement );
199 plane = Object.create(this.ElementPlanes, {});
200 this._planesArray.push( plane );
201 }
202
203 plane.setElement( newElement );
204 plane.init();
205 newElement.elementModel.props3D.elementPlane = plane;
206 }
207 },
208
180 _shouldUpdatePlanes: { 209 _shouldUpdatePlanes: {
181 value: function(props) { 210 value: function(props) {
182 if(!props) { 211 if(!props) {
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 9f6b9ed1..a401c363 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -124,6 +124,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
124 initialize: { 124 initialize: {
125 value: function() { 125 value: function() {
126 this.eventManager.addEventListener("elementsRemoved", this, false); 126 this.eventManager.addEventListener("elementsRemoved", this, false);
127 this.eventManager.addEventListener("elementReplaced", this, false);
127 } 128 }
128 }, 129 },
129 130
@@ -170,15 +171,19 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
170 if(Array.isArray(elements)) { 171 if(Array.isArray(elements)) {
171 elements = Array.prototype.slice.call(elements, 0); 172 elements = Array.prototype.slice.call(elements, 0);
172 elements.forEach(function(element) { 173 elements.forEach(function(element) {
173 element = element._element || element;
174 self.removeElementFrom2DCache(element); 174 self.removeElementFrom2DCache(element);
175 }); 175 });
176 } else { 176 } else {
177 this.removeElementFrom2DCache(elements._element || elements); 177 this.removeElementFrom2DCache(elements);
178 } 178 }
179 } 179 }
180 }, 180 },
181 181
182 handleElementReplaced: {
183 value: function(event) {
184 this._isCacheInvalid = true;
185 }
186 },
182 187
183 setCurrentStage: { 188 setCurrentStage: {
184 value: function(stage) { 189 value: function(stage) {
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a72b7906..63c2cb52 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -1099,54 +1099,6 @@ exports.ViewUtils = Montage.create(Component, {
1099 } 1099 }
1100 }, 1100 },
1101 1101
1102 transformStringToMat: {
1103 value: function( str ) {
1104 var rtnMat;
1105
1106 var index1 = str.indexOf( "matrix3d(");
1107 if (index1 >= 0)
1108 {
1109 index1 += 9; // do not include 'matrix3d('
1110 var index2 = str.indexOf( ")", index1 );
1111 if (index2 >= 0)
1112 {
1113 var substr = str.substr( index1, (index2-index1));
1114 if (substr && (substr.length > 0))
1115 {
1116 var numArray = substr.split(',');
1117 var nNums = numArray.length;
1118 if (nNums == 16)
1119 {
1120 // gl-matrix wants row order
1121 rtnMat = numArray;
1122 for (var i=0; i<16; i++)
1123 rtnMat[i] = Number( rtnMat[i] );
1124
1125 // the matrix as input is column major order. The Matrix
1126 // class expects the numbers in row major order.
1127 /*
1128 var rowArray = new Array;
1129 for (var i=0; i<4; i++)
1130 {
1131 rtnMat.push( numArray[i] );
1132 var row = new Array;
1133 row.push( Number(numArray[i ]) );
1134 row.push( Number(numArray[i+ 4]) );
1135 row.push( Number(numArray[i+ 8]) );
1136 row.push( Number(numArray[i+12]) );
1137 rowArray.push( row );
1138 }
1139 rtnMat = Matrix.create( rowArray );
1140 */
1141 }
1142 }
1143 }
1144 }
1145
1146 return rtnMat;
1147 }
1148 },
1149
1150 pushViewportObj: { 1102 pushViewportObj: {
1151 value: function( obj ) { 1103 value: function( obj ) {
1152 this._viewportObjStack.push( this.m_viewportObj ); 1104 this._viewportObjStack.push( this.m_viewportObj );