diff options
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 76 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 8 |
2 files changed, 69 insertions, 15 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 | ||
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 5a36e367..2e8020d3 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -130,10 +130,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
130 | 130 | ||
131 | bindSnap: { | 131 | bindSnap: { |
132 | value: function() { | 132 | value: function() { |
133 | this.addEventListener("change@appModel.snap", this.toggleSnap, false); | 133 | this.addPropertyChangeListener("appModel.snap", this.toggleSnap, false); |
134 | this.addEventListener("change@appModel.snapGrid", this.toggleSnapGrid, false); | 134 | this.addPropertyChangeListener("appModel.snapGrid", this.toggleSnapGrid, false); |
135 | this.addEventListener("change@appModel.snapObjects", this.toggleSnapObjects, false); | 135 | this.addPropertyChangeListener("appModel.snapObjects", this.toggleSnapObjects, false); |
136 | this.addEventListener("change@appModel.snapAlign", this.toggleSnapAlign, false); | 136 | this.addPropertyChangeListener("appModel.snapAlign", this.toggleSnapAlign, false); |
137 | } | 137 | } |
138 | }, | 138 | }, |
139 | 139 | ||