diff options
Diffstat (limited to 'js/helper-classes')
47 files changed, 7787 insertions, 9616 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/hit-record.js b/js/helper-classes/3D/hit-record.js index 2c60adc6..265bf2a4 100755 --- a/js/helper-classes/3D/hit-record.js +++ b/js/helper-classes/3D/hit-record.js | |||
@@ -232,7 +232,15 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, | |||
232 | var elt = this.getElt(); | 232 | var elt = this.getElt(); |
233 | viewUtils.pushViewportObj( elt ); | 233 | viewUtils.pushViewportObj( elt ); |
234 | var viewPt = viewUtils.screenToView( scrPt[0], scrPt[1], scrPt[2] ); | 234 | var viewPt = viewUtils.screenToView( scrPt[0], scrPt[1], scrPt[2] ); |
235 | var eyePt = viewUtils.getEyePoint(); | 235 | var eyePt; |
236 | if(viewUtils.getPerspectiveDistFromElement(elt)) | ||
237 | { | ||
238 | eyePt = viewUtils.getEyePoint(); | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | eyePt = [viewPt[0], viewPt[1], 1400]; | ||
243 | } | ||
236 | var projPt = MathUtils.vecIntersectPlane( eyePt, MathUtils.vecSubtract(viewPt,eyePt), plane ); | 244 | var projPt = MathUtils.vecIntersectPlane( eyePt, MathUtils.vecSubtract(viewPt,eyePt), plane ); |
237 | 245 | ||
238 | return projPt; | 246 | return projPt; |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 9f6b9ed1..02e81a62 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) { |
@@ -224,7 +229,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
224 | parentPt = [quadPt[0], quadPt[1], 0.0]; | 229 | parentPt = [quadPt[0], quadPt[1], 0.0]; |
225 | else | 230 | else |
226 | parentPt = [xScreen, yScreen, 0.0]; | 231 | parentPt = [xScreen, yScreen, 0.0]; |
227 | var vec = viewUtils.parentToChildVec(parentPt, stage); | 232 | |
233 | var eyePt = []; | ||
234 | var vec = viewUtils.parentToChildVec(parentPt, stage, eyePt); | ||
228 | if (vec) | 235 | if (vec) |
229 | { | 236 | { |
230 | // activate the drag working plane | 237 | // activate the drag working plane |
@@ -236,7 +243,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
236 | var wp = currentWorkingPlane.slice(0); | 243 | var wp = currentWorkingPlane.slice(0); |
237 | var mat = viewUtils.getMatrixFromElement(stage); | 244 | var mat = viewUtils.getMatrixFromElement(stage); |
238 | wp = MathUtils.transformPlane(wp, mat); | 245 | wp = MathUtils.transformPlane(wp, mat); |
239 | var eyePt = viewUtils.getEyePoint(); | ||
240 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); | 246 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); |
241 | if (projPt) | 247 | if (projPt) |
242 | { | 248 |