diff options
author | Pushkar Joshi | 2012-04-27 10:03:58 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-27 10:03:58 -0700 |
commit | 40a4d9dbc12e802e2d0a7c3acd69bc7e394d4529 (patch) | |
tree | 6b44ad4243062d5aec653434a96b4d661b674606 | |
parent | d2ff4810064dd902519310fc61e2144ee025ab16 (diff) | |
download | ninja-40a4d9dbc12e802e2d0a7c3acd69bc7e394d4529.tar.gz |
Fix for 1525 Pen: "Uncaught RangeError: Maximum call stack size exceeded".
(check if the second mouse click actually selects the existing first anchor point)
-rwxr-xr-x | js/helper-classes/3D/math-utils.js | 11 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 38 |
2 files changed, 36 insertions, 13 deletions
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 2f0283a9..35ee8112 100755 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js | |||
@@ -928,17 +928,18 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { | |||
928 | return 0; | 928 | return 0; |
929 | } | 929 | } |
930 | //TODO testing...remove this block | 930 | //TODO testing...remove this block |
931 | console.log("getAxisAngleBetween3DVectors Angle: "+angle); | ||
932 | if (isNaN(angle)){ | 931 | if (isNaN(angle)){ |
933 | console.log("getAxisAngleBetween3DVectors Angle is NaN"); | 932 | console.log("Warning! getAxisAngleBetween3DVectors Angle is NaN"); |
934 | } | 933 | } |
935 | //TODO end testing block | 934 | //TODO end testing block |
936 | //optionally, if axis is provided, create the axis of rotation as well | 935 | //optionally, if axis is provided, create the axis of rotation as well |
937 | var rotAxis = VecUtils.vecCross(3, v1n, v2n); | 936 | var rotAxis = VecUtils.vecCross(3, v1n, v2n); |
938 | rotAxis = VecUtils.vecNormalize(3, rotAxis, 1); | 937 | rotAxis = VecUtils.vecNormalize(3, rotAxis, 1); |
939 | axis[0] = rotAxis[0]; | 938 | if (axis){ |
940 | axis[1] = rotAxis[1]; | 939 | axis[0] = rotAxis[0]; |
941 | axis[2] = rotAxis[2]; | 940 | axis[1] = rotAxis[1]; |
941 | axis[2] = rotAxis[2]; | ||
942 | } | ||
942 | return angle; | 943 | return angle; |
943 | } | 944 | } |
944 | }, | 945 | }, |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 8ecc9f79..8cc32536 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -273,14 +273,36 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
273 | var swMousePos = hitRec.calculateStageWorldPoint(); | 273 | var swMousePos = hitRec.calculateStageWorldPoint(); |
274 | swMousePos[0]+= snapManager.getStageWidth()*0.5; swMousePos[1]+= snapManager.getStageHeight()*0.5; | 274 | swMousePos[0]+= snapManager.getStageWidth()*0.5; swMousePos[1]+= snapManager.getStageHeight()*0.5; |
275 | 275 | ||
276 | this._selectedSubpath.addAnchor(new AnchorPoint()); | 276 | //check if the mouse click location is close to the existing anchor |
277 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 277 | var indexAndCode = this._selectedSubpath.pickAnchor(swMousePos[0], swMousePos[1], swMousePos[2], this._PICK_POINT_RADIUS); |
278 | newAnchor.setPos(swMousePos[0], swMousePos[1], swMousePos[2]); | 278 | if (indexAndCode[0]>=0){ |
279 | newAnchor.setPrevPos(swMousePos[0], swMousePos[1], swMousePos[2]); | 279 | //the anchor point was hit, so we do not add another anchor |
280 | newAnchor.setNextPos(swMousePos[0], swMousePos[1], swMousePos[2]); | 280 | switch(indexAndCode[1]){ |
281 | //set the mode so that dragging will update the next and previous locations | 281 | case this._selectedSubpath.SEL_ANCHOR: |
282 | this._editMode = this.EDIT_PREV_NEXT; | 282 | this._editMode = this.EDIT_ANCHOR; |
283 | } | 283 | break; |
284 | case this._selectedSubpath.SEL_PREV: | ||
285 | this._editMode = this.EDIT_PREV; | ||
286 | break; | ||
287 | case this._selectedSubpath.SEL_NEXT: | ||
288 | this._editMode = this.EDIT_NEXT; | ||
289 | break; | ||
290 | default: | ||
291 | this._editMode = this.EDIT_ANCHOR; | ||
292 | console.log("WARNING picked anchor point with incorrect mode"); | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | } else { | ||
297 | this._selectedSubpath.addAnchor(new AnchorPoint()); | ||
298 | var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | ||
299 | newAnchor.setPos(swMousePos[0], swMousePos[1], swMousePos[2]); | ||
300 | newAnchor.setPrevPos(swMousePos[0], swMousePos[1], swMousePos[2]); | ||
301 | newAnchor.setNextPos(swMousePos[0], swMousePos[1], swMousePos[2]); | ||
302 | //set the mode so that dragging will update the next and previous locations | ||
303 | this._editMode = this.EDIT_PREV_NEXT; | ||
304 | } | ||
305 | } //if we have not yet created a canvas for this path | ||
284 | 306 | ||
285 | //the selected subpath has a canvas, so test within that canvas' space | 307 | //the selected subpath has a canvas, so test within that canvas' space |
286 | else | 308 | else |