diff options
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 79 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 18 | ||||
-rwxr-xr-x | js/helper-classes/3D/vec-utils.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 13 |
4 files changed, 65 insertions, 47 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index d6334e6c..c7c1c08d 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -109,8 +109,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
109 | this._gridOrigin = [0,0]; // 2D plane space point | 109 | this._gridOrigin = [0,0]; // 2D plane space point |
110 | 110 | ||
111 | this.eventManager.addEventListener("elementAdded", this, false); | 111 | this.eventManager.addEventListener("elementAdded", this, false); |
112 | this.eventManager.addEventListener("elementDeleted", this, false); | 112 | this.eventManager.addEventListener("elementsRemoved", this, false); |
113 | this.eventManager.addEventListener("deleteSelection", this, false); | ||
114 | this.eventManager.addEventListener("elementChange", this, false); | 113 | this.eventManager.addEventListener("elementChange", this, false); |
115 | this.eventManager.addEventListener("closeDocument", this, false); | 114 | this.eventManager.addEventListener("closeDocument", this, false); |
116 | } | 115 | } |
@@ -147,38 +146,47 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
147 | 146 | ||
148 | handleElementAdded: { | 147 | handleElementAdded: { |
149 | value: function(event) { | 148 | value: function(event) { |
150 | this.addElement(event.detail); | 149 | var elements = event.detail; |
150 | |||
151 | if(Array.isArray(elements)) { | ||
152 | elements.forEach(function(element) { | ||
153 | this.addElement(element); | ||
154 | }, this); | ||
155 | } else { | ||
156 | this.addElement(elements); | ||
157 | } | ||
158 | |||
151 | this.drawWorkingPlane(); | 159 | this.drawWorkingPlane(); |
152 | } | 160 | } |
153 | }, | 161 | }, |
154 | 162 | ||
155 | handleElementDeleted: { | 163 | handleElementsRemoved: { |
156 | value: function(event) { | 164 | value: function(event) { |
157 | this.removeElement(event.detail); | 165 | var elements = event.detail; |
158 | } | 166 | |
159 | }, | 167 | if(Array.isArray(elements)) { |
168 | elements = Array.prototype.slice.call(elements, 0); | ||
169 | elements.forEach(function(element) { | ||
170 | this.removeElement(element); | ||
171 | }, this); | ||
172 | } else { | ||
173 | this.removeElement(elements._element || elements); | ||
174 | } | ||
160 | 175 | ||
161 | handleDeleteSelection: { | ||
162 | value: function(event) { | ||
163 | this.drawWorkingPlane(); | 176 | this.drawWorkingPlane(); |
164 | } | 177 | } |
165 | }, | 178 | }, |
166 | 179 | ||
167 | _shouldUpdatePlanes: { | 180 | _shouldUpdatePlanes: { |
168 | value: function(props) { | 181 | value: function(props) { |
169 | if(!props) | 182 | if(!props) { |
170 | { | ||
171 | return false; | 183 | return false; |
172 | } | 184 | } else if (typeof props === "string") { |
173 | else if (typeof props === "string") | ||
174 | { | ||
175 | return (this._updatePlaneProps.indexOf(props) !== -1); | 185 | return (this._updatePlaneProps.indexOf(props) !== -1); |
176 | } | 186 | } |
177 | 187 | ||
178 | for (var p in props) | 188 | for (var p in props) { |
179 | { | 189 | if(this._updatePlaneProps.indexOf(p) !== -1) { |
180 | if(this._updatePlaneProps.indexOf(p) !== -1) | ||
181 | { | ||
182 | return true; | 190 | return true; |
183 | } | 191 | } |
184 | } | 192 | } |
@@ -199,15 +207,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
199 | { | 207 | { |
200 | var len = els.length, | 208 | var len = els.length, |
201 | i = 0, | 209 | i = 0, |
202 | item, | 210 | item; |
203 | el; | ||
204 | 211 | ||
205 | for(i=0; i < len; i++) { | 212 | for(i=0; i < len; i++) { |
206 | item = els[i]; | 213 | if(els[i].elementModel.props3D.elementPlane) |
207 | el = item._element || item; | ||
208 | if(el.elementModel.props3D.elementPlane) | ||
209 | { | 214 | { |
210 | el.elementModel.props3D.elementPlane.init(); | 215 | els[i].elementModel.props3D.elementPlane.init(); |
211 | } | 216 | } |
212 | } | 217 | } |
213 | 218 | ||
@@ -222,17 +227,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
222 | // Methods | 227 | // Methods |
223 | /////////////////////////////////////////////////////////////////////// | 228 | /////////////////////////////////////////////////////////////////////// |
224 | 229 | ||
225 | addElement: | 230 | addElement: { |
226 | { | 231 | value: function( elt ) { |
227 | value: function( elt ) | ||
228 | { | ||
229 | // check if we already know about this object | 232 | // check if we already know about this object |
230 | var n = this._eltArray.length; | 233 | var n = this._eltArray.length; |
231 | for (var i=0; i<n; i++) | 234 | for (var i=0; i<n; i++) { |
232 | { | 235 | if (elt == this._eltArray[i]) { |
233 | if (elt == this._eltArray[i]) | ||
234 | { | ||
235 | // console.log( "element already added to stage display: " + elt.id ); | ||
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | } | 238 | } |
@@ -248,17 +248,14 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
248 | } | 248 | } |
249 | }, | 249 | }, |
250 | 250 | ||
251 | removeElement : { | 251 | removeElement: { |
252 | value: function( elt ) { | 252 | value: function(element) { |
253 | // check if object exists | 253 | // check if object exists |
254 | var n = this._eltArray.length; | 254 | var _elements = this._eltArray.length; |
255 | for (var i=0; i<n; i++) | 255 | for (var i=0; i < _elements; i++) { |
256 | { | 256 | if (element === this._eltArray[i]) { |
257 | if (elt == this._eltArray[i]) | ||
258 | { | ||
259 | // First remove the planes for this element | 257 | // First remove the planes for this element |
260 | this._planesArray.splice(i, 1); | 258 | this._planesArray.splice(i, 1); |
261 | |||
262 | // Then remove the element | 259 | // Then remove the element |
263 | this._eltArray.splice(i, 1); | 260 | this._eltArray.splice(i, 1); |
264 | 261 | ||
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index a755e9e2..67dedc49 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -123,7 +123,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
123 | /////////////////////////////////////////////////////////////////////// | 123 | /////////////////////////////////////////////////////////////////////// |
124 | initialize: { | 124 | initialize: { |
125 | value: function() { | 125 | value: function() { |
126 | this.eventManager.addEventListener("elementDeleted", this, false); | 126 | this.eventManager.addEventListener("elementsRemoved", this, false); |
127 | } | 127 | } |
128 | }, | 128 | }, |
129 | 129 | ||
@@ -163,9 +163,19 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
163 | }, | 163 | }, |
164 | 164 | ||
165 | 165 | ||
166 | handleElementDeleted: { | 166 | handleElementsRemoved: { |
167 | value: function(event) { | 167 | value: function(event) { |
168 | this.removeElementFrom2DCache(event.detail); | 168 | var self = this, elements = event.detail; |
169 | |||
170 | if(Array.isArray(elements)) { | ||
171 | elements = Array.prototype.slice.call(elements, 0); | ||
172 | elements.forEach(function(element) { | ||
173 | element = element._element || element; | ||
174 | self.removeElementFrom2DCache(element); | ||
175 | }); | ||
176 | } else { | ||
177 | this.removeElementFrom2DCache(elements._element || elements); | ||
178 | } | ||
169 | } | 179 | } |
170 | }, | 180 | }, |
171 | 181 | ||
@@ -1411,6 +1421,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1411 | case glObj.GEOM_TYPE_PATH: | 1421 | case glObj.GEOM_TYPE_PATH: |
1412 | // Snapping not implemented for these type, but don't throw an error... | 1422 | // Snapping not implemented for these type, but don't throw an error... |
1413 | break; | 1423 | break; |
1424 | case glObj.GEOM_TYPE_BRUSH_STROKE: | ||
1425 | break; //don't throw error because snapping not yet implemented | ||
1414 | case glObj.GEOM_TYPE_CUBIC_BEZIER: | 1426 | case glObj.GEOM_TYPE_CUBIC_BEZIER: |
1415 | { | 1427 | { |
1416 | var nearVrt = glObj.getNearVertex( eyePt, dir ); | 1428 | var nearVrt = glObj.getNearVertex( eyePt, dir ); |
diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js index e6db4a8d..4eacd856 100755 --- a/js/helper-classes/3D/vec-utils.js +++ b/js/helper-classes/3D/vec-utils.js | |||
@@ -259,6 +259,6 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype, | |||
259 | glmat4.rotate(mat, angle, axis); | 259 | glmat4.rotate(mat, angle, axis); |
260 | return mat; | 260 | return mat; |
261 | } | 261 | } |
262 | }, | 262 | } |
263 | 263 | ||
264 | }); \ No newline at end of file | 264 | }); \ No newline at end of file |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 5a820fc2..a72b7906 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -1200,10 +1200,19 @@ exports.ViewUtils = Montage.create(Component, { | |||
1200 | // MISCELLANEOUS | 1200 | // MISCELLANEOUS |
1201 | // event.layerX/Y: var pt = viewUtils.getMousePoint(event); |