diff options
author | Jose Antonio Marquez | 2012-05-16 16:23:05 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-16 16:23:05 -0700 |
commit | d59cb51c275fbbef84604f9ed77afedba8168099 (patch) | |
tree | 7d3f51c20eb6b6940c1ce648d828fa1e2d8d510b /js/helper-classes/3D/draw-utils.js | |
parent | 857aafee732b6a85fa155ff4a05d1b8fde48f09d (diff) | |
parent | 92fcb770aff434e994e7a39a61d8fac4a017dca0 (diff) | |
download | ninja-d59cb51c275fbbef84604f9ed77afedba8168099.tar.gz |
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'js/helper-classes/3D/draw-utils.js')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index b53ac4ad..a6d2d899 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -119,19 +119,43 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
119 | 119 | ||
120 | initializeFromDocument:{ | 120 | initializeFromDocument:{ |
121 | value:function(){ | 121 | value:function(){ |
122 | var documentRootChildren = null, i; | 122 | var documentRootChildren = null, i, stage = this.application.ninja.stage; |
123 | //initialize with current document | 123 | //initialize with current document |
124 | this._eltArray = []; | 124 | this._eltArray = []; |
125 | this._planesArray = []; | 125 | this._planesArray = []; |
126 | this.setDrawingSurfaceElement(this.application.ninja.stage.canvas); | 126 | this.setDrawingSurfaceElement(stage.canvas); |
127 | this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage ); | 127 | this.setSourceSpaceElement( stage.stageDeps.currentStage ); |
128 | this.setWorkingPlane( [0,0,1,0] ); | 128 | this.setWorkingPlane( [0,0,1,0] ); |
129 | 129 | ||
130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them | 130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them |
131 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ | 131 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ |
132 | documentRootChildren = this.application.ninja.currentDocument._liveNodeList; | 132 | documentRootChildren = this.application.ninja.currentDocument._liveNodeList; |
133 | for(i=0;i<documentRootChildren.length;i++){ | 133 | var len = documentRootChildren.length, |
134 | this.addElement(documentRootChildren[i]); | 134 | minLeft = stage.userPaddingLeft, |
135 | minTop = stage.userPaddingTop, | ||
136 | docLeft = stage.documentOffsetLeft, | ||
137 | docTop = stage.documentOffsetTop, | ||
138 | l, | ||
139 | t, | ||
140 | plane, | ||
141 | elt | ||
142 | for(i=0; i<len; i++) { | ||
143 | elt = documentRootChildren[i]; | ||
144 | plane = this.addElement(elt); | ||
145 | l = plane._rect.m_left - docLeft; | ||
146 | t = plane._rect.m_top - docTop; | ||
147 | if(l < minLeft) { | ||
148 | minLeft = l; | ||
149 | } | ||
150 | if(t < minTop) { | ||
151 | minTop = t; | ||
152 | } | ||
153 | } | ||
154 | if(minLeft !== stage.userPaddingLeft) { | ||
155 | stage.userPaddingLeft = minLeft; | ||
156 | } | ||
157 | if(minTop !== stage.userPaddingTop) { | ||
158 | stage.userPaddingTop = minTop; | ||
135 | } | 159 | } |
136 | } | 160 | } |
137 | } | 161 | } |
@@ -245,16 +269,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
245 | } | 269 | } |
246 | var els = event.detail.data.els; | 270 | var els = event.detail.data.els; |
247 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { | 271 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { |
248 | var len = els.length; | 272 | var len = els.length, |
273 | stage = this.application.ninja.stage, | ||
274 | minLeft = stage.userPaddingLeft, | ||
275 | minTop = stage.userPaddingTop, | ||
276 | docLeft = stage.documentOffsetLeft, | ||
277 | docTop = stage.documentOffsetTop, | ||
278 | l, | ||
279 | t, | ||
280 | plane, | ||
281 | changed = false; | ||
249 | for(var i=0; i < len; i++) { | 282 | for(var i=0; i < len; i++) { |
250 | if(els[i].elementModel.props3D.elementPlane) { | 283 | plane = els[i].elementModel.props3D.elementPlane; |
251 | els[i].elementModel.props3D.elementPlane.init(); | 284 | if(plane) { |
285 | plane.init(); | ||
286 | l = plane._rect.m_left - docLeft; | ||
287 | t = plane._rect.m_top - docTop; | ||
288 | if(l < minLeft) { | ||
289 | minLeft = l; | ||
290 | } | ||
291 | if(t < minTop) { | ||
292 | minTop = t; | ||
293 | } | ||
252 | } | 294 | } |
253 | } | 295 | } |
254 | 296 | ||
255 | this.application.ninja.stage.layout.draw(); | 297 | if(minLeft !== stage.userPaddingLeft) { |
256 | this.drawWorkingPlane(); | 298 | stage.userPaddingLeft = minLeft; |
257 | this.draw3DCompass(); | 299 | changed = true; |
300 | } | ||
301 | if(minTop !== stage.userPaddingTop) { | ||
302 | stage.userPaddingTop = minTop; | ||
303 | changed = true; | ||
304 | } | ||
305 | |||
306 | if(!changed) { | ||
307 | stage.layout.draw(); | ||
308 | this.drawWorkingPlane(); | ||
309 | this.draw3DCompass(); | ||
310 | } | ||
258 | } | 311 | } |
259 | } | 312 | } |
260 | }, | 313 | }, |
@@ -281,6 +334,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
281 | plane.init(); | 334 | plane.init(); |
282 | this._planesArray.push( plane ); | 335 | this._planesArray.push( plane ); |
283 | elt.elementModel.props3D.elementPlane = plane; | 336 | elt.elementModel.props3D.elementPlane = plane; |
337 | return plane; | ||
284 | } | 338 | } |
285 | }, | 339 | }, |
286 | 340 | ||